Iced Earth Posted March 31, 2010 Share Posted March 31, 2010 Hey all, I'm the definition of a PHP noob...I know my way around xhtml/css just fine and can design, but have only studied a little PHP code I've seen. Onto my problem: I'm doing a website for a friend who has a piano moving company. He wanted a 'contact' form on his rates page, so people could fill out some fields and get a custom quote. I'm using this php script as a template: http://www.phpeasystep.com/phptu/8.html -- really really basic. I've subbed out the current form fields for what I want, that was easy enough. But I have a few things I'd like to change/fix: 1) When you receive the information, its all on one line, and without what field it came from which can be confusing. $detail is an original ID, but I've added name, phone, make, size, along with a couple others. They aren't listed here. :-x // Contact subject $subject ="Customer Quote Form"; // Details $message="$detail"; 2) When the form is submitted, I'd like it to link to a new page i create, instead of displaying a simple message. How would I do this? I think that's it...any help is appreciated...thanks! Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/ Share on other sites More sharing options...
beingalex Posted March 31, 2010 Share Posted March 31, 2010 First of all: Have you actually got this script working ? ie. Do you get a message saying "We've recieved your contact information" ? Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034974 Share on other sites More sharing options...
ialsoagree Posted March 31, 2010 Share Posted March 31, 2010 It would be really helpful to see the HTML of the form, and the PHP that handles building and mailing the e-mail. To make it easier to help you, it's best if you only include these two pieces of code. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034975 Share on other sites More sharing options...
Iced Earth Posted March 31, 2010 Author Share Posted March 31, 2010 Sorry, yes, its works. I uploaded it to my webspace and had it email my own account. I tested it with the default fields (name/email/detail) though. edit: I'll post all the code as well. Sorry :-x Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034976 Share on other sites More sharing options...
Iced Earth Posted March 31, 2010 Author Share Posted March 31, 2010 HTML Page code: <h3>Want a free quote? Take a moment to fill out our form!</h3> <table width="650" border="0" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr> <td style="width:200px">Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"/></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"/></td> </tr> <tr> <td>Phone Number</td> <td>:</td> <td><input name="phone" type="text" id="phone" size="50"/></td> </tr> <tr> <td>Make & Model of Piano</td> <td>:</td> <td><input name="make" type="text" id="make" size="50"/></td> </tr> <tr> <td>Size of Piano (measured)</td> <td>:</td> <td><input name="size" type="text" id="size" size="50"/></td> </tr> <tr> <td>Number of stairs</td> <td>:</td> <td><input name="stairs" type="text" id="stairs" size="50"/></td> </tr> <tr> <td>Mileage traveled from A to B</td> <td>:</td> <td><input name="mileage" type="text" id="mileage" size="50"/></td> </tr> <tr> <td>Truck Access (Yes/No)?</td> <td>:</td> <td><input name="access" type="text" id="access" size="50"/></td> </tr> <tr> <td>Any other information we may need to know?</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"/> <input type="reset" name="Submit2" value="Reset"/></td> </tr> </table> </form> </td> </tr> </table> send_contact.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Contact Form</title> </head> <body> <?php // Contact subject $subject ="Customer Quote Form"; // Details $message="$detail"; // Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='<my email here>'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "Thank you for filling out our form! We have received your message and will respond to you soon."; } else { echo "Error: Please email us directly: <customer email here>."; } ?> </body> </html> As you can see my custom fields aren't in the send_contact.php. I wanted to wait until I got the formatting to add it..and to be sure its added right. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034978 Share on other sites More sharing options...
beingalex Posted March 31, 2010 Share Posted March 31, 2010 For simplicity here's what I would do .. In the code where it says: if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } I'd put: if($send_contact){ header('Location: thankyou.php'); } else { echo "ERROR"; } Create a page called "thankyou.php" with all the same markup and css as your other pages and present your message received text in that. the header function given the "Location" will load a page again so if you load "thankyou.php" - that is the page that you'll see when the form has been completed correctly. - Alex Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034981 Share on other sites More sharing options...
Iced Earth Posted March 31, 2010 Author Share Posted March 31, 2010 Awesome, thanks alex. What about having the email display the field names, and their user submitted text? Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034987 Share on other sites More sharing options...
oni-kun Posted March 31, 2010 Share Posted March 31, 2010 Awesome, thanks alex. What about having the email display the field names, and their user submitted text? $message="$detail"; You can put anything you wish in $detail, such as the $_POST elements of their submitted text. But where is $detail even defined? I don't see it, it should be blank or with an error unless you define it. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1034992 Share on other sites More sharing options...
beingalex Posted March 31, 2010 Share Posted March 31, 2010 First of all: did that code I give you work ? Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1035005 Share on other sites More sharing options...
Iced Earth Posted March 31, 2010 Author Share Posted March 31, 2010 $message="$detail"; You can put anything you wish in $detail, such as the $_POST elements of their submitted text. But where is $detail even defined? I don't see it, it should be blank or with an error unless you define it. Ah, it's hiding. It was the last option in the form: <tr> <td>Any other information we may need to know?</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> Again I apologize; I don't even know how to format the results. Normally I would have plenty of time to learn and test test test, but I am under time constraints. If I could have a simple example with one or two lines, I could do the rest myself. First of all: did that code I give you work ? I just uploaded it to test and got this message: Warning: Cannot modify header information - headers already sent by (output started at /home/vpm/public_html/test/send_contact.php:10) in /home/vpm/public_html/test/send_contact.php on line 29 Instead of thankyou.php I used test.php and changed send_contact.php to show that. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1035007 Share on other sites More sharing options...
Lukeidiot Posted April 1, 2010 Share Posted April 1, 2010 Heres a link to my very noob friendly contact form maker. All you do is enter your email, then it generates a phps (re-saveas to .php); then upload. It sends the logs to your email you enter. http://lukeidiot.com/form/make.php Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1035176 Share on other sites More sharing options...
Iced Earth Posted April 1, 2010 Author Share Posted April 1, 2010 Thanks luke...but I really need a client to be able to fill out: Name Phone Email Make & Model of Piano Size of Piano (measured) Mileage traveled Truck access (Yes/No) Any other info we might need Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1035424 Share on other sites More sharing options...
jcbones Posted April 1, 2010 Share Posted April 1, 2010 Try something like this: <?php // Contact subject $subject ="Customer Quote Form"; // Details $name = (isset($_POST['name'])) ? strip_tags(ucwords(strtolower($_POST['name']))) : NULL; // Mail of sender $mail_from= (isset($_POST['customer_mail'])) ? strip_tags($_POST['customer_mail']) : NULL; $info['Customer Phone'] = (isset($_POST['phone'])) ? strip_tags($_POST['phone']) : 'Phone number not listed'; $info['Piano Make and Model'] = (isset($_POST['make'])) ? strip_tags($_POST['make']) : 'Make & Model not listed.'; $info['Piano Size'] = (isset($_POST['size'])) ? strip_tags($_POST['size']) : 'Size not listed.'; $info['Stairs'] = (isset($_POST['stairs'])) ? (int) $_POST['stairs'] : 0; $info['Estimated Mileage'] = (isset($_POST['mileage'])) ? (int) $_POST['mileage'] : 0; $info['Truck Access'] = (isset($_POST['access']) && strtolower($_POST['access']) == 'yes') ? 'Yes' : 'No, or not stated.'; $info['Other Details'] = (isset($_POST['detail'])) ? strip_tags($_POST['detail']) : NULL; $message = 'Customer: ' . $name . PHP_EOL; foreach($info as $key => $value) { $message .= $key . ': ' . $value . PHP_EOL; } // From $header="from: $name <$mail_from>"; // Enter your email address $to ='<my email here>'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ header('Status: 200'); header('Location: thankyou.php'); //This should be a full URI as in 'Location: http://mysite.com/thankyou.php' } else { $comment = "Error: Please email us directly: <customer email here>."; } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Contact Form</title> </head> <body> <?php echo $comment; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1035538 Share on other sites More sharing options...
Iced Earth Posted April 2, 2010 Author Share Posted April 2, 2010 thanks jc...I think thats exactly what i was looking for. When i get home later I'll give this a go and report back with the results. thanks again Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1035576 Share on other sites More sharing options...
Iced Earth Posted April 2, 2010 Author Share Posted April 2, 2010 Success! I did notice that the email info was not submitted in the message, so I just added: $info['Customer Email'] = (isset($_POST['customer_mail'])) ? strip_tags($_POST['customer_mail']) : 'Email not listed.'; However, if you leave the phone number/email fields empty, no message is displayed prompting you for the information. Is there an easy solution to that? I've seen some other free forms online with these, I'll look at those as a reference and see if I can figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1036182 Share on other sites More sharing options...
Iced Earth Posted April 8, 2010 Author Share Posted April 8, 2010 After looking at some other php mailers as examples, its safe to say I don't know how to implement error generators. Q: Could anyone help with adding code that would ask the user to fill in name/email/phone if they forget to? Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1038709 Share on other sites More sharing options...
Iced Earth Posted April 13, 2010 Author Share Posted April 13, 2010 I didn't want to bump this immediately...but am still wondering, could someone help me with the prompts to make sure the user fills in all the form fields? Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1041222 Share on other sites More sharing options...
jcbones Posted April 14, 2010 Share Posted April 14, 2010 The HTML page (now is PHP and should be named with the .php extension) <?php session_start(); $name = null; $customer_mail = null; $customer_phone = null; $piano_make_and_model = null; $piano_size = null; $stairs = null; $estimated_mileage = null; $truck_access = null; $other_details = null; $customer_email = null; if(isset($_SESSION['errors']) && is_array($_SESSION['errors'])) { foreach($_SESSION['errors'] as $error => $desc) { $error = strtolower(str_replace(' ','_',$error)); $$error = '<br />' . $desc; } } ?> <h3>Want a free quote? Take a moment to fill out our form!</h3> <table width="650" border="0" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr> <td style="width:200px">Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"/><?php echo $name; ?></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"/><?php echo $customer_email; ?></td> </tr> <tr> <td>Phone Number</td> <td>:</td> <td><input name="phone" type="text" id="phone" size="50"/><?php echo $customer_phone; ?></td> </tr> <tr> <td>Make & Model of Piano</td> <td>:</td> <td><input name="make" type="text" id="make" size="50"/><?php echo $piano_make_and_model; ?></td> </tr> <tr> <td>Size of Piano (measured)</td> <td>:</td> <td><input name="size" type="text" id="size" size="50"/><?php echo $piano_size; ?></td> </tr> <tr> <td>Number of stairs</td> <td>:</td> <td><input name="stairs" type="text" id="stairs" size="50"/><?php echo $stairs; ?></td> </tr> <tr> <td>Mileage traveled from A to B</td> <td>:</td> <td><input name="mileage" type="text" id="mileage" size="50"/><?php echo $estimated_mileage; ?></td> </tr> <tr> <td>Truck Access (Yes/No)?</td> <td>:</td> <td><input name="access" type="text" id="access" size="50"/><?php echo $truck_access; ?></td> </tr> <tr> <td>Any other information we may need to know?</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea><?php echo $other_details; ?></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"/> <input type="reset" name="Submit2" value="Reset"/></td> </tr> </table> </form> </td> </tr> </table> processing script. Put your complete URI to the page above in the header function on line 33. <?php session_start(); // Contact subject $subject ="Customer Quote Form"; // Details $name = (isset($_POST['name'])) ? strip_tags(ucwords(strtolower($_POST['name']))) : NULL; // Mail of sender $mail_from= (isset($_POST['customer_mail'])) ? strip_tags($_POST['customer_mail']) : NULL; $info['Name'] = $name; $info['Customer Phone'] = (isset($_POST['phone'])) ? strip_tags($_POST['phone']) : NULL; $info['Piano Make and Model'] = (isset($_POST['make'])) ? strip_tags($_POST['make']) : NULL; $info['Piano Size'] = (isset($_POST['size'])) ? strip_tags($_POST['size']) : NULL; $info['Stairs'] = (isset($_POST['stairs'])) ? (int) $_POST['stairs'] : NULL; $info['Estimated Mileage'] = (isset($_POST['mileage'])) ? (int) $_POST['mileage'] : NULL; $info['Truck Access'] = (isset($_POST['access']) && strtolower($_POST['access']) == 'yes') ? 'Yes' : 'No, or not stated.'; $info['Other Details'] = (isset($_POST['detail'])) ? strip_tags($_POST['detail']) : NULL; $info['Customer Email'] = (isset($_POST['customer_mail'])) ? strip_tags($_POST['customer_mail']) : NULL; $message = NULL; foreach($info as $key => $value) { if($value == NULL) { $error[$key] = 'You have left ' . $key . ' blank.'; } $message .= $key . ': ' . $value . PHP_EOL; } if(is_array($error) && isset($error)) { $_SESSION['errors'] = $error; header('Status: 200'); header('Location: http://www.mysite/myform.php'); } // From $header="from: $name <$mail_from>"; // Enter your email address $to ='<my email here>'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ header('Status: 200'); header('Location: thankyou.php'); //This should be a full URI as in 'Location: http://mysite.com/thankyou.php' } else { $comment = "Error: Please email us directly: <customer email here>."; } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Contact Form</title> </head> <body> <?php echo $comment; ?> </body> </html> Of course, you will want to style the error messages for display. Currently this puts them below the inputs the error resides in. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1042005 Share on other sites More sharing options...
Iced Earth Posted April 20, 2010 Author Share Posted April 20, 2010 Hey JC, thanks for the reply. My post got buried and I only saw it yesterday. I tried what you said, but when I uploaded the files to my web space I got this error: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/vpm/public_html/test/rates.php:7) in /home/vpm/public_html/test/rates.php on line 61 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/vpm/public_html/test/rates.php:7) in /home/vpm/public_html/test/rates.php on line 61 Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1045365 Share on other sites More sharing options...
jcbones Posted April 20, 2010 Share Posted April 20, 2010 You must be including these files into other files. Move: session_start(); To the very top of the parent file. On both files. Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1045445 Share on other sites More sharing options...
Iced Earth Posted April 20, 2010 Author Share Posted April 20, 2010 You must be including these files into other files. Move: session_start(); To the very top of the parent file. On both files. Sorry, I'm confused. It's at the top of my send_contact.php file, in the PHP tags, and at the beginning of the PHP script in my single webpage (saved as .php), with the PHP tags right before it. Should it be somewhere else? Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1045494 Share on other sites More sharing options...
jcbones Posted April 22, 2010 Share Posted April 22, 2010 session_start() has to be at the very top of the page, and before any echo's or regular HTML. So if your page starts with: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> Then the session start should be moved before it. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1046684 Share on other sites More sharing options...
Iced Earth Posted April 22, 2010 Author Share Posted April 22, 2010 D'oh. Like I said, I am a super noob. I'll do that and report back with results. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1046696 Share on other sites More sharing options...
Iced Earth Posted April 22, 2010 Author Share Posted April 22, 2010 OK, interesting. I entered only my name in the form, and clicked 'Submit'. It redirected me to the "thank you" page I made. I hit my browser's back button though, and saw the error messages under each field I didn't enter information in. Again just for reference here is my rates.php page (with the form): <?php session_start(); $name = null; $customer_mail = null; $customer_phone = null; $piano_make_and_model = null; $piano_size = null; $stairs = null; $estimated_mileage = null; $truck_access = null; $other_details = null; $customer_email = null; if(isset($_SESSION['errors']) && is_array($_SESSION['errors'])) { foreach($_SESSION['errors'] as $error => $desc) { $error = strtolower(str_replace(' ','_',$error)); $$error = '<br />' . $desc; } } ?> <h3>Want a free quote? Take a moment to fill out our form!</h3> <table width="650" border="0" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr> <td style="width:200px">Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"/><?php echo $name; ?></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"/><?php echo $customer_email; ?></td> </tr> <tr> <td>Phone Number</td> <td>:</td> <td><input name="phone" type="text" id="phone" size="50"/><?php echo $customer_phone; ?></td> </tr> <tr> <td>Make & Model of Piano</td> <td>:</td> <td><input name="make" type="text" id="make" size="50"/><?php echo $piano_make_and_model; ?></td> </tr> <tr> <td>Size of Piano (measured)</td> <td>:</td> <td><input name="size" type="text" id="size" size="50"/><?php echo $piano_size; ?></td> </tr> <tr> <td>Number of stairs</td> <td>:</td> <td><input name="stairs" type="text" id="stairs" size="50"/><?php echo $stairs; ?></td> </tr> <tr> <td>Mileage traveled from A to B</td> <td>:</td> <td><input name="mileage" type="text" id="mileage" size="50"/><?php echo $estimated_mileage; ?></td> </tr> <tr> <td>Truck Access (Yes/No)?</td> <td>:</td> <td><input name="access" type="text" id="access" size="50"/><?php echo $truck_access; ?></td> </tr> <tr> <td>Any other information we may need to know?</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea><?php echo $other_details; ?></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"/> <input type="reset" name="Submit2" value="Reset"/></td> </tr> </table> </form> </td> </tr> </table> ...and send_contact.php: <?php session_start(); // Contact subject $subject ="Customer Quote Form"; // Details $name = (isset($_POST['name'])) ? strip_tags(ucwords(strtolower($_POST['name']))) : NULL; // Mail of sender $mail_from= (isset($_POST['customer_mail'])) ? strip_tags($_POST['customer_mail']) : NULL; $info['Name'] = $name; $info['Customer Phone'] = (isset($_POST['phone'])) ? strip_tags($_POST['phone']) : NULL; $info['Piano Make and Model'] = (isset($_POST['make'])) ? strip_tags($_POST['make']) : NULL; $info['Piano Size'] = (isset($_POST['size'])) ? strip_tags($_POST['size']) : NULL; $info['Stairs'] = (isset($_POST['stairs'])) ? (int) $_POST['stairs'] : NULL; $info['Estimated Mileage'] = (isset($_POST['mileage'])) ? (int) $_POST['mileage'] : NULL; $info['Truck Access'] = (isset($_POST['access']) && strtolower($_POST['access']) == 'yes') ? 'Yes' : 'No, or not stated.'; $info['Other Details'] = (isset($_POST['detail'])) ? strip_tags($_POST['detail']) : NULL; $info['Customer Email'] = (isset($_POST['customer_mail'])) ? strip_tags($_POST['customer_mail']) : NULL; $message = NULL; foreach($info as $key => $value) { if($value == NULL) { $error[$key] = 'You have left ' . $key . ' blank.'; } $message .= $key . ': ' . $value . PHP_EOL; } if(is_array($error) && isset($error)) { $_SESSION['errors'] = $error; header('Status: 200'); header('Location: http://www.customer-url-here.com/test/rates.php'); } // From $header="from: $name <$mail_from>"; // Enter your email address $to ='myemailhere@fortesting.com'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ header('Status: 200'); header('Location: http://www.customer-url-here.com/test/thank_you.html'); //This should be a full URI as in 'Location: http://mysite.com/thankyou.php' } else { $comment = "Error: Please email us directly: <customer email here>."; } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" > <title>Contact Form</title> </head> <body> <?php echo $comment; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1046704 Share on other sites More sharing options...
jcbones Posted April 22, 2010 Share Posted April 22, 2010 That doesn't make sense That means the $_SESSION['errors'] is being set, so the only thing that can be failing is the re-directing header. After header('Location: http://www.customer-url-here.com/test/rates.php'); add: die('You should have been redirected!'); Quote Link to comment https://forums.phpfreaks.com/topic/197175-super-php-noob-help-with-form-mailer/#findComment-1046725 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.