Log in

View Full Version : Session help!



мϊкэ
09-08-2005, 05:27 PM
right this worked fine originally, i logged in on the member system and it kept you logged in when you went on other pages, right but i did some editing and its now broke! so i want to know how i can add a session to this login,


<?php
include('connect.php');
if ($_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "A password was not supplied<br>";
}else{
$query = mysql_query("SELECT username,password FROM members WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo "The supplied login is incorrect<br>";
}else{
$query = mysql_query("SELECT username,password FROM members WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
header("Location: index.php?show=main");
}
}
}
?>
<strong>Login</strong>:
<form action='index.php?show=login' method='POST'>
<table cellpadding="0" cellspacing="0" class="boxes_main">
<tr>
<td align='left'>
Username:<br> <input type='text' size='20' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='left'>
Password:<br> <input type='password' size='20' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='left'>
<input type="submit" value="Login">
</td>
</tr>
<tr>
<td align='left' class="boxes_main">
<a href="index.php?page=members/forgot">Forgot Password ?</a> | <a href="index.php?page=members/register">Register</a>
</td>
</tr>
</table>
</form>

please help :'(

Anderman
09-08-2005, 05:37 PM
God how many errors do you get on your site
:rolleyes:
Wouldnt it be quicker to re-add the original code than debug it all

мϊкэ
09-08-2005, 06:17 PM
ok...

right on connect.php it actually starts a session apparently!

Wootzeh
10-08-2005, 07:36 AM
if ($password==NULL) :rolleyes:

splintercell!
10-08-2005, 08:14 AM
session_start(); :) Thats how you start a session.

Want to hide these adverts? Register an account for free!