Page 1 of 1

PHP Email Problem

Posted: Sun Sep 30, 2012 2:10 pm
by ianhaney
Hi

I have created a php forgotten password page but when I receive the forgotten password email, I only get the email address in the email and not the username and password, its not collecting the username and password data for some reason

The php coding is below in the forgottenpassword.php

Code: Select all

<?php
if($go == "1")
{
$connect = mysql_connect("host","username","password");
if (!$connect)
{
die("MySQL could not connect!");
}

$DB = mysql_select_db('databasename');

if(!$DB)
{
die("My SQL could not select Database!");
}
}

$Username = $_POST['username'];
$Email = $_POST['email'];
$Email1 = "@";
$Email_Check = strpos($Email,$Email1);
$Password = $_POST['password'];
$message_field = $_POST['username, password'];
$message = "$Email, $Username, $Password, $message_field";
?>
<?php
//These are the variables for the email 

$sendto = $_POST['email']; // this is the email address collected from the form 
$ccto = "ianhaney@irhwebsites.co.uk"; //you can cc it to yourself 
$subject = "Your Registration Details"; // Subject 
$message = "Email Address: " . $Email . "\n\n" . "Username: " . $Username . "\n\n" . "Password: " . $Password . "\n\n" . "$message_field";
$header = "From: ianhaney@irhwebsites.co.uk\r\n"; 
$header .= "Reply-to: ianhaney@irhwebsites.co.uk\r\n"; 
// This is the function to send the email 
mail($sendto, $subject, $message, $header, $message_field);
echo "Your password has been sent to ". $Email .".";
?>
Below is what the email comes out like

Email Address: ianhaney@irhwebsites.co.uk

Username:

Password:

Can someone help me please, been trying to solve this for a few hours now lol

Re: PHP Email Problem

Posted: Sun Sep 30, 2012 7:59 pm
by fady10
If you are using localhost, the mail function will not work.


Regards,
Fady Joseph
iFunny; The funniest blog ever ! funny comics and pictures

Re: PHP Email Problem

Posted: Sun Sep 30, 2012 11:31 pm
by ianhaney
Hi thank you for the reply

No I am not using localhost, I am connecting to the database I set up and it connects all ok

I have had a rough idea what it could be

I think it might be because in the html form I had below

Code: Select all

<form action="forgotpassword.php" method="post">
E-mail: <input type="text" name="email" size="24" border="0">
<br>
<input type="hidden" name="go" value="1" border="0">
<input type="submit" name="submitButtonName" value="Submit" border="0">
</form>
Could it be that the following was not in the form

Code: Select all

<input type="hidden" name="username" value="0" border="0">
<input type="hidden" name="password" value="0" border="0">
I have put them two lines in now and am going to see if it works

Re: PHP Email Problem

Posted: Sun Sep 30, 2012 11:35 pm
by ianhaney
I put the following lines in

Code: Select all

<input type="hidden" name="username" border="0">
<input type="hidden" name="password" border="0">
But is still not getting the data for some reason

my html form is below

Code: Select all

<form action="forgotpassword.php" method="post">
E-mail: <input type="text" name="email" size="24" border="0">
<br>
<input type="hidden" name="username" border="0">
<input type="hidden" name="password" border="0">
<input type="hidden" name="go" value="1" border="0">
<input type="submit" name="submitButtonName" value="Submit" border="0">
</form>
Not sure what else it could be

Any Ideas, sorry to be a pain, just well stuck on this bit