This might seem stupid, but I have this simple php code, and it is not echoeing the message to the screen, neither is redirecting the page. I am not sure why. I tested the db connection and it is working, also the user and password used for test exist in the db (of course info changed here for security). What am I doing wrong? What am I missing?
<?php
session_start();
include_once("C:/webroot/connect.php");
if (isset($_POST['submit'])){
//$user=$_POST["httpd_username"];
$user="usernameXYZ";
//$pass=$_POST["httpd_password"];
$pass="passXYZ";
$query= "SELECT * FROM regtrack_users WHERE user_name='$user' and password='$pass'";
$result =pg_query($query) or die ("Unable to connect to db");
$numrows=(pg_num_rows($result));
if($numrows>0){
$row=pg_fetch_assoc($result);
$dbuser=$row['user_name'];
$dbpass=$row['pass'];
echo "$dbuser and $dbpass";
}
header("Location:login.php");
}
?>
It might because of this part:
if($numrows==1){
$row=pg_fetch_assoc($result);
$dbuser=$row['user_name'];
$dbpass=$row['pass'];
echo "$dbuser and $dbpass";
}
You should check if the $numrows variable really contains 1, or you should try $numrows>0 instead of $numrows==1
Root of the problem lies in 3rd line, you are providing a path to a file to include in wrong way. Read here about how properly you should be providing paths to files in php code:
http://yagudaev.com/posts/resolving-php-relative-path-problem/