Don't use == in MySQL queries: use ONE = only.
In this case, I'd guess you want to select an record field, like 'name', not *.
So rewrite:
$result = mysql_query("SELECT name FROM $table_name WHERE auser = '$user' AND apass = '$pass'");
- You need to FETCH THE RESULT.
I assume you only have one row/record with this username / pass. (If you have more records, you'd need a while loop to fetch them all.)
$row=mysql_fetch_array($result);
- Your comparison as written will always be true.
/*YOURS*/if ($auser == "$auser" AND $apass == "$apass")
Rewrite to actually check result of your query:
$name=$row[0];
//first element of your returned array. Make sure that element has a value in every record.
//Then check to see that a record was returned; otherwise the user ain't authorized.
if ($name){
echo "<br><br><center><font size='+2'>Welcome $name":}
PS other notes:
and (lowercase) not AND in PHP
If($x==true and $y==true)
THEN IT FOLLOWS THAT
($x<>true and $y<>true)
So your structuire
if($x==true and $y==true) {}//A }
elseif ($x<>true and $y<>true) { }//B
else {} //C -- THIS CASE IS NEVER EVER GOING TO BE REACHED. Can you tell why?
Maybe you meant:
if($x==true and $y==true) {
echo 'both OK';
}
elseif ($x<>true ) {echo 'x was false, y was true'; }
elseif ($y<>true ){echo 'x was true, y was false';}
else {echo 'both false';}