I don’t know what exactly the problem is here, but I’m using xampp to run these scripts… it connects to the server, inputs the information just fine into the database with the registration script and everything works fine in these php codes except that after I run this php code to register:
[CODE]
<?php include_once(“scripts/global.php”);
$message = ”;
if(isset($_POST[‘username’])){
$username = $_POST[‘username’];
$fname = $_POST[‘fname’];
$lname = $_POST[‘lname’];
$email = $_POST[’email’];
$pass1 = $_POST[‘pass1’];
$pass2 = $_POST[‘pass2’];
//error handling
if((!$username)||(!$fname)||(!$lname)||(!$email)||(!$pass1)||(!$pass2)){
$message = ‘Please insert all fields in the form below’;
}else{
if($pass1 != $pass2){
$message = ‘Your passwords must match!’;
}else{
//securing the data
$username = preg_replace(“#[^0-9a-z]#i”,””,$username);
$fname = preg_replace(“#[^0-9a-z]#i”,””,$fname);
$lname = preg_replace(“#[^0-9a-z]#i”,””,$lname);
$pass1 = sha1($pass1);
$email = mysql_real_escape_string($email);
//check for duplicates
$user_query = mysql_query(“SELECT username FROM members WHERE username=’$username’ LIMIT 1”) or die(“Could not check username”);
$count_username = mysql_num_rows($user_query);
$email_query = mysql_query(“SELECT email FROM members WHERE email=’$email’ LIMIT 1”) or die(“Could not check email”);
$count_email = mysql_num_rows($email_query);
if($count_username > 0){
$message = ‘Your username is already in use’;
}else if($count_email > 0){
$message = ‘Your email is already in use’;
}else{
//insert members
$ip_address = $_SERVER[‘REMOTE_ADDR’];
$query = mysql_query(“INSERT INTO members (username, firstname, lastname, email, password, ip_address, sign_up_date)VALUES (‘$username’,’$fname’,’$lname’,’$email’,’$pass1′,’$ip_address’,now())”) or die(“Could not insert your information”);
$member_id = mysql_insert_id();
mkdir(‘users/’.$member_id,0755);
$message = ‘You have now been registered!’;
}
}
}
}
?>
I used this code to enable logins but it keeps coming back with “The information your provided is not correct” when i try to login.. I used the same information logging in as I did to register… not sure what’s wrong
[CODE]
<?php include_once(“scripts/global.php”);
$message = ”;
if(isset($_POST[’email’])){
$email=$_POST[’email’];
$pass=$_POST[‘pass’];
$remember=$_POST[‘remember’];
//error handling
if((!$email)||(!$pass)){
$message = ‘Please enter both email and password fields!’;
}else{
//secure data
$email = mysql_real_escape_string($email);
$pass = sha1($pass);
$query = mysql_query(“SELECT * FROM members WHERE email=’$email’ AND password=’$pass’ LIMIT 1”) or die (‘Could not check.’);
$count_query = mysql_num_rows($query);
if ($count_query == 0){
$message = “The information your provided is not correct”;
}else{
//start the session
$_SESSION[‘pass’] = $pass;
while($row = mysql_fetch_array($query)){
$username = $_row[‘username’];
$id = $_row[‘id’];
}
$_SESSION[‘username’] = $username;
$_SESSION[‘id’] = $id;
if($remember == ‘yes’){
//create cookies
setcookie(‘id_cookie’, $id, time()+60*60*24*100,”/”);
setcookie(‘pass_cookie’, $pass, time()+60*60*24*100,”/”);
}
header(‘Location: home.php’);
}
}
}
?>