Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limits on Forms using Mail?

Status
Not open for further replies.

JMaximus

Programmer
Oct 23, 2004
9
US
Hi everyone,

I was referred from the Via forums (been a longtime member there) because I had a PHP question there most couldn't answer.

After ten years of HTML, I finally learned how to do forms without using Outlook to send the message. Yeah, I know - slow learner.

I'm impressed with PHP but seem to get an error when I have more than four "items" being mailed to my email.

My site is: I have the "Send Question" part working... here is my code for the .php page (without the html headers:


<?php

$errors = "";
if (!$_POST['name'])
$errors .= "Your name is required - Please try again\n";
if (!$_POST['question'])
$errors .= "No question was submitted - Please try again\n";
if (!$_POST['emph'])
$errors .= "Either your email address or phone number is required - Please try again\n";
if ($errors)
echo $errors;
else {

$recipient = 'jamie@fourpeaksplanning.com';
$name = $_POST['name'];
$question = $_POST['question'];
$reach = $_POST['emph'];

$subject = "Website Question from $name";
$quests = "The question: $question";
$reachme = "How to contact: $reach";

mail($recipient, $subject, $reachme, $quests);

$errors = "Thank you $name for using our services. <br> <br>You will be contacted within the next 24 hours.";

echo $errors;
}
?>


I use to have the name of the sender being mailed to me but I kept getting syntax errors, parse erros, etc (yeah - I know you'd like exact error messages but I didn't write them down last night). So know the name of the sender is in the subject line.

When I had five items being mailed, I'd swap the last item with the first, the second, the third... and it was always an error with the last one. And I'm gotten errors when I tried to go with six items, saying it expected five. That could be a problem for my "Request Apptment" button. How do I get around that?

Thanks in advance for all your help.
 
To be honest, until you provide the exact text of the error, it's difficult if not impossible to help you.

Parse errors, for example, often do not occur at the line where PHP reports them, because the line where the interpreter reports the error is not necessarily the place where the program bug exists. Rather, the line reported is the place where the interpreter got confused by your code. The actual program bug can be many lines earlier in your code.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
You have the call to the mail function incorrect.

In your case, it should be something like:
Code:
$body = 'The question: ' . $question . "\n";
$body .= 'How to contact: ' . $reach . "\n";
$from .= '<Your Name>your@email.addr.ess';

mail($recipient, $subject, $body, $from);

Please see for more information.

Ken
 
Thanks for the help.

Ken - the code you presented cleared up my misunderstanding of PHP.

My site is good-to-go. Thanks very much.

Time for me to learn some other neat PHP tricks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top