Jump to content

limit of 5 variables.. Need to add more, please help!


lou28

Recommended Posts

Hi,

 

I have a form 3 fields in it and I am using this php code to process the form:

 

<?php

$sender = $_POST["email"];

$sentfrom = "From: $sender";
$to = '[email protected]';
$name = $_POST["name"];
$text = $_POST["message"];


if(($sender=='')||($to=='')||($name=='')||($text==''))
					{ echo "<center><b>Please make sure you complete the form</b></center>"; }
				else {
					if(mail($to, $name, $text, $sentfrom, '-f'.$sender))
						{ echo "<center><b>Thank you for your enquiry, someone will respond to you as soon as possible.</b></center>"; } 
					else { echo "<center><b>Sorry, your email cannot be sent right now</b></center>"; }
				}
?>

 

However I want to add more fields but if I do I get an error returned telling me I can't have more than 5 variables in the 'mail' bit. If there a way to work around this? I am a php beginner and have tried everything I can think of!

 

Thanks

What other variables do you want to add? You can build the body out of many variables. Like so:

 

$text = $_POST['message'];
$firstname = $_POST['first_name'];
$dob = $_POST['dob'];

$body = <<<html
First Name: {$firstname}\n
Birthday: {$dob}\n\n
Message:\n
{$text}
html;

 

Then use $body in the place of $text in your mail() function.

Hope that makes sense.

Thanks for that, I have tried it, but I'm not receiving the email. No error comes up at all so I can't understand why.

Do you have any ideas?

 

<?php

$sender = $_POST["email"];

$sentfrom = "From: $sender";
$to = '[email protected]';
$name = $_POST["name"];
$companyname = $_POST["companyname"];
$telephone = $_POST["telephone"];
$text = $_POST["enquiry"];

$body = <<<html
Name: {$name}\n
Telephone: {$telephone}\n
Company Name: {$companyname}\n\n
Message:\n
{$text}
html;

				if(($sender==''))
					{ echo "<center><b>Please make sure you complete the form</b></center>"; }
				else {
					if(mail($to, $body, '-f'.$sender))
						{ echo "<center><b>Thank you for your enquiry, someone will respond to you as soon as possible.</b></center>"; } 
					else { echo "<center><b>Sorry, your email cannot be sent right now</b></center>"; }
				}



?>



Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.