the html element on a seperate page is fine.
When a user tries to login and hit submit its returning the "cant execute query".
I can't understand why this is happenning.
Im new to PHP. im using php 5 and not using mysql.
heres my code
<?php $username = (isset($_POST['username'])) ? pg_escape_string($_POST['username']) : "";
$password = (isset($_POST['password'])) ? pg_escape_string($_POST['password']) : "";
$referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : "noreferer";
#this will make user return to login page if a field is left empty
if ( ( !$username ) or (!$password) )
{
header ( "location:$referer" );
exit();
}
$conn = @pg_connect("connection details hidden");
$psql="select * from users where username =\"$username\" and password =\"$password\"";
$rs = @pg_query ($psql, $conn)
or die ("could not execute query");
#get number of rows that match username and password
$num = pg_num_rows($rs);
#if there is a match log in successful
if ( $num !=0 )
{
$msg = "Welcome $username - You are logged in";
}
else #return to log in page
{
header ( "location:$referer" );
exit();
}
?>
<html>
<head><title>You are logged in</title></head>
<body>
<? echo ( $msg );
?>
</body>
<html>
any ideas?


Sign In
Create Account


Back to top










