timothyltaylor Posted October 14, 2006 Share Posted October 14, 2006 Hey there ya'll...I'm trying to get this simple form together to be sent back to an email address.Can someone help me out with the correct coding? I keep running into problems! (here are two different pages: 1) the form page, and 2) the sendmail.php file the form requests to send the informationThank you...<form name="form1" method="post" action="sendmail.php"> <table width="600" height="700" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td width="391" height="30" align="right" valign="middle"> Class Date and Location :</td> <td width="336"><input name="classdateandlocation" type="text" size="40"> </td> </tr> <tr> <td height="30" align="right" valign="middle">Instructors :</td> <td><input name="instructors" type="text" size="40"> </td> <tr> <td height="29" align="right" valign="middle">This learning Experience was :</td> <td><p> <input type="radio" name="Q1" checked value="1"> 1 <input type="radio" name="Q1" value="2"> 2 <input type="radio" name="Q1" value="3"> 3 <input type="radio" name="Q1" value="4"> 4 <input type="radio" name="Q1" value="5"> 5 </td> </tr> <tr> <td height="29" align="right" valign="middle">Were the stated learning objectives met? :</td> <td><p> <input type="radio" name="Q2" checked value="1"> 1 <input type="radio" name="Q2" value="2"> 2 <input type="radio" name="Q2" value="3"> 3 <input type="radio" name="Q2" value="4"> 4 <input type="radio" name="Q2" value="5"> 5 </td> </tr> <tr> <tr> <td height="29" align="right" valign="middle"> If applicable, were prerequisites appropriate? :</td> <td><p> <input type="radio" name="Q3" checked value="1"> 1 <input type="radio" name="Q3" value="2"> 2 <input type="radio" name="Q3" value="3"> 3 <input type="radio" name="Q3" value="4"> 4 <input type="radio" name="Q3" value="5"> 5 </td> </tr> <tr> <tr> <td height="29" align="right" valign="middle"> Were program materials both accurate and effective? :</td> <td><p> <input type="radio" name="Q4" checked value="1"> 1 <input type="radio" name="Q4" value="2"> 2 <input type="radio" name="Q4" value="3"> 3 <input type="radio" name="Q4" value="4"> 4 <input type="radio" name="Q4" value="5"> 5 </td> </tr> <tr> <tr> <td height="46" align="right" valign="middle"> Did program materials contribute to the achievement of the learning Objectives? :</td> <td><p> <input type="radio" name="Q5" checked value="1"> 1 <input type="radio" name="Q5" value="2"> 2 <input type="radio" name="Q5" value="3"> 3 <input type="radio" name="Q5" value="4"> 4 <input type="radio" name="Q5" value="5"> 5 </td> </tr> <tr> <tr> <td height="29" align="right" valign="middle"><p>Was the time allotted to the learning experience appropriate? :</p></td> <td><p> <input type="radio" name="Q6" checked value="1"> 1 <input type="radio" name="Q6" value="2"> 2 <input type="radio" name="Q6" value="3"> 3 <input type="radio" name="Q6" value="4"> 4 <input type="radio" name="Q6" value="5"> 5 </td> </tr> <tr> <td height="46" align="right" valign="middle"> Were the facilities and/or the technological equipment appropriate? :</td> <td><p> <input type="radio" name="Q8" checked value="1"> 1 <input type="radio" name="Q8" value="2"> 2 <input type="radio" name="Q8" value="3"> 3 <input type="radio" name="Q8" value="4"> 4 <input type="radio" name="Q8" value="5"> 5 </td> </tr> <tr> <td height="46" align="right" valign="middle"> Were the handouts and advanced preparation materials satisfactory? :</td> <td><p> <input type="radio" name="Q9" checked value="1"> 1 <input type="radio" name="Q9" value="2"> 2 <input type="radio" name="Q9" value="3"> 3 <input type="radio" name="Q9" value="4"> 4 <input type="radio" name="Q9" value="5"> 5 </td> </tr> <tr> <td height="46" align="right" valign="middle"><p>Was the classroom facilitator’s knowledge and experience satisfactory for the course material?:</p></td> <td><p> <input type="radio" name="Q10" checked value="1"> 1 <input type="radio" name="Q10" value="2"> 2 <input type="radio" name="Q10" value="3"> 3 <input type="radio" name="Q10" value="4"> 4 <input type="radio" name="Q10" value="5"> 5 </td> <tr> <td height="120" align="right" valign="top">Comments:</td> <td><textarea name="comments" cols="40" rows="6"></textarea> </td> </tr> <tr> <td height="30"><div align="right">Name : </div></td> <td><input name="name" type="text" id="name" size="40"></td> </tr> <tr> <tr> <td height="30"><div align="right">Address : </div></td> <td><input name="address" type="text" id="address" size="40"></td> </tr> <tr> <td height="30"><div align="right">City : </div></td> <td><input name="city" type="text" id="city" size="40"></td> </tr> <tr> <td height="30"><div align="right">State : </div></td> <td><input name="state" type="text" id="state" size="40"></td> </tr> <tr> <td height="30"><div align="right">Zip : </div></td> <td><input name="zip" type="text" id="zip" size="40"></td> </tr> <tr> <td height="30"><div align="right">Phone : </div></td> <td><input name="phone" type="text" id="phone" size="40"></td> </tr> <td height="31"></td> <td><input type="submit" name="Submit" value="Send"> <input type="reset" name="Reset" value="Reset"></td> </tr> </table> </form>---------------------------------------------------------------------------------------------------------------------<title>sendmail.php</title><?php$to = "myname@mysite.com";$from = stripslashes($_POST['Name']);$subject = "EPSA CAP2 Evaluation Results".stripslashes($_POST['Subject']);$body = "Message from: $from\n\n".stripslashes($_POST['name']);$comments = "Comments:".stripslashes($_POST['comments']) . "$body = "Class Date and Locaion:".stripslashes($POST['classdateandlocation']) . "$Q1 = "Question 1".stripslashes($_POST['Q1']);$Q2 = "Question 2".stripslashes($_POST['Q2']);$Q3 = "Question 3".stripslashes($_POST['Q3']);$Q4 = "Question 4".stripslashes($_POST['Q4']);$Q5 = "Question 5".stripslashes($_POST['Q5']);$Q6 = "Question 6".stripslashes($_POST['Q6']);$Q7 = "Question 7".stripslashes($_POST['Q7']);$Q8 = "Question 8".stripslashes($_POST['Q8']);$Q9 = "Question 9".stripslashes($_POST['Q9']);$Q10 = "Question 10".stripslashes($_POST['Q10']);if (mail("$to","$from","$subject","$body","$Q1","$Q2","$Q3","$Q4","$Q5","$Q6","$Q7","$Q8","$Q9","$Q10")) echo nl2br("<b>Message Sent:</b> To: $recipient Subject: $subject Choices: $msg Message: $comments"); else echo "Message failed to send"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/ Share on other sites More sharing options...
trq Posted October 14, 2006 Share Posted October 14, 2006 [quote]Can someone help me out with the correct coding? I keep running into problems![/quote]And what [i]exactly[/i] are those problems? Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-108713 Share on other sites More sharing options...
timothyltaylor Posted October 14, 2006 Author Share Posted October 14, 2006 The email supposed to return all of the form fields returns this information only:[i]From: www@host28.christianwebhost.com[/i][i]Class Date and Locaion:EPSA CAP2 Evaluation Results[/i] For some reason, I'm missing the correct variables to grab the information from the form, and return them in the email...Thanks thorpe...-------------------------------------------------------<title>sendmail.php</title><?php$to = "myname@mysite.com";$from = stripslashes($_POST['Name']);$subject = "EPSA CAP2 Evaluation Results".stripslashes($_POST['Subject']);$body = "Message from: $from\n\n".stripslashes($_POST['name']);$comments = "Comments:".stripslashes($_POST['comments']);$body = "Class Date and Locaion:".stripslashes($POST['classdateandlocation']);$Q1 = "Question 1".stripslashes($_POST['Q1']);$Q2 = "Question 2".stripslashes($_POST['Q2']);$Q3 = "Question 3".stripslashes($_POST['Q3']);$Q4 = "Question 4".stripslashes($_POST['Q4']);$Q5 = "Question 5".stripslashes($_POST['Q5']);$Q6 = "Question 6".stripslashes($_POST['Q6']);$Q7 = "Question 7".stripslashes($_POST['Q7']);$Q8 = "Question 8".stripslashes($_POST['Q8']);$Q9 = "Question 9".stripslashes($_POST['Q9']);$Q10 = "Question 10".stripslashes($_POST['Q10']);if (mail("$to","$from","$subject","$body","$Q1-Q10")) echo nl2br("<b>Message Sent:</b> To: $recipient Subject: $subject Choices: $Q1,$Q2,$Q3,$Q4,$Q5,QQ6,$Q7,$Q8,$Q9,$Q10 Message: $comments"); else echo "Message failed to send";?> Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-108714 Share on other sites More sharing options...
.josh Posted October 14, 2006 Share Posted October 14, 2006 if (mail("$to","$from","$subject","$body","$Q1-Q10"))you are trying to send your variables as a fourth argument to the mail function. If you read the manual, you will see that the 4th argument for the mail function is for additional headers. also, i don't know what this whole "$Q1-Q10" business is... I hope that's not some attempt to have it automatically echo all of those variables out. Unless that's some kind of shortcut I don't know about? Doesn't seem to work for me...try this: if (mail("$to","$from","$subject","$body $Q1,$Q2,$Q3,$Q4,$Q5,$Q6,$Q7,$Q8,$Q9,$Q10"))you might wanna look into using an array for your questions though... it might just make things a bit easier for you...just FYI... Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-108725 Share on other sites More sharing options...
timothyltaylor Posted October 25, 2006 Author Share Posted October 25, 2006 Thanks for the last response...I've changed the code to a much simpler, much easier way for me to understand. I just keep getting stuck on two more things:1) I keep receiving this error in the code, although the form still sends. [i]Warning: Cannot modify header information - headers already sent by (output started at /home/tltaylor/estateplanningschools-www/sendmail.php:2) in /home/tltaylor/estateplanningschools-www/sendmail.php on line 46[/i]2) Also, how do I format text within the php script (say, when I receive the email of the user input information, can I make some titles [b]BOLD[/b] when it comes to me in an email?Here's the new code:<title>sendmail.php</title><? $email = $_REQUEST['email'] ; $name = $_REQUEST['name'] ; $classdateandtime = $_REQUEST['classdateandtime'] ; $instructors = $_REQUEST['instructors'] ; $address = $_REQUEST['address'] ; $city = $_REQUEST['city'] ; $state = $_REQUEST['state'] ; $zip = $_REQUEST['zip'] ; $phone = $_REQUEST['phone'] ; $Q1 = $_REQUEST['Q1'] ; $Q2 = $_REQUEST['Q2'] ; $Q3 = $_REQUEST['Q3'] ; $Q4 = $_REQUEST['Q4'] ; $Q5 = $_REQUEST['Q5'] ; $Q6 = $_REQUEST['Q6'] ; $Q7 = $_REQUEST['Q7'] ; $Q8 = $_REQUEST['Q8'] ; $Q9 = $_REQUEST['Q9'] ; $comments = $_REQUEST['comments'] ; mail( "myemail@mymail.com", "EPSA CAP2 Evaluation Results", "From: $email Name: $name Class Date and Time: $classdateandtime Instructors: $instructors Address: $address City: $city State: $state Zip: $zip Phone Number: $phone This learning Experience was: $Q1 Were the stated learning objectives met?: $Q2 If applicable, were prerequisites appropriate?: $Q3 Were program materials both accurate and effective?: $Q4 Did program materials contribute to the achievement of the learning Objectives?: $Q5 Was the time allotted to the learning experience appropriate?: $Q6 Were the facilities and/or the technological equipment appropriate?: $Q7 Were the handouts and advanced preparation materials satisfactory?: $Q8 Was the classroom facilitator's knowledge and experience satisfactory for the course material?: $Q9 Comments: $comments" ); header( "Location: http://www.estateplanningschools.com/thankyou.html" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-114003 Share on other sites More sharing options...
.josh Posted October 25, 2006 Share Posted October 25, 2006 the cannot modify headers problem is because you have html output before your header function at the bottom of the script. I see this:<title>sendmail.php</title>at the top of your script. that's html output. get rid of it. you can't have any html output before a header function call. not even a space before your <? tag. as far as making text bold in your email, you would do it just like normal html. however the user's email program may or may not be set to allow html code, so it might not show up for them, just FYI. Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-114009 Share on other sites More sharing options...
timothyltaylor Posted October 26, 2006 Author Share Posted October 26, 2006 Thanks for the help! Though I didn't think html could work within the <? and ?> of the php code?I tried it and the email came back with the <bold> </bold> tags inside the text of the email.Hmm...Thanks you anyhow... Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-115076 Share on other sites More sharing options...
.josh Posted October 26, 2006 Share Posted October 26, 2006 well for one thing, it's <b > .. </b > (no spaces) not <bold>...</bold> Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-115085 Share on other sites More sharing options...
timothyltaylor Posted October 28, 2006 Author Share Posted October 28, 2006 This isn't able to work for me yet. Am I placing it in the wrong part of the code?This is the part I'm talking about... <strong>Name:</strong>...thanks[code]<? $email = $_REQUEST['email'] ; $name = $_REQUEST['name'] ; $classdateandtime = $_REQUEST['classdateandtime'] ; $instructors = $_REQUEST['instructors'] ; $address = $_REQUEST['address'] ; $city = $_REQUEST['city'] ; $state = $_REQUEST['state'] ; $zip = $_REQUEST['zip'] ; $phone = $_REQUEST['phone'] ; $Q1 = $_REQUEST['Q1'] ; $Q2 = $_REQUEST['Q2'] ; $Q3 = $_REQUEST['Q3'] ; $Q4 = $_REQUEST['Q4'] ; $Q5 = $_REQUEST['Q5'] ; $Q6 = $_REQUEST['Q6'] ; $Q7 = $_REQUEST['Q7'] ; $Q8 = $_REQUEST['Q8'] ; $Q9 = $_REQUEST['Q9'] ; $comments = $_REQUEST['comments'] ; mail( "myname@myname.com", "EPSA CAP2 Evaluation Results", "From: $email <strong>Name:</strong> $name Class Date and Time: $classdateandtime Instructors: $instructors Address: $address City: $city State: $state Zip: $zip Phone Number: $phone This learning Experience was: $Q1 Were the stated learning objectives met?: $Q2 If applicable, were prerequisites appropriate?: $Q3 Were program materials both accurate and effective?: $Q4 Did program materials contribute to the achievement of the learning Objectives?: $Q5 Was the time allotted to the learning experience appropriate?: $Q6 Were the facilities and/or the technological equipment appropriate?: $Q7 Were the handouts and advanced preparation materials satisfactory?: $Q8 Was the classroom facilitator's knowledge and experience satisfactory for the course material?: $Q9 Comments: $comments" ); header( "Location: http://www.estateplanningschools.com/thankyou.html" ); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-115684 Share on other sites More sharing options...
.josh Posted October 28, 2006 Share Posted October 28, 2006 here try this. [code]<?php $email = $_REQUEST['email'] ; $name = $_REQUEST['name'] ; $classdateandtime = $_REQUEST['classdateandtime'] ; $instructors = $_REQUEST['instructors'] ; $address = $_REQUEST['address'] ; $city = $_REQUEST['city'] ; $state = $_REQUEST['state'] ; $zip = $_REQUEST['zip'] ; $phone = $_REQUEST['phone'] ; $Q1 = $_REQUEST['Q1'] ; $Q2 = $_REQUEST['Q2'] ; $Q3 = $_REQUEST['Q3'] ; $Q4 = $_REQUEST['Q4'] ; $Q5 = $_REQUEST['Q5'] ; $Q6 = $_REQUEST['Q6'] ; $Q7 = $_REQUEST['Q7'] ; $Q8 = $_REQUEST['Q8'] ; $Q9 = $_REQUEST['Q9'] ; $comments = $_REQUEST['comments'] ; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $message = "From: $email <strong>Name:</strong> $name Class Date and Time: $classdateandtime Instructors: $instructors Address: $address City: $city State: $state Zip: $zip Phone Number: $phone This learning Experience was: $Q1 Were the stated learning objectives met?: $Q2 If applicable, were prerequisites appropriate?: $Q3 Were program materials both accurate and effective?: $Q4 Did program materials contribute to the achievement of the learning Objectives?: $Q5 Was the time allotted to the learning experience appropriate?: $Q6 Were the facilities and/or the technological equipment appropriate?: $Q7 Were the handouts and advanced preparation materials satisfactory?: $Q8 Was the classroom facilitator's knowledge and experience satisfactory for the course material?: $Q9 Comments: $comments"; mail( "myname@myname.com", "EPSA CAP2 Evaluation Results", $message, $headers); header( "Location: http://www.estateplanningschools.com/thankyou.html" ); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-115720 Share on other sites More sharing options...
timothyltaylor Posted November 17, 2006 Author Share Posted November 17, 2006 Hmm, I've tried that and am having trouble with that form.I need to figure out three things that aren't happening at the moment:1) check to see if each form has been filled out2) send the results to my email lee@thesudanhouse.comHere's the code:[code]<?phpif (isset($_POST["submit"])) { // Check for empty fields if ($_POST["email"] == "") { die("Please fill out all fields"); } if ($_POST["name"] == "") { die("Please fill out all fields"); } // And so on for each required field ... $to = "lee@estateplanningschools.com"; $email = $_POST['email'] ; $subject = "EPSA CAP2 Evaluation Results"; $name = $_POST['name'] ; $classdateandtime = $_POST['classdateandtime'] ; $instructors = $_POST['instructors'] ; $address = $_POST['address'] ; $city = $_POST['city'] ; $state = $_POST['state'] ; $zip = $_POST['zip'] ; $phone = $_POST['phone'] ; $Q1 = $_POST['Q1'] ; $Q2 = $_POST['Q2'] ; $Q3 = $_POST['Q3'] ; $Q4 = $_POST['Q4'] ; $Q5 = $_POST['Q5'] ; $Q6 = $_POST['Q6'] ; $Q7 = $_POST['Q7'] ; $Q8 = $_POST['Q8'] ; $Q9 = $_POST['Q9'] ; $comments = $_POST['comments'] ; $message = "From: $email <strong>Name:</strong> $name Class Date and Time: $classdateandtime Instructors: $instructors Address: $address City: $city State: $state Zip: $zip Phone Number: $phone This learning Experience was: $Q1 Were the stated learning objectives met?: $Q2 If applicable, were prerequisites appropriate?: $Q3 Were program materials both accurate and effective?: $Q4 Did program materials contribute to the achievement of the learning Objectives?: $Q5 Was the time allotted to the learning experience appropriate?: $Q6 Were the facilities and/or the technological equipment appropriate?: $Q7 Were the handouts and advanced preparation materials satisfactory?: $Q8 Was the classroom facilitator's knowledge and experience satisfactory for the course material?: $Q9 Comments: $comments"; if (!mail($to, $subject, $message, $headers)) { $error = "<p class=\"error\">Couldn't send message!</p>\n"; }}echo isset($error) ? $error : ''; header( "Location: http://www.estateplanningschools.com/thankyou.html" ); ?>[/code]3) I am desiring to use this code to output the information into a .pdf file that is self-written by the script. Does that make sense? And from your experience, is it possible to accomplish?I've been looking at pdfLIB and feel that it is...Maybe you've got some experience with where to start? Thanks again... Quote Link to comment https://forums.phpfreaks.com/topic/23923-form-script-helpso-appreciated/#findComment-126340 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.