Hello my apologies if i post this in wrong category. I was given a script to help someone put a login/register script on their website and ran into a snag. When a user enters their info into username,password fields it doesnt seem to add the record to the database table but does not give an error either i am fairly new to mysql but i am trying this on my debian system using php5 and mysql 5 i believe from what i can tell just username and password fields are required to add the user and i made those tables in mysql. Here is the code if anyone can guide me in the right direction it be much apreciated.
//connect to the db server , check if uname exist
include('config.php');
$query=("Select * from user where uname='$name'");
$result= mysql_query($query);
$num=mysql_num_rows($result);
Perhaps 'config.php' contains the commands to connect to the server and connect to the database, but without seeing what is in config.php, I can't tell. It should look something like this:
//NEED TO CHECK IF FIELDS ARE FILLED IN
if(empty($_POST['name']) && (empty($_POST['email']))){
header("Location:Messages.php?msg=3");
exit();
}
if(empty($_POST['pw1']) && (empty($_POST['pw2']))){
header( "Location:Messages.php?msg=4" );
exit();
}
Firstly lets break this down, IF $_POST['name'] IS EMPTY AND $_POST['email'] IS EMPTY, so both of them have to be empty. What if only one of them is empty. Change the && to || (or operator)
Next, try outputting $query to see what it withholds, aswell as add mysql_error() calls to the queries if they fail (as mentioned previously)