Hi there I'm trying to do a function that check if the informations sent by the user when he wants to register are correct !! but i'm keep getting this error :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@hotmail.com' at line 1
Could anyone help me please! i don't know whats' wrong with the code.
This is the function user_functions. php
and here is the page register.php
Any help I could appreciate it thanks for advance
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@hotmail.com' at line 1
Could anyone help me please! i don't know whats' wrong with the code.
This is the function user_functions. php
Code:
<?php
class user{
function checkemail($usercheck,$pass1,$pass2){
// checks if the email is in use
echo $usercheck; echo"<br>";
$check = mysql_query("SELECT * FROM `users` WHERE email =" . $usercheck) or die(mysql_error());
echo "first";
$check2 = mysql_num_rows($check);
//if the email exists it gives an error
if ($check2 != 0) {
echo 'email already used';
die('Sorry, the email '.$usercheck.' is already in use.');
}
// this makes sure both passwords entered match
if ($pass1 != $pass2) {
echo 'password did not match';
die('Your passwords did not match. ');
}
// here we encrypt the password and add slashes if needed
$pass1 = md5($pass1);
if (!get_magic_quotes_gpc()) {
echo '111';
$pass1 = addslashes($pass1);
$usercheck = addslashes($usercheck);
}
}
}
?>
Code:
<?php
// Connects to your Database
include_once("include/database.php");
include_once("user_functions.php");
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['email'] | !$_POST['pass'] | !$_POST['pass2'] | !$_POST['full_name'] | !$_POST['Gendre'] | !$_POST['phone'] | !$_POST['nationality']) {
die('You did not complete all of the required fields');
}
if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$usercheck = $_POST['email'];
$pass1 = mysql_real_escape_string($_POST['pass']);
$pass2 = mysql_real_escape_string($_POST['pass2']);
$fullname = mysql_real_escape_string($_POST['full_name']);
$gender = mysql_real_escape_string($_POST['Gendre']);
$phone = mysql_real_escape_string($_POST['phone']);
$birthday = mysql_real_escape_string($_POST['birthday']);
$email = mysql_real_escape_string($_POST['email']);
$address = mysql_real_escape_string($_POST['address']);
$nationality = mysql_real_escape_string($_POST['nationality']);
user::checkemail($usercheck,$pass1,$pass2);
//user::check($fullname,$gender,$pass1,$pass2,$phone,$birthday,$email,$address,$nationality);
//user::checkLog($fullname,$gender,$pass1,$pass2,$phone,$birthday,$email,$address,$nationality);
?>
<h1>Registered</h1>
<p>Thank you, you have registered - you may now<a href="index.php"> login</a>.</p>
<?php
}
else
{
?>
Comment