Page 1 of 1

submit button inside PHP

Posted: Tue Aug 03, 2004 12:51 am
by zeroanarchy
Ok well have been looking at code on here for a bit and cannot seem to find an example of

Code: Select all

<form action ="sent.php">
<input type="submit" value="Send Letter">
being used inside of PHP. I have an if statement and if the statement is true I want it to add the above button to the page if not don't display it.

I tried

Code: Select all

echo "<form action ="sent.php">";
echo "<input type="submit" value="Send Letter">";
but just kept getting errors, any ideas?

Thanks in advance.
zeroanarchy

Posted: Tue Aug 03, 2004 1:07 am
by g3ckO
I think you don't have to put the "echo". Just simply type the code without echo.

hey

Posted: Tue Aug 03, 2004 1:12 am
by fresh
you can echo it too, but make sure you dont use double quotes inside of double quotes..

ex.

echo "<input type='submit' name='sub' value='Submit'>";

hope that helps ;)

Posted: Tue Aug 03, 2004 4:26 am
by Revan
or

echo "<form action =\"sent.php\">
<input type="submit" value=\"Send Letter\">"
echo "<input type="\submit\" value=\"Send Letter\"> "


:wink:

Posted: Tue Aug 03, 2004 5:16 am
by kettle_drum
Pretty sure you need to use double quotes to be w3 complient as well. But theres no need to use two echo's, just have it all in one:

Code: Select all

echo "
this

and this

and maybe something here too.
";

Posted: Tue Aug 03, 2004 5:59 am
by fresh
yeah, but not inside another double quote, because you will neutral out the main dbl quotes, BTW... I usually echo the whole thing too, if needed of course, which in this case is not.. ;)

Posted: Tue Aug 03, 2004 8:24 am
by zeroanarchy
Thanks all for your help, something I should have remembered from my VB coding days. :oops:

Cheers
zeroanarchy

Posted: Tue Aug 03, 2004 8:38 am
by JAM
Revan wrote: <input type="submit" value="Send Letter">"
(You forgot the \ & ; at the "submit" btw)

Another approach...

Code: Select all

echo '
    <form action="sent.php">
    <input type="submit" value="Send Letter">
';
echo '<input type="submit" value="Send Letter">';
...using single quotes around strings or the Heredoc syntax...

The ongoing discussion about what's best... ;)