MySQL Forums :: PHP :: Creating Function to Register Session (user variables)
Creating Function to Register Session (user variables)
Date: June 26, 2013 03:00AM
Please, the script below works but hbangs at the session_register("myusername") line, because the example script didn't include session_register() function. Please, how can I create one to work with this scripts. Other associated .php files are working ok. Thanks.
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // 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");
// Define $myusername and $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 username='$myusername' and password='$mypassword'";
// Mysql_num_row is counting table row
// If result matched $myusername and $mypassword, table row must be 1 row
//Register $myusername, $mypassword and redirect to file "login_success.php"
echo "Wrong Username or Password";
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.