-4

Im trying to check if the email exist in the ddbb, so my code is:

<?php
include 'connection.php';
$email=addslashes ($_POST['cEmail']);
$sqlEmail = "select cEmail from Client where cEmail = '$email'";
$exist = mysql_fetch_row($sqlEmail); 

if (isset($_POST['submit']))
    {
        if($exist == false){
            $name = addslashes ($_POST['cName']);   
            $surname=addslashes ($_POST['cSurname']);
            $email=addslashes ($_POST['cEmail']);
            $phone=addslashes ($_POST['cPhone']);
            $otherPhone=addslashes($_POST['cOtherPhone']);
            $languages=implode(' | ', $_POST['cLanguages']);
            $address=addslashes ($_POST['cAddress']);
            $neighborhood=addslashes ($_POST['cNeighborhood']);
            $pswd=addslashes($_POST['cPswd']);
            $service= addslashes ($_POST['cService']);

            $sql = "INSERT INTO Client(cName, cSurname, cEmail, cPhone, cOtherPhone, cLanguages, cAddress, cNeighborhood, cPswd, cService) 
                VALUES ('$name', '$surname', '$email', $phone, $otherPhone, '$languages', '$address', '$neighborhood', '$pswd', '$service')";

            if ($conn->query($sql) === TRUE) {
                echo "New record created successfully";
            }
        }else{
            echo "the email exists";
        }
    }

?>

So the problem becomes when the email address exist in the database, is not giving any message. Any ideas?

Thanks!

Barmar
  • 741,623
  • 53
  • 500
  • 612

1 Answers1

0

Hi @AlguienEnEsteMundo,

Your code is incorrect so it is generating warning "mysql_fetch_row() expects parameter 1 to be resource, string given"(please check your php ini setting to display the warning message). Following is the correct code, please update your code with:

include 'connection.php';
$email=addslashes ($_POST['cEmail']);
$sqlEmail = "select cEmail from Client where cEmail = '$email'";
$res = mysql_query($sqlEmail);
$exist = mysql_fetch_row($res); 

Hope this may fix your issue...

Vikramraj
  • 188
  • 4
  • 18