This question already has an answer here:
databaseI'm having trouble getting my registration code working. I keep getting the error:
Unknown column 'email' in 'where clause'
What am i doing wrong? I tried:
$query = "SELECT * FROM register_login WHERE 'email' = '$email'";
and it seemed to work but nothing was uploaded to my database. back in 2014 this code was working perfectly but then i stooped using it for 2 years and now its not working
Here is the server code:
<?php
if(isset($_POST['submit'])) {
// Required field names
$required = array('email');
// Loop over field names, make sure each one exists and is not empty
$error = false;
foreach($required as $field) {
if (empty($_POST[$field])) {
$error = true;
}
}
if ($error) {
echo 'You forgot to fill in your email';
} else {
include("configur.php");
$email = mysqli_real_escape_string($link, $_POST['email']);
$query = "SELECT * FROM register_login WHERE email = '$email'";
$result = mysqli_query($link, $query) or die(mysqli_error($link));
if (mysqli_num_rows($result) ) {
print 'E-mail already exists. Please use a different email';
}
else {
include('config.php');
// table name
$tbl_name="pre_register";
// Random confirmation code
$confirm_code=md5(uniqid(rand()));
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$fdrink=$_POST['fdrink'];
$fdrink1= hash("sha512", $fdrink);
$email=$_POST['email'];
$password=$_POST['password'];
$encrypt_password= hash("sha512", $password);
$confirmpassword=$_POST['confirmpassword'];
$encrypt_password1=hash("sha512", $confirmpassword);
// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, fname, lname, fdrink1, email, encrypt_password, encrypt_password1 )VALUES('$confirm_code', '$fname', '$lname', '$fdrink1', '$email', '$encrypt_password', '$encrypt_password1')";
$result=mysql_query($sql);
// if suceesfully inserted data into database, send confirmation link to email
if($result){
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email;
</div>