PHP form sending email, but not input information

Ruth.Adele

New Member
Hi, i'm a newbie at PHP, i learned this particular form at a short course i attended - so i'm not exactly sure whats going on...
It works - to a point.
The email comes through to the specified address, but all the information that the client inputs on the website is missing.
Can anyone help me!?
Thanks

This is my HTML:


<div id="membershipform">
<form id="c-form" name="form1" method="post" action="emailform.php">

<p>
<label>Name</label><br />
<input type="text" name="name" id="name" /><br />
<label>Email</label><br />
<input type="text" name="sendersemail" id="sendersemail" /><br />
<label>Phone Number</label><br />
<input type="text" name="phone" id="phone" /><br />
<label>Postcode</label><br />
<input type="text" name="postcode" id="postcode" /><br />
<input type="submit" name="Submit" id="button" value="Submit" /></p>
</form>
</div>


And this is my PHP form:


<body>
<?php
if($sentemail == "2"){
include("sorry.html");
}else{
$num = $sentmessage + 1;
$email = "
Name:\t$name\n
Email:\t$sendersemail\n
Phone Number:\t$phone\n
Postcode:\t$postcode\"";
$to = "[email protected]";
$subject = "New Membership";
$mailheaders = "From: $sendersemail\n";
$mailheaders .= "Reply-To: $sendersemail\n\n";
mail ($to, $subject, $email, $mailheaders);
include("thanks.html");
$to = "$sendersemail";
$subject = "Your membership has been confirmed";
mail($to, $subject, $email, $mailheaders);
}
?>
</body>


Thanks again! Please help! :confused:
 

Ruth.Adele

New Member
This is what i get in the email:


Name:

Email:

Phone Number:

Postcode: "




There is also no 'From' email address in the inbox fields.
Hope this helps...
 

Ruth.Adele

New Member
Can anyone point me in the right direction to find help?? I need to fix this and i have no idea how to...
 
Last edited:

anna

New Member
I'm sorry, not familiar with PHP at all but I would suggest google searching your issue.

Sorry to respond with no solution, but no one else was helping. Good luck!
 

Ruth.Adele

New Member
i just got a hold of an old friend who helped me out - i haven't tested it yet, but he said to put $_POST['name'] instead of $name and so on for all the input fields. so i'll give that a go and see if it works.
 

v2Media

Member
Give the following a go for your php processing:-

Code:
<?php
//vars
$email_sent = false;
$subject = 'New Membership';
$from_address = '[email protected]';
$to_address = '[email protected]';
$url_success = 'sorry.html';
$url_fail = 'thanks.html';

//form processing
if(!empty($_POST['Submit'])) {
	
	$member_email = (!empty($_POST['sendersemail'])) ? $_POST['sendersemail'] : '--';
	$member_name = (!empty($_POST['name'])) ? $_POST['name'] : '--';
	$member_phone = (!empty($_POST['phone'])) ? $_POST['phone'] : '--';
	$member_postcode = (!empty($_POST['postcode'])) ? $_POST['postcode'] : '--';
	
	$message = "
	Name:\t$member_name\n
	Email:\t$member_email\n
	Phone Number:\t$member_phone\n
	Postcode:\t$member_postcode\n";
	
	$mailheaders = "From: $from_address\r\n";
	$mailheaders .= "Reply-To: $member_email\r\n";
	mail($to_address, $subject, $message, $mailheaders);
	
	$mailheaders = "From: $from_address\r\n";
	$mailheaders .= "Reply-To: $to_address\r\n";
	$subject = "Your membership has been confirmed";
	$email_sent = mail($member_email, $subject, $email, $mailheaders);
	
	if($email_sent) include_once($url_success);
	else include_once($url_fail);
	
}

?>
 
Top