Re: Re: php form action breaks script

From: Date: Fri, 15 Jun 2012 01:35:27 +0000
Subject: Re: Re: php form action breaks script
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-318244@lists.php.net to get a copy of this message
On Thu, Jun 14, 2012 at 10:17 PM, David Robley <robleyd@aapt.net.au> wrote: > Tim Dunphy wrote: > >> Hello list, >> >>  I was just wondering if I could get some opinions on a snippet of >> code which breaks a php web page. >> >>  First the working code which is basically an html form being echoed by >>  php: >> >> if ($output_form) { >> >>   echo '<br /><br /><form action="sendemail.php>" >> method="post"  > <form action="sendemail.php>" should be: <form action="sendemail.php" ... >>   <label for="subject">Subject of email:</label><br /> >>   <input id="subject" name="subject" type="text" >> size="30" /><br /> >>   <label for="elvismail">Body of email:</label><br /> >>    <textarea id="elvismail" name="elvismail" rows="8" >> cols="40"></textarea><br /> >>    <input type="submit" name="Submit" value="Submit" >> /> >>   </form>'; >> >> >>   } >> >> However if I change the form action to this, it breaks the page >> resulting in a white screen of death: >> >> >>   if ($output_form) { >> >>   echo '<br /><br /><form action="<?php echo >> $_SERVER['PHP_SELF']; ?>" >> method="post"  > >>   <label for="subject">Subject of email:</label><br /> >>   <input id="subject" name="subject" type="text" >> size="30" /><br /> >>   <label for="elvismail">Body of email:</label><br /> >>    <textarea id="elvismail" name="elvismail" rows="8" >> cols="40"></textarea><br /> >>    <input type="submit" name="Submit" value="Submit" >> /> >>   </form>'; >> >> >>   } >> >> Reverting the one line to this: >> >> echo '<br /><br /><form action="sendemail.php" >> method="post"  > >> >> gets it working again. Now I don't know if it's an unbalanced quote >> mark or what's going on. But I'd appreciate any advice you may have. >> >> >> Best, >> tim >> > If you check your apache log you'll probably see an error message. But the > problem seems to be that your string you are trying to echo is enclosed in > single quotes, and contains a string in <?php tags. Try something like > > echo '<br /><br /><form action="' . > $_SERVER['PHP_SELF'] . '" > method="post"> ...etc > > > > Cheers > -- > David Robley > > "I haven't had any tooth decay yet," said Tom precariously. > Today is Sweetmorn, the 20th day of Confusion in the YOLD 3178. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Paul Halliday http://www.squertproject.org/

« previous php.general (#318244) next »