Page 1 of 1

help

Posted: Fri Apr 16, 2004 4:29 am
by idnoble
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

Code: Select all

<?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;
}
?>

Posted: Fri Apr 16, 2004 4:41 am
by markl999
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;

?

Posted: Fri Apr 16, 2004 5:18 am
by idnoble
hey thank you for that i've put echo in front now and got another error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in d:\phpweb\xplosivehome.php on line 34

here's the script as it is now

Code: Select all

<?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;
}
?>

Posted: Fri Apr 16, 2004 6:12 am
by markl999
echo $msg = "<p style= "font-size: 12pt; color: white"><strong>Hello:$First_name $Last_name</strong></p>";
Either do:

echo "<p style= \"font-size: 12pt; color: white\"><strong>Hello:$First_name $Last_name</strong></p>";

or

$msg = "<p style= \"font-size: 12pt; color: white\"><strong>Hello:$First_name $Last_name</strong></p>";
echo $msg;

Use the first way unless you need to use $msg somewhere else too.