Re: php form action breaks script

From: Date: Fri, 15 Jun 2012 12:29:22 +0000
Subject: Re: php form action breaks script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-318246@lists.php.net to get a copy of this message
On 6/14/2012 7:28 PM, 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 heredoc is best for this
if ($output_form){ $report = <<<sty <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> sty; }

« previous php.general (#318246) next »