Jump to content

equivalents

New Members
  • Posts

    3
  • Joined

  • Last visited

equivalents's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thankyou PFMaBiSmAd! Thanks for saving me quite a few hours, I have already spent many trying to solve that! I can move foward now! I wish I had know that beforehand! I just satrted, and I don't think the book I've been using mentions that, but I will check now.... My login form works now!
  2. Hey Thanks for the reply! Doesn't this line do that? $dbc = mysqli_connect("$host", "$username", "$password", "$db_name")or die("cannot connect"); I was just eliminating as many variables as possible, I also wanted to make the code short and easy to read for anyone helping me. I set the database up and it has only one table and the table only has one entry. So, i figured I would just start testing there and build the code up as I went along.
  3. Hey folks, I'm trying to create my first Login script using php to check for username and password in a MYSQL database. The script seems succesful at connecting to the database, however when I retrieve results from a table that I have confrimed exsist, the mysql_num_rows($result); returns zero, Can anyone suggest a solution or a diagnosis path? Here is what I have: LAMP server PHP 5.4.4-7 MYSQL Ver 14.14 Distrib 5.5.24 <?php ob_start(); $host="localhost"; // Host name $username="pi"; // Mysql username $password="raspberry"; // Mysql password $db_name="n2it2_database"; // Database name $tbl_name="email_list"; // Table name // Connect to server and select databse. $dbc = mysqli_connect("$host", "$username", "$password", "$db_name")or die("cannot connect"); $sql="SELECT * FROM email_list"; $result=mysqli_query($dbc, $sql) or die('Error quering database.'); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" echo "Success!"; } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> login_script 2.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.