I am getting an error on my new submission form. Here is the error after submitting: Warning: mail() expects at most 5 parameters, 6 given in and here is my code: <?php $to = "test@test.com"; $from = "From: \n"; mail($to, $_POST["contact-name"], $_POST["contact-email"], $_POST["contact-subject"], $_POST["contact-message"], $from); ?> Obviously I have one too many parameters, but I don't know how to rewrite it to make it work. Thanks in advance. I am trying to learn php in greater detail, but this is frustrating as...
look at the ref page for mail() on php.net (http://www.php.net/manual/en/function.mail.php). There are 4 clear examples of usage. Hope it helps. -d-
Looking at your post, this is probably what you want to do. $content = "Name: " . $_POST["contact-name"] . "\n"; $content .= "Email: " . $_POST["contact-email"] . "\n"; $content .= "Subject: " . $_POST["contact-subject"] . "\n"; $content .= "Message: " . $_POST["contact-message"] . "\n"; mail($to, "Website form submission", $content);
Thanks Exam, that seemed to do the trick. How do I get the results to display in a more readable manner? Right now they come through compiled. I would almost like it to come through as displayed on the contact page seen here: http://www.newcomputer.ca/contact-us.php Thanks again for your help. I don't need the layout, but would like the spaces.
you can use "\t" for a tab space or just add the spaces. It's annoying but spaces only work in the middle of strings, not at the beginning of lines. Sarah
Thanks Sarah, I have been really surprised that there is not a 'return' function for the actual email display. The closest I can come is configuring it using \n and \t, but this get altered as the message, email etc... get shortened or extended.
You can format the message that is to be sent however you want. You could make it show up in your email as: --------------------------- Name: XXXX --------------------------- Email: XXXX --------------------------- Subject: XXXXX --------------------------- Message: XXX XXX XXX --------------------------- Just put it all in the content variable above. If your email reader is html compliant you could even format it better. If you want more help, you can post an example of how the email is displayed and how you would like it to be displayed. -d-
Thanks again exam, currently, the email comes to me as such: Name: test Email: Subject: Test Message: This is a test Here is the <php>: <?php $to = "test@test.ca"; $from = "From: \t"; $content = "Name: " . $_POST["contact-name"] . "\t"; $content .= "Email: " . $_POST["contact-email"] . "\t"; $content .= "Subject: " . $_POST["contact-subject"] . "\t\t"; $content .= "Message: " . $_POST["contact-message"] . "\t"; mail($to, "Website form submission", $content); ?> I would like to have it display as such: --------------------------- Name: XXXX --------------------------- Email: XXXX --------------------------- Subject: XXXXX --------------------------- Message: XXX XXX XXX --------------------------- Which is what you typed above. I have tried both the \n and \t and multiples of both, neither of which have worked.
If you do a return within the quoted string, that shows up as a return in the variable... so $message = $fromname . " sends the following link request"; $message = $message . " Link URL = ". $linkurl; $message = $message . " Site Name = " . $sitename; $message = $message . " Description = " . $description; $message = $message . " Return Link = " . $returnlinkurl; Code (markup): Gives me
Thanks Trance, but I am having problems with the email display, not the content. Thanks for the input, maybe I missed something in your post?
Sorry, not being clear In PHP, if you write a string as follows <?php $string="this appears on this line ---------------------------- but this appears on this line"; ?> Code (markup): and send it via email, it will be recieved as follows
Try something like this: $content = "\r\n------------------------------------\r\n"; $content .= "Name: " . $_POST["contact-name"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Email: " . $_POST["contact-email"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Subject: " . $_POST["contact-subject"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Message:\r\n" . $_POST["contact-message"] . "\r\n"; $content .= "------------------------------------\r\n"; mail($to, "Website form submission", $content);