Jump to content

Php Else script not displaying


photec

Recommended Posts

What I'm trying to do is when user logs in hide the log in form

I have my log in form on my main menu. when I add this code in my header.php my site wont load at all.

<?php

if(!isset($_SESSION['SESS_MEMBER_ID'])){
<a class="green" href="/?content=member-profile">My Profile</a> | <a class="green" href="/logout.php">Logout</a>
else{
<form id="loginForm" name="loginForm" method="post" action="login-exec.php">

<input name="login" type="text" class="textfield" id="login" />
<b>Login</b>
<br></br>

<input name="password" type="password" class="textfield" id="password" />
<b>Pass</b>
<br></br>
<div align="center"><input type="submit" name="Submit" value="Login" /> <a class="green" 

href="/?content=register-form">Sign up |</a></div>
</form>
}
?>

:(

Link to comment
https://forums.phpfreaks.com/topic/193863-php-else-script-not-displaying/
Share on other sites

Probably cause you have a php start tag, an if then a bunch of raw html within the brackets. Either break php, echo it, or put it in a heredoc then echo the var. You should also enable errors cause that is surely throwing one.

 

 

HTH

Teamatomic

<?php

if(!isset($_SESSION['SESS_MEMBER_ID'])){
?>
<a class="green" href="/?content=member-profile">My Profile</a> | <a class="green" href="/logout.php">Logout</a>
<?
else{
?>
<form id="loginForm" name="loginForm" method="post" action="login-exec.php">

<input name="login" type="text" class="textfield" id="login" />
<b>Login</b>
<br></br>

<input name="password" type="password" class="textfield" id="password" />
<b>Pass</b>
<br></br>
<div align="center"><input type="submit" name="Submit" value="Login" /> <a class="green" 

href="/?content=register-form">Sign up |</a></div>
</form>
<?
}
?>

Yes, but try to get in the habit of not using short tags(<?) instead use the basic (<?php) tag. Unless you have absolute control over the server there is no telling when short tags might get turned off and your script will be broken.

 

 

HTH

Teamatomic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.