Re: php form action breaks script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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"  >
>   <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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux