basically having a problem with a login behavior (a different way of doing it anyway) the one i had before worked fine but now i need to add some information from login so that it can be retrieved later. Someone gave me the code yesterday(sorry m8, cant remember your name
Heres the database confirmation code.
Code: Select all
// The Database Connection Is Defined Here
$link = mysql_connect("localhost","malcolmboston","********")
or die("Connection Error" . mysql_error());
print "Connection To MySQL Server Established";
mysql_select_db("TDN") or die("Unable To Make Connection To Relevant Database");
// Database Connection Code Completed */Code: Select all
<?php
// user has filled out the login form...
if(isset($_POST['login']))
{
$username = addslashes(trim($_POST['username']));
$password = md5($_POST['password']);
$query = mysql_query("select session_id from login where username = '$username' AND password = '$password' limit 1");
$check = mysql_num_rows($query);
if($check == 1)
{
// user is in the database and was found..
session_start();
$row = mysql_fetch_array($query);
$_SESSION['user_id'] = $row['session_id'];
$_SESSION['username'] = $username;
// send the authenticicated user to specical members area
header("location: logged_in\index.php");
exit;
}
else
{
// User was not found in the database
echo "<br>incorrect username and password!";
}
}
?>Code: Select all
&lt;form name="login" autocomplete="off" id="login" method="POST"&gt;
&lt;table width="100%" border="0"&gt;
&lt;tr&gt;
&lt;td&gt;Username&lt;/td&gt;
&lt;td&gt;&lt;input name="username" type="text" id="username" maxlength="20" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password&lt;/td&gt;
&lt;td&gt;&lt;input name="password" type="password" id="password" maxlength="15" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;input name="login" type="submit" id="login" value="login" /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;My thoughts on why this is happening
- The MD5 password, i know what MD5 is, im just wondering i my field in mysql needs to be "md5'd" as well?
- Possibly the login program is requiring the session_ID is already in its field, which obviously it is'nt, if that is the problem how do i write this in because the session is only started if the person logs in sucessfully (this cannot surely be the problem can it?)
Please Note : All of the defined tables in the PHP coding are present on my MySQL server (username, password and session_id and a lot more)