Jump to content

session not logging in...


petroz

Recommended Posts

Hi Guys,

 

This script isn't reporting any errors, but its not actually authenticating at all. I am not even seeing the

 

echo "Hello";

 

Any help would be greatly appreciated.

 

<?php 

include 'db.php';

// Add slashes to the username, and make a md5 checksum of the password. 
$user = addslashes($_POST['username']); 
$pass = md5($_POST['password']); 

$result = mysql_query("SELECT count(bus_id) FROM businesses WHERE password='$pass' AND bus_id='$user' LIMIT 1") or trigger_error('Query failed: ' . mysql_error($db), E_USER_ERROR); 
$num = mysql_result($result, 0);
//$row = mysql_fetch_array($result);
//$num = $row['bus_id'];

if (!$num) 

{

// When the query didn't return anything, 
// display the login form. 

echo "<h3>User Login</h3> 
<form action='$_SERVER[php_SELF]' method='post'> 
Username: <input type='text' name='username'><br> 
Password: <input type='password' name='password'><br><br> 
<input type='submit' value='Login'> 
</form>"; 

} else { 

// Start the login session 
session_start(); 

echo "Hello";

// We've already added slashes and MD5'd the password 
$_SESSION['username'] = $_POST['username']; 
$_SESSION['password'] = $_POST['password']; 

// All output text below this line will be displayed 
// to the users that are authenticated. Since no text 
// has been output yet, you could also use redirect 
// the username to the next page using the header() function. 
// header('Location: page2.php'); 

echo "<h1>Welcome</h1>"; 
echo "You're now logged in. Try visiting <a href='update_info_form.php'>Update Info Form</a>."; 

} 

?>

 

Here is a sample of a user and pw from the db.

 

bus_id   password

eric           f4b00a307fa831ef56ef7117c

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.