perezf Posted August 18, 2006 Share Posted August 18, 2006 i cant seem to figure out what is going wrong im sure it is something simplebut the email function is not working[code]<div align="center"><form name="form1" method="post" action=""> <p>Your Name:<br> <input name="name" type="text" size="50"> </p> <p>Your Email:<br> <input name="from" type="text" size="50"> </p> <p>Your Question:<br> <textarea name="contents" cols="50" rows="5"></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form></div><?phpif(isset($_POST['Submit'])){}else{$to = "2fr3sh@gmail.com";$subject = "Question from DoitYourself";$from_header = "From: $from"; mail($to, $subject, $contents, $from_header);echo "Thank You for using the 2fr3sh emailer the messages have been sent!";};?>[/code] Quote Link to comment Share on other sites More sharing options...
craygo Posted August 18, 2006 Share Posted August 18, 2006 you have your isset function wrong. Also if you have globals turned off, which they are by default, you cannot just use $from.try this[code]<?phpif(isset($_POST['Submit'])){$to = "2fr3sh@gmail.com";$subject = "Question from DoitYourself";$from_header = "From: $_POST['from']"; mail($to, $subject, $contents, $from_header);echo "Thank You for using the 2fr3sh emailer the messages have been sent!";} else {?><div align="center"><form name="form1" method="post" action=""> <p>Your Name:<br> <input name="name" type="text" size="50"> </p> <p>Your Email:<br> <input name="from" type="text" size="50"> </p> <p>Your Question:<br> <textarea name="contents" cols="50" rows="5"></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form></div><?}?>[/code] Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 18, 2006 Share Posted August 18, 2006 [code]<form name="form1" method="post" action="">[/code]You have not defined [b]action[/b] in your form, so the data you submit doesn't get sent anywhere. Try this:[code]<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">[/code] Quote Link to comment Share on other sites More sharing options...
craygo Posted August 18, 2006 Share Posted August 18, 2006 good job heyray2 I blew right past that part :) Quote Link to comment Share on other sites More sharing options...
perezf Posted August 18, 2006 Author Share Posted August 18, 2006 worked perfectly thank you Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 18, 2006 Share Posted August 18, 2006 Glad to help... ;) Quote Link to comment Share on other sites More sharing options...
perezf Posted August 18, 2006 Author Share Posted August 18, 2006 i wouldnt recommend putting<?php echo $_SERVER['PHP_SELF']; ?>because it just goes to the main page index.php not to the page i want it to stay onleaving the action blank makes the same page reload allowing the script to work now Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 18, 2006 Share Posted August 18, 2006 [code]<?php echo $_SERVER['PHP_SELF']; ?>[/code]That variable is replaced by the name of the php file that printed out your html form, so only use it if that same php file also does your form processing.Otherwise, enter the name of the file that you want to process the form... ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.