Hi
I have some script that I have used for sometime so understand it is out of date code, but it works. I want to amend it so that it also checks a field user_type and on successful login directs each to a differnt page. The code at the moment takes username and password from a login page, checks it (code below) and either takes user to a main page if correct or tells them username or password is wrong.
<?php require_once('Connections/Connection1.php'); ?>
<?php
$tbl_name="users"; // Table name
// Connect to server and select databse.
//mysql_connect("$host", "$username", "$password")or die("cannot connect");
//mysql_select_db("$db_name")or die("cannot select DB");
mysql_select_db($database_Connection1, $Connection1);
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=md5($_POST['mypassword']);
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE userid='$myusername' and
password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:main.php?myusername=".$myusername);
}
else {
header("location:login_failed.php");
//echo "Wrong Username or Password";
}
?>
Any help would be very much appreciated!