Hi,
I've written a code to retrieve my user name & password from a MySql database via email. The code works fine.
I would like to know how to determine the email's return path? At present, the return path is being determined by my server by default. My code is displayed below.
Thanks a lot for your guidance.
<?php
function validateemail($vemail){
$position1 = strpos($vemail,"@");
if ($position1 > 1){
$position2 = strpos($vemail,".",$position1);
if (($position2) > ($position1+1)){
return true;
}
}
return false;
}
?>
<head>
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input name="email" type="text" id="email" size="20">
Email address </p>
<p>
<input name="Submit1" type="submit" id="Submit1" value="Submit">
</p>
<p>
<?php
$username="abc123";
$password="abc123";
$database="abc123";
$host="localhost";
$email=$_POST['email'];
$Submit1=$_POST['Submit1'];
if(isset($Submit1))
{
if (($email != ''))
{
if (validateemail($email)==true)
{
mysql_connect ("$host","$username","$password");
mysql_select_db($database) or die( "Where's the database man?");
$query=mysql_query("SELECT * FROM customers WHERE email = '$email'");
$numrows=mysql_num_rows($query);
if ($numrows>0)
{
$data=mysql_fetch_array($query);
$from ='someone@someone.com';
$to = $data["email"];
$return = 'someone@someone.com';//return path declared here.
$name = $data["name"];
$pass = $data["password"];
$user = $data["username"];
$subject = "Password request from www.someone.com";
$header="From:$from\r\nReply-To:$from\r\n";//how to insert return path here?
$body="Hello ". $name .",\nYour password is $pass and your username is $user
\nBest of luck to you in all your appointments tommorrow :-)
\nWarm Regards\n\nROBERT RAM\n+6013 308 4321";
mail($to,$subject,$body,$header);
echo "Your e-mail has been sent";
}
else
{
echo "You need to sign up first.";
}
}
else
{
echo "invalid email";
}
}
else
{
echo "Please enter your email address & click the Submit button";
}
}
die()
?>
</p>
</form>
</body>
</html>