Forum Moderators: coopster
<?php session_start();
$username = $_POST['username'];
$userpass = md5($_POST['password']);
$sql = "select * from usertable where username='$username' and password='$userpass'";
$result = mysql_query($sql);
if (mysql_num_rows($result)!= 1) {
$error = "Login failed";
} else {
$row = mysql_fetch_array($result);
$_SESSION['username'] = "$username";
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
header("Location: h*tp://www.w-------.com/$row['USLP']");
}
?>
Also, add error messages to your MySQL connecton, etc. so you can see what's happening, like:
if (!$dbl = mysql_connect($host,$user,$pass)) die(mysql_error());
...
if (!$result = mysql_query($sql)) die(mysql_error());
What's the action attribute of your login form? Does it point to this script?
Also, you're not going to see the $error message, unless you echo it.
$error = "Login failed";
echo $error;
// or just
$echo "Login failed";
I hope this helps.
<?php $dbh=mysql_connect ("localhost", "mysql_user", "******") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mysql_table");
?>
<?php resource mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]])
$host = "host";
$user = "user";
$pass = "pass";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
$error = "Login failed";
echo $error;
// or just
$echo "Login failed";
if (!$dbl = mysql_connect($host,$user,$pass)) die(mysql_error());
...
if (!$result = mysql_query($sql)) die(mysql_error());
bool mysql_select_db ( string database_name [, resource link_identifier])
$dbname = "dbname";
mysql_select_db($dbname);
session_start();
$username = $_POST['username'];
$userpass = md5($_POST['password']);
$sql = "select * from usertable where username='$username' and password='$userpass'";
$result = mysql_query($sql);
if (mysql_num_rows($result)!= 1) {
$error = "Login failed";
} else {
$row = mysql_fetch_array($result);
$_SESSION['username'] = "$username";
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
header("Location: [website...]
}
?>
I wish you well.