Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP Email Problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP Email Problem

Postby ianhaney » Sun Sep 30, 2012 2:10 pm

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
ianhaney
New php-forum User
New php-forum User
 
Posts: 27
Joined: Tue May 01, 2012 12:30 pm

Re: PHP Email Problem

Postby fady10 » Sun Sep 30, 2012 7:59 pm

If you are using localhost, the mail function will not work.


Regards,
Fady Joseph
iFunny; The funniest blog ever ! funny comics and pictures
User avatar
fady10
New php-forum User
New php-forum User
 
Posts: 10
Joined: Mon Sep 24, 2012 6:58 pm

Re: PHP Email Problem

Postby ianhaney » Sun Sep 30, 2012 11:31 pm

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
ianhaney
New php-forum User
New php-forum User
 
Posts: 27
Joined: Tue May 01, 2012 12:30 pm

Re: PHP Email Problem

Postby ianhaney » Sun Sep 30, 2012 11:35 pm

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
ianhaney
New php-forum User
New php-forum User
 
Posts: 27
Joined: Tue May 01, 2012 12:30 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.