i have problem with my code, it didn't say any error but it wont receive a data from the textfield.. is there something wrong with my code?

here is the code..

<?php 

include('config.php');

$email=$_REQUEST['email'];

$sql ="SELECT * from employee where emp_work_email = '$email'";
$hasil=mysql_query($sql) or die("E-mail is invalid".mysql_error());
$data=mysql_fetch_array($hasil);


$sql1 ="select emp_password from employee where emp_work_email = '$email' ";
$hasil1= mysql_query($sql1) or die("Password is not match".mysql_error());
$data1=mysql_fetch_array($hasil1);

if($data == $email)
{
    $to=$email;

    $subject="This is your password";

    $header="<no-reply@lms.com>";

    $message="Your password is";
    $message.= data1;

    $sentmail = mail($to,$subject,$message,$header);
}
else
{
    echo" not found email in your database";
}
if($sentmail){
    echo"Your password already sent to your email";
}
else{
    echo" cannot send to the email";
}

?>

when i run it, it show that not found email in your database..

can someone help me please? :(

Recommended Answers

All 6 Replies

what is the URL before you start this script?
where are you requesting the $email from?

if you var_dump($email); is there a valid output?

$email requested from the user input, there is a textfield that allow user to enter the email, and after click submit, the script should be matching the user input email address with the one in database, if its matched, then it will send the email, if not match, it means its not in database,,

what is the output of var_dump($email)?

Is this information transfering?

Instead

if($data == $email)

Try

if(in_array($email, $data))

Check it!
$email=$_REQUEST['email'];

You are comparing $data with $email. Just print the $data array to show what it has .

var_dump($data);

So you should be using :

if($data['email'] = $email){ //depends on your coloumn 
    //your code here
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.