title: How to test a php login connected to a mysql db through xampp?
body: <p>hello this is my first post on stackoverflow i am at beginner level at php, mysql and work on a php log in page connected to a mysql database which i did try to test through xampp and getting the following error message</p>
  
  <pre><code>Warning: include(../storescripts/connect_to_mysql.php): failed to open stream: No such
  file or directory in C:\xampp\htdocs\myonlinestore\storeadmin\admin_login.php 
  on line 15
  
  Warning: include(): Failed opening '../storescripts/connect_to_mysql.php' for
  inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\myonlinestore
  \storeadmin\admin_login.php on line 15
  
  Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in 
  C:\xampp\htdocs\myonlinestore\storeadmin\admin_login.php on line 18
  That information is incorrect, try again Click Here
  </code></pre>
  
  <p>I was able to successfully connect to the mysql database through dreamwavercs6 on win7 64bit and created a user for the db as also i created a administrator with full privileges in the created admin table. With a successful log in it should direct you to a follow up page called <code>index.php</code> which is a second index page only for admins to choose tasks, located in a subfolder in the same directory. The home page <code>index.php</code> is located here <code>C:\xampp\htdocs\myonlinestore\index.php\</code>  </p>
  
  <p>the file with the script called <code>admin_login.php</code> is shown under here </p>
  
  <pre><code>&lt;?php
  session_start();
  if (isset($_SESSION["manager"])){
  header("location: index.php");
  exit();
  }
  ?&gt;
  &lt;?php
  if (isset($_POST["username"]) &amp;&amp; isset($_POST["password"])){
  
  $manager = preg_replace('#[^A-Za-z0-9]#i','',$_POST["username"]);
  $password = preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]);
  
  include "../storescripts/connect_to_mysql.php";
  $sql = mysql_query("SELECT id FROM admin WHERE username='$manager' AND
  password='$password' LIMIT 1");
  $existCount = mysql_num_rows($sql);
  if ($existCount == 1){
  while($row = mysql_fetch_array($sql)){
  $id = $row["id"];
  }
  $_SESSION["id"] = $id;
  $_SESSION["manager"] = $manager;
  $_SESSION["password"] = $password;
  header("location: index.php");
  exit();
  } else {
  echo 'That information is incorrect, try again &lt;ahref="index.php"&gt;Click Here&lt;/a&gt;';
  exit();
  }
  }
  ?&gt;
  </code></pre>
  
  <p>the script <code>connect_to_mysql.php</code> under here</p>
  
  <pre><code> &lt;?php 
  $db_host = "localhost";
  $db_username = "user"; 
  $db_pass = "user"; 
  $db_name = "myonlinestore_db";
  
  mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to
  mysql");
  mysql_select_db("$db_name") or die ("no database");             
  ?&gt;
  </code></pre>
  
  <p>the script <code>index.php</code> which is the landing page where on successful login from <code>admin_login</code> should redirect you to, under here</p>
  
  <pre><code>&lt;?php
  session_start();
  if(!isset($_SESSION["manager"])){
  header("location: admin_login.php");
  exit();
  }
  $managerID = preg_replace('#[^0-9]#i', '',$_SESSION["id"]);
  $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]);
  $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]);
  
  include"../storescripts/connect_to_mysql.php";
  $sql=mysql_query("SELECT*FROM admin WHERE id='$managerID' AND username='$manager' AND
  password='$password' LIMIT 1"); // query the person
  
  $existCount=mysql_num_rows($sql); // count the nums
  if ($existCount==0){//evaluate the count
  echo "Your login session data is not on record in the database";
  exit();
  }
  ?&gt;
  </code></pre>
  
  <p>the problem is that i can not log in through my firefox browser and getting the error as mentioned at the top. All addons,extensions in my firefox browser are on disable and accepting cookies is selected, can anyone help to fix this problem?  </p>
  
  <p>Many thanks in advance</p>