Re: why isn't php being parsed?
| From: | lferro@teladigital.net | Date: | Tue, 01 Feb 2005 20:02:40 +0000 |
| Subject: | Re: why isn't php being parsed? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25507@lists.php.net to get a copy of this message | ||
First of all, sorry to everyone... i forgot to remove the "return receipt" from my last mail... *blush*
The header info you get is because there was output prior to the "headers" manipulation (be it a session, cookie or anything else that uses the headers).
The resolution is fairly simple... change the php block to the top of the page...
The culprit is the line:
header ("Location:$thankyouURL");
Another thing that is worth something... if your smtp server works ok (some don't work 100%), the mail function returns a true value when the mail is sent correctly and a false when it can't send the mail...
You can redirect to diferent pages acording to it and in case of failure, ask for another kind of contact...
Cheers,
Luis Ferro
Patrick Roane wrote:
Thanks for the quick response. I tried your suggestion and I do get an e-mail sent from the form when I test it. The problem is, I only receive the date the form was filled out minus any of the values. I also get the error msg: Warning: Cannot add header information - headers already sent by ... I looked this up and added: <?php ob_start(); // file content ob_end_flush(); ?> to my script, but I still get the error. --- "lferro@teladigital.net" <lferro@teladigital.net> wrote:Hi there, First, prolly, your file needs to be called chair1.php instead of chair.html... Second, you should add something in the lines of: if (isset($_POST["submit"])) { .... email sending code here... } If not, the users, when they reach the page will send an empty form to the email... Cheers, Luis Ferro Patrick Roane wrote:===== ---------------- "forget your lust for the rich man's gold. All that you need, is in your soul. You can do this if you try. All that I want for you my son, is to be satisfied" ~ Lynard SkynardI am trying to include form-parsing code on thesamepage as my hard-coded HTML form- but I'm doing something wrong. The name of my file is chair1.html Please see below: thanks! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict/EN""http://www/w3/org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> <title>form</title> <link rel="stylesheet" type="text/css"media="screen"href="center.css"> <style type="text/css"> </style> </head> <body bgcolor="#999900"> <table border="0" cellpadding="5" width="100%" bgcolor="#999900" class="rightsidebar"><tr> <td> </td> <td align="center"><div id="whitetitle">Item Ch1-1</div></td> <td>  </td> <body bgcolor="#999900"> <table border="0" cellpadding="0" width="100%" align="left" bgcolor="#999900"class="rightsidebar"><tr><td>   </td><td> </td> <td><img src="chair_pics/rt_chair.jpg" alt="" height="304" width="160" border="0" align="right"></td> <td> </td> <td align="left"><ul>want<li>» Arm Chair</li> <li>» Beach wood</li> <li>» Height: 42"</li> <li>» Seat: 19"w x 18 1/2d</li><td> </td> <td> </td> <td> </td> </ul> </td> </tr> </table> <table border="0" cellpadding="0" width="100%" align="left" bgcolor="#999900"><tr><td> <?php $to = "fojomo@yahoo.com"; //Change to the email you want the form results to be sent to $subject = "Form Results"; //Change to what youthe title of the email to be $headers = "From: Form Mailer"; $thankyouURL ="http://www.crost.com/test/index.html";//Change to the url you want the form to go toaftersubmit $date = date ("l, F jS, Y"); $time = date ("h:i A"); $msg = "Submitted on $date at $time.\n\n"; if ($_SERVER['REQUEST_METHOD'] == "POST") { foreach ($_POST as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } } else { foreach ($_GET as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } } mail($to, $subject, $msg, $headers); header ("Location:$thankyouURL"); ?> <fieldset><legend align="center">Questions & Comments</legend><br> <form method="post" action="{' .$_SERVER['PHP_SELF']. '}"> <input type="checkbox" name="Ch1-1[]" value="Ch1-1" />I'd like to purchase Item Ch1-1: <input type="checkbox" name="similar_1[]" value="similar_1" />Do you have something similar? <input type="checkbox" name="browse_1[]" value="browse_1" />Just browsing: <p>Name:<br /> <input type="text" name="user" /></p> <p>Phone:<br /> <input type="text" name="phone" /></p><br /> Comments:<br /> <textarea name="Comments" rows="5" cols="40"></textarea></fieldset> <p><input type="submit" value="submit data" /></p> </form> </tr> </td> </table> </body> </html> ===== ---------------- "forget your lust for the rich man's gold. All thatyou need, is in your soul. You can do this if you try. All that I want for you my son, is to be satisfied"~ Lynard Skynard-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php