I found a tutorial password-reset function that I could use for my website, so I downloaded the files and played around with the code. I didn't like theirs that much, so I deleted almost all of it and kept the important parts. Anyway, I downloaded it from here, and unfortunately now it isn't working.
Whenever I type in an email, no matter what it is, it says, "Invalid email." Any help will be appreciated. Also, I am a slight noob at PHP, but I understand all of the code here. My code is below:
<?php include "base.php"; ?>
 <html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" href="style2.css" type="text/css" />
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>Forgot Password</title>
</head>
<body>
    <div id="main"><h1>Forgot Password</h1>
    <p>If you forgot your password, please enter the email associated with your account, and we will send you a reset link.</p>
        <form action="" method="post" name="passwd" id="passwd">
        <fieldset>
            <label for="emailadd"><div>Email Address:</div></label><input id="emailid" name="emailid" type="text" placeholder="Your Account's Email"><br>
            <input type="submit" value="Reset Password" />
        </fieldset>
        </form>
        </div>
<?php
    if(!empty($_POST['emailid']))
    {
        $emailaddress = mysqli_real_escape_string($_POST['emailid']);
        if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $emailaddress))  // Validate email address
       {
            echo '<p id="msg"><center>That is an invalid email address. Please try again.</center></p>';
        }
        else
        {
            $query = "SELECT UserID FROM users where  EmailAddress='".$emailaddress."'";
            $result = mysqli_query($query);
            $Results = mysqli_fetch_array($result);
           if(count($Results)==1)
            {
                $encrypt = md5(XXXXXXXXXXXXXXXXXXX);
                echo '<p id="msg"><center>Your password reset link has been sent to your email.</center></p>';
                $to=$emailaddress;
                $subject="Forgot Password";
                $from = 'no-reply@XXXXXXXXXXXX.com';
                $body='Hello, <br/> <br/>Your Membership ID is:   '.$Results['id'].' <br><br>Click <a href="http://XXXXXXXXXXX.com/home/forgot/reset.php?encrypt='.$encrypt.'&action=reset">here</a> to reset your password, or follow the link below:<br><br>http://XXXXXXXXXXXX.com/home/forgot/reset.php?encrypt='.$encrypt.'&action=reset <br/> <br/>--<br>XXXXXXXXXXXX<br>Games, Tools, and so much more!';
                $headers = "From: " . strip_tags($from) . "\r\n";
                $headers .= "Reply-To: ". strip_tags($from) . "\r\n";
                $headers .= "MIME-Version: 1.0\r\n";
                $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                mail($to,$subject,$body,$headers);
            }
            else
            {
                echo '<p id="msg"><center>Account not found. Please try again.    </center></p>';
            }
        }
    } elseif(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) {
        echo "<meta http-equiv='refresh'              content='0;http://www.XXXXXXXXXXXX.com/home/main.php'/>";
    } else {
    }
//    include("html.inc"); 
?>
</body>
</html>
P.S. Base.php connects to my database, and the Xs represent either my encryption or my website address.
Thanks in advance!
 
     
    