Hi, I need to have a forgot password php script this is what i have came up with so far:
Can somebody tell me what i need to get the mail function to work.
<?php
session_start();
ini_set( 'display_errors', '1' );
error_reporting ( 2047 );
$fromemail = "someone@hotmail.com";
$scripturl = "http://localhost/xampp/mailsend.php";
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from signup form
$myusername=$_POST['myusername'];
$myemail=$_POST['myemail'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and email='$myemail'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $myemail, table row must be 1 row
if($count==1){
$sql="SELECT * FROM $tbl_name WHERE email = '$myemail'";
$resultID=mysql_query($sql);
$row = mysql_fetch_array($resultID);
$password = $row[0];
// End of query commands
// Send Password to email
$subject = 'Your Password';
$message = 'Go to ' . $scripturl . '?action=change&email='. $myemail .'&pass='. $mypassword .' to change your password.';
$headers = 'From: someone@hotmail.com' . "\r\n" .
'Reply-To: someone@hotmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($myemail, $subject, $message, $headers);
}
else {
header("location:login_failure.php");
echo "We are sorry, your Email and username do not appear to be in our database";
}
?>