drax Posted January 29, 2008 Share Posted January 29, 2008 Hi all I'm completely new to php and keep hitting problems that are driving me mad. Could someone be kind enough to look at my code and tell me what stupid mistake I am making? <?php $step=isset($_POST['step'])?$_POST['step']:1; if($step==1) { ?> <FORM METHOD="POST"><H2>Step 1</H2><BR> <INPUT TYPE="HIDDEN" NAME="step" value="2"> <INPUT TYPE="TEXT" Name="username" value="Dave Smith"> <INPUT TYPE="SUBMIT"> </FORM> <? elseif($step==2) { $username=$_POST['username']; ?> <FORM METHOD="POST"><H2>Step 2</H2><BR> <INPUT TYPE="HIDDEN" NAME="step" value="3"> <INPUT TYPE="HIDDEN" NAME="username" value="<?=$username;?>"> <INPUT TYPE="TEXT" Name="email" value="Dave@Smith.com"> <INPUT TYPE="SUBMIT"> </FORM> <? } else { <H2>Step 3</H2><BR> Username: <?=$_POST['username'];?> <BR> Email: <?=$_POST['email'];?><BR> } ?> I get the error "Parse error: syntax error, unexpected T_ELSEIF on line 22" I'm guessing it's a syntax error but have reached the point where I can't see the wood for the trees! any help would be great Cheers Quote Link to comment https://forums.phpfreaks.com/topic/88387-solved-parse-error-syntax-error-unexpected-t_elseif/ Share on other sites More sharing options...
trq Posted January 29, 2008 Share Posted January 29, 2008 <?php $step=isset($_POST['step'])?$_POST['step']:1; if ($step==1) { ?> <FORM METHOD="POST"><H2>Step 1</H2><BR> <INPUT TYPE="HIDDEN" NAME="step" value="2"> <INPUT TYPE="TEXT" Name="username" value="Dave Smith"> <INPUT TYPE="SUBMIT"> </FORM> <?php } elseif($step==2) { $username = $_POST['username']; ?> <FORM METHOD="POST"><H2>Step 2</H2><BR> <INPUT TYPE="HIDDEN" NAME="step" value="3"> <INPUT TYPE="HIDDEN" NAME="username" value="<?=$username;?>"> <INPUT TYPE="TEXT" Name="email" value="Dave@Smith.com"> <INPUT TYPE="SUBMIT"> </FORM> <?php } else { <H2>Step 3</H2><BR> Username: <?=$_POST['username'];?> <BR> Email: <?=$_POST['email'];?><BR> } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88387-solved-parse-error-syntax-error-unexpected-t_elseif/#findComment-452347 Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 This is all in php else { <H2>Step 3</H2><BR> Username: <?=$_POST['username'];?> <BR> Email: <?=$_POST['email'];?><BR> } ?> so change to else { ?> <H2>Step 3</H2><BR> Username: <?=$_POST['username'];?> <BR> Email: <?=$_POST['email'];?><BR> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88387-solved-parse-error-syntax-error-unexpected-t_elseif/#findComment-452351 Share on other sites More sharing options...
drax Posted January 29, 2008 Author Share Posted January 29, 2008 Thanks for the replies, they were scary fast! Thorpe - I tried your and got "Parse error: syntax error, unexpected '<' on line 32" - prob just highlighting another mistake I made. Revraz - yours seemed to fix it Thank you both so much for your help. Time to crack on and no doubt hit more walls - I'll be back! Cheers Quote Link to comment https://forums.phpfreaks.com/topic/88387-solved-parse-error-syntax-error-unexpected-t_elseif/#findComment-452359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.