Devinemke,
Complete code follows:
<?php
// check for required fields from the form
if (isset($_POST['log'])) {
//connection to server and select database
require ('../scripts/db_connect.php');
// create and issue the query
$sql = "select usr_id, usr_name, usr_pwd from log_user where usr_name =
'$_POST[username]' AND usr_pwd = '$_POST[password]'";
$result = mysql_query($sql,$conn) or die(mysql_error());
if (mysql_num_rows($result) == 1) {
$f_uid = mysql_result($result, 0, 'usr_id');
$sql = "select inf_id from user_idx where usr_id=$f_uid";
$residx = mysql_query($sql,$conn) or die(mysql_error());
if (mysql_num_rows($residx) == 1) {
$f_inf = mysql_result($residx, 0, 'inf_id');
$sql = "select inf_fnam, inf_lnam from user_info where inf_id=$f_inf";
$resinf = mysql_query($sql,$conn) or die(mysql_error());
}
// if authorized, get the value of f_name l_name
$f_name = mysql_result($resinf, 0, 'inf_fnam');
$l_name = mysql_result($resinf, 0, 'inf_lnam');
// set authorization cookie
setcookie("auth", "1", 0, "/", "localhost @mydomain.com", 0);
//create display string
$display_block = "<font size=-1><b>Welcome $f_name $l_name.
<br>Thank you for logging in!</b></font>";
echo $display_block;
} else {
$display_block = "<font size=-1><b>Login not successful!</b></font>";
// return;
// exit;
}
} else {
$display_block = "<form action='../scripts/login.php' method='POST'><p><strong>User Login:</strong><br>
<INPUT TYPE='text' NAME='username'></p><p><strong>Password:</strong><br>
<INPUT TYPE='password' NAME='password'></p><p> <br>
<input type=image src='../Images/btn-pale(log).jpg' name=log value=log width=120>
</form>";
}
?>
SQL code is working fine, but can't return the $display_block to the calling form!
OMR