let's start a session, with
start_session(); that will be the first line after a <? php block.
in login-exec.php let's start the session_start() too,
if($POST["password"]!='' AND $POST["password"]!='')
{
//connection to the database
//select the username and password
//-fetch the rows if it is in the table
//let's add a value to the $_SESSION['SESS_MEMBER_ID']
$_SESSION['SESS_MEMBER_ID']=$rows["member_id"];
header("Location: your_previous site.php"); //use the header location to get to the previous file
}
header("Location: your_previous site.php?message=empy_form");
hello
jjozsi
http://phpcode.hu
PHPviper;10890205 wrote:I'm trying to make it so that when the user is not logged in, it shows the login form and if he/she is logged in, it shows 'Welkom $login'.
<?php
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) {
?>
form id="loginForm" name="loginForm" method="post" action="login-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="112"><b>Login</b></td>
<td width="188"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>
<?php
} else {
<h1>Member pagina</h1>
<p>Welkom <?php echo $login; ?></p>
<?php
}
?>
What's wrong with this? I'm new to PHP