Jump to content

login script not working! it works on my other site.....?


Alexhoward

Recommended Posts

Hi guy,

 

I've got this login script that works fine on my other site,

 

but keeps saying the password is incorrect on my new one...?

 

can anyone see where i'm going wrong?

 

<?php
ob_start();
include("config.php"); 

// connect to the mysql server 
$link = mysql_connect($server, $db_user, $db_pass) 
or die ("Could not connect to mysql because ".mysql_error()); 

// select the database 
mysql_select_db($database) 
or die ("Could not select database because ".mysql_error()); 

$_POST['password'] = md5($_POST['password']);

$match = "select password from $table where username = '".$_POST['username']."' 
and password = '".$_POST['password']."';"; 

$qry = mysql_query($match) 
or die ("Could not match data because ".mysql_error()); 
$num_rows = mysql_num_rows($qry); 

if ($num_rows <= 0) { 
echo "Sorry, that password is incorrect.<br>"; 
echo "<a href=index.php>Try again</a>"; 
echo "$num_rows";
exit; 
} else { 

$username = $_POST['username'];
setcookie("loggedin", "true");
setcookie("theideasden", "$username");
echo "You are now logged in!<br>"; 
echo "Continue to the <a href=members.php>members</a> section."; 
}
ob_end_flush();
?>

 

Also if i jig it to work, the setcookie part produces errors

 

namely "can't set header, headers already set by....!"

 

i don't understand it works fine on the other site...?

 

Thanks in advance

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.