I believe that this is a really basic problem but i am starting my coding at PHP so i really can't do it all alone:
I've been for 2 days trying to solve a strange problem. I am using XAMPP for my database and its tables with the objective of creating a login and register system.
This is my user table:
CREATE TABLE `playware`.`users` (
`user_id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 25 ) NOT NULL ,
`surname` VARCHAR( 25 ) NOT NULL ,
`email` VARCHAR( 35 ) NOT NULL ,
`telephone` VARCHAR( 9 ) NOT NULL ,
`password` VARCHAR( 50 ) NOT NULL ,
UNIQUE (`email`)
) ENGINE = MYISAM ;
The register .php file is working (it's adding the user to the table correctly) but when i try to make login i just can't.
So I've made this on my login.php file just to test if it gets the row:
<?php
include_once 'connect.php';
session_start();
if(isset($_SESSION['user'])!="")
{
header("Location: index_home.php");
}
$email = $_POST["email"];
$upass = $_POST["password"];
$sql="SELECT email FROM users";
$res=$conn->query($sql);
if($res->num_rows>0)
{
while($row=$res->fetch_assoc());
{
if($row["email"]==$email)
{
echo"Writting email: ".$row["email"]." - done writting.";
}
}
}
?>
All time i try to do this results on a white screen, nothing more, when it's supposed to appear the user email. Someone knows how to fix this?
================================UPDATE================================== The error was:
while($row=$res->fetch_assoc());
{
//Stuff here ...
}
It can't take the ";" there because it cancels the outputting. So the fix is:
while($row=$res->fetch_assoc())
(...)
As I expected, it was a basic error ... Thank you for people that supported me.