submit button inside PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zeroanarchy
Forum Newbie
Posts: 15
Joined: Wed Jul 21, 2004 8:51 pm

submit button inside PHP

Post 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
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

I think you don't have to put the "echo". Just simply type the code without echo.
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

hey

Post 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 ;)
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

or

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


:wink:
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
";
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post 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.. ;)
zeroanarchy
Forum Newbie
Posts: 15
Joined: Wed Jul 21, 2004 8:51 pm

Post by zeroanarchy »

Thanks all for your help, something I should have remembered from my VB coding days. :oops:

Cheers
zeroanarchy
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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... ;)
Post Reply