...

View Full Version : if statement for login display



pinch
08-30-2006, 09:35 AM
hi all,

am trying to get a login section to only display if the user have not logged in yet, and disappears if they are.



<?php if(!(isset($_SESSION['MM_Username'])) { $loging_box = "<td bgcolor='#000000'><form id='form1' name='form1' method='POST' action='<?php echo $loginFormAction; ?>'>";
$loging_box .= "<span class='style114'>Membership Number<input type='text' name='textfield' /><br />Password</span><input type='text' name='textfield2' />";
$loging_box .= "<br /><input type='submit' name='Submit' value='Login' /></form></td>";
echo $loging_box;}
?>


am getting a parse error, on the first line, please help

Webmonkey
08-30-2006, 09:56 AM
Please could you post the error you are getting?

kehers
08-30-2006, 09:57 AM
Try this:


<?php
if(!isset($_SESSION['MM_Username'])){
//bracket use round ur isset wrong
$loging_box = "<td bgcolor='#000000'><form id='form1' name='form1' method='POST' action='$loginFormAction'>";
/*this wrong - <?php echo $loginFormAction;?> too*/
$loging_box .= "<span class='style114'>Membership Number<input type='text' name='textfield' /><br />Password</span><input type='text' name='textfield2' />";
$loging_box .= "<br /><input type='submit' name='Submit' value='Login' /></form></td>";
echo $loging_box;
}
?>

That should fix it.

pinch
08-30-2006, 10:00 AM
This is the error code

PHP Parse error: parse error, unexpected '{' in c:\...\XXX.php on line 1

pinch
08-30-2006, 10:00 AM
This is the error code

PHP Parse error: parse error, unexpected '{' in c:\...\XXX.php on line 1

Webmonkey
08-30-2006, 10:04 AM
its becuase

<?php if(!(isset($_SESSION['MM_Username']))

Should be. . .


<?php if(!isset($_SESSION['MM_Username']))

pinch
08-30-2006, 10:07 AM
Try this:


<?php
if(!isset($_SESSION['MM_Username'])){
//bracket use round ur isset wrong
$loging_box = "<td bgcolor='#000000'><form id='form1' name='form1' method='POST' action='$loginFormAction'>";
/*this wrong - <?php echo $loginFormAction;?> too*/
$loging_box .= "<span class='style114'>Membership Number<input type='text' name='textfield' /><br />Password</span><input type='text' name='textfield2' />";
$loging_box .= "<br /><input type='submit' name='Submit' value='Login' /></form></td>";
echo $loging_box;
}
?>

That should fix it.

Hi Thanks, i have fixed the second part, but i am not too sure what you mean by the wrong use of brackets, please can you explain further.

thanks again

Webmonkey
08-30-2006, 10:08 AM
he maeans the differnece in my post.

pinch
08-30-2006, 10:12 AM
thanks everyone, fixed



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum