So its the final step of a college project... i'm trying to get a value from a mysql table dependant from the session. For example, you enter your email and password, the next page you are redirected two has your first name. I'm using this script for the login check:
<?php
ob_start();
$host="localhost";
$username="***";
$password="***";
$db_name="***";
$tbl_name="usersWebsite";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$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'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
and i'm using this short code to create the session:
<?php
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<meta http-equiv="refresh" content="0; url=http://starkwave.com/main/dashboard" />
got the code on an tutorial online and adapted it to my situation i want to echo in a php page the first name of the user that logged in, Thank you very much