HighDots Forums  

Form Submission

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Form Submission in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shaun
 
Posts: n/a

Default Form Submission - 07-06-2004 , 05:28 AM






Hi,

How can I check if a form has been submitted, I have seen a demo that uses
the following:

if(isset($HTTP_POST_VARS))

But I understand that $HTTP_POST_VARS is depricated...

Thanks for your help



Reply With Quote
  #2  
Old   
Gary White
 
Posts: n/a

Default Re: Form Submission - 07-06-2004 , 08:54 AM






On Tue, 6 Jul 2004 10:28:20 +0100, "Shaun" <nospam (AT) nospam (DOT) com> wrote:

Quote:
How can I check if a form has been submitted, I have seen a demo that uses
the following:

if(isset($HTTP_POST_VARS))

But I understand that $HTTP_POST_VARS is depricated...

The $HTTP_POST_VARS, like the newer $_POST, is always set. The $_POST
array was introduced in PHP version 4.1.0. If there is a possibility
that the script might need to run on a version older than that, then
$HTTP_POST_VARS is the only reliable method.

However, being automatically created globals, both $HTTP_POST_VARS and
$_POST are always set. The only caveat is that $HTTP_POST_VARS is not
automatically global inside functions. Inside a function, you need to
declare it as a global.

To test effectively, you would need to test for a specific value. For
example, if your form has a submit button named "submit", you could test
for that:

if(isset($HTTP_POST_VARS['submit']))
echo "Form was submitted";
else
echo "Form has not been submitted";


Gary


Reply With Quote
  #3  
Old   
Gordon Mackay
 
Posts: n/a

Default Re: Form Submission - 07-06-2004 , 12:04 PM



Shaun wrote:

Quote:
Hi,

How can I check if a form has been submitted, I have seen a demo that uses
the following:

if(isset($HTTP_POST_VARS))

But I understand that $HTTP_POST_VARS is depricated...

Thanks for your help


Try this:

<?php if ($_POST){ if
(mail("YOU (AT) YOU (DOT) COM",$_POST['subject'],stripslashes($_POST['body']),"From:
".$_POST['email']."\r\n")){ ?>
<p>Your message is now winging its way to me at supersonic speed!</p>
<h2>You said:</h2>
<blockquote>“<?php echo "$body" ?>”.</blockquote>
<p>I will be in touch with you as quickly as possible.</p>
<?php }else{ ?>
<p>Message Failed, the gremlins are playing up!</p>
<?php } }else{ ?>
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post"
name="mailform" id="mailform">
<fieldset title="Send Me Some Mail">
<legend>Send Me Some Mail</legend>
<label for="subject">Subject:</label>
<select name="subject" id="subject">
<option selected="selected">Enquiry</option>
<option>Suggestion</option>
<option>Praise</option>
<option>Design Work</option>
</select>
<label for="email">Email:</label>
<input name="email" type="text" id="email" value="Your email here" />
<label for="body">Message:</label>
<textarea name="body" cols="30" rows="12" id="body">Message you wish to
send</textarea>
<input type="submit" name="Submit" value="Send" id="Submit" />
</fieldset>
</form>
<?php } ?>

If it's sent you should get:

Your message is now winging its way to me at supersonic speed!

you said:

"blah blah blah"

I will be in touch with you as quickly as possible.

If it failed:

Message Failed, the gremlins are playing up!


Hope this helps

Gordon M

http://gordonmac.com




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.