php form action breaks script
| From: | Tim Dunphy | Date: | Thu, 14 Jun 2012 23:28:19 +0000 |
| Subject: | php form action breaks script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-318242@lists.php.net to get a copy of this message | ||
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
--
GPG me!!
gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B