PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello, I'm trying to create a login system, where once people login the system will display their first and last name as it appears in the database, I've done the scripts for the login and it works fine but the message with the first and last doesn't get diaplyed, I've gone through the script a gazillion times and still no luck can anybody help out. The script is below
thank you
<?php
//Create short variable names
$Email = $HTTP_POST_VARS['Email'];
$Password = $HTTP_POST_VARS['Password'];
//Check for required fields from login form
if (!$Email || !$Password){
header("Location: //http:82.44.148.126/login.html");
exit;
}
//Connect to mysql servers and select database
$session = mysql_connect("localhost", "root", "platinum")
or die(mysql_error());
mysql_select_db("xplosive") or die(mysql_error());
//issue query to mysql
$sql = "select First_name, Last_name
from customer_account
Where Email = '".$Email."' AND Password = '".$Password."'";
$result = mysql_query($sql,$session) or die(mysql_error());
//acquire number of rows in the result set
if (mysql_num_rows($result) == 1) {
//If authorised get values of First and last names
$First_name = mysql_result($result, 0, 'First_name');
$Last_name = mysql_result($result, 0, 'Last_name');
$msg = '<p style= "font-size: 12pt; color: black"><strong>Hello:$First_name $Last_name</strong></p>';
}
else {
//redirect back to login form if unauthorised
header("location:http://82.44.148.126/login.html");
exit;
}
?>
I see $msg = '<p style= "font-size: 12pt; color: black"><strong>Hello:$First_name $Last_name</strong></p>'; but i don't see where you actually display it, eg echo $msg;
<?php
//Create short variable names
$Email = $HTTP_POST_VARS['Email'];
$Password = $HTTP_POST_VARS['Password'];
//Check for required fields from login form
if (!$Email || !$Password){
header("Location: http://82.44.148.126/login.html");
exit;
}
//Connect to mysql servers and select database
$session = mysql_connect("localhost", "root", "platinum")
or die(mysql_error());
mysql_select_db("xplosive") or die(mysql_error());
//issue query to mysql
$sql = "select First_name, Last_name
from customer_account
Where Email = '".$Email."' AND Password = '".$Password."'";
$result = mysql_query($sql,$session) or die(mysql_error());
//acquire number of rows in the result set
if (mysql_num_rows($result) == 1) {
//Set authorisation cookie
header ("Set-Cookie: auth", "1", 0, "/", "xplosivehome.php", 0);
//If authorised get values of First and last names
$First_name = mysql_result($result, 0, 'First_name');
$Last_name = mysql_result($result, 0, 'Last_name');
echo $msg = "<p style= "font-size: 12pt; color: white"><strong>Hello:$First_name $Last_name</strong></p>";
}
else {
//redirect back to login form if unauthorised
header("location:http://82.44.148.126/login.html");
exit;
}
?>