putting a html form into php if statements.

smoochy boys on tour

Far

tsniffer
Staff member
Developer
May 19, 2003
20,183
30
2,785
540
hi ther!

iv currently got a html form which holds 2 text boxes, and 3 buttons.

i want to put that form inside a php if statement which would do..

if(logged in)
{
display form A
}
else
{
display form B
}

its basically to change a login form from being able to login, to viewing your control panel.

if got a simple login system working on my page, but cant get this working.

keep getting syntax error: unexpected "<" on line 906.


HELP?!

ps: i dont know if im doing this a stupid way. if i am, how do i do it propperly?
 
Last edited:

Sawell

Golden Oldie
Golden Oldie
Dec 29, 2003
1,079
17
195
An educated guess would be (on the assumption that "<" is probably html code), you're trying to parse HTML within PHP without telling your script that you're going back to using HTML.

You can't just stick HTML into a PHP script unfortunately, you have to either declare it or move the PHP around it.

I.e. either put echo statements before your HTML, or end off the code (?>) put in your html, start the code again (<?php).

So...
Code:
else
{
<html form></html form>
}

Won't work. You either need to do:

Code:
else
{
echo '<html code></html code>';
}

Or

Code:
else
{
?>
<html code>
<?php
}

Hope that makes sense, let me know if you need any further help.
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,183
30
2,785
540
thanks yeah it did. i did the second one, and working perfec now :)