help

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!

Moderator: General Moderators

Post Reply
idnoble
Forum Commoner
Posts: 28
Joined: Wed Mar 31, 2004 4:09 am

help

Post 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;
}
?>
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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;

?
idnoble
Forum Commoner
Posts: 28
Joined: Wed Mar 31, 2004 4:09 am

Post 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;
}
?>
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
Post Reply