one the customer as login to the web site and they have booked an event i want to be able to callthe username
below is small code where i trying to call the user name and simply echo it out but all i get is blank i can call the game variable from booking page when try reuse the usernaem nothing
<?php
session_start();
if (($_SESSION['auth'] == false)||(!isset($_SESSION['auth']))){
header("location:login.html");
}
$game = $_GET['game'];
echo $game;
$username =$_SESSION['user']
echo $username;
?>
*************************************start of login php
<?php
session_start();
$_SESSION['auth']=false;
$host="localhost"; // Host name
$username="20203800"; // Mysql username
$password="ralph"; // Mysql password
$db_name="two0203800"; // Database name
$tbl_name="ralphdb"; // 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");
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
// 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'";
$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['user']=$username;
$_SESSION['auth'] = true;
$_SESSION['password']=$mypassword;
//$path = "location:members.php";
}else {
$path = "location:login.html";
}
header($path);
?>
below is small code where i trying to call the user name and simply echo it out but all i get is blank i can call the game variable from booking page when try reuse the usernaem nothing
<?php
session_start();
if (($_SESSION['auth'] == false)||(!isset($_SESSION['auth']))){
header("location:login.html");
}
$game = $_GET['game'];
echo $game;
$username =$_SESSION['user']
echo $username;
?>
*************************************start of login php
<?php
session_start();
$_SESSION['auth']=false;
$host="localhost"; // Host name
$username="20203800"; // Mysql username
$password="ralph"; // Mysql password
$db_name="two0203800"; // Database name
$tbl_name="ralphdb"; // 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");
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
// 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'";
$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['user']=$username;
$_SESSION['auth'] = true;
$_SESSION['password']=$mypassword;
//$path = "location:members.php";
}else {
$path = "location:login.html";
}
header($path);
?>