| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | Need some help with a contect form Hey everyone. I am working on a site and I need to get a contact form working. It sounds dumb but I have it on the page, but what do I need to do to get it to work. Its done in dreamweaver </style> <form name="form1" method="post" action=""> <table width="450" border="0"> <tr> <td width="73">Name</td> <td width="367"><label> <input name="name" type="text" id="name"> </label></td> </tr> <tr> <td>Email</td> <td><label> <input name="email" type="text" id="email"> </label></td> </tr> <tr> <td>Comment</td> <td><label> <textarea name="comment" id="comment"></textarea> </label></td> </tr> <tr> <td> </td> <td><label> <input name="Submit" type="submit" class="button" value="Send"> <input name="Submit2" type="reset" class="button" value="Clear"> </label></td> </tr> </table> </form>
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #3 (permalink) |
| Senior Member | any ideas on a easy way to get it done?
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #5 (permalink) |
| Senior Member | I have PHP on my server. I found a script I can use and it will send mail... but no subject or message. And it sends from my server and not a email I specify. Maybe there is something missing <html> <head><title>PHP Mail Sender</title></head> <body> <?php /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */ $name = $HTTTP_POST_VARS ['name']; $email = $HTTP_POST_VARS['email']; $comment = $HTTP_POST_VARS['comment']; /* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */ if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif ($subject == "") { echo "<h4>No subject</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */ elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?> </body> </html>
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #6 (permalink) |
| NamePros Regular | This setting in phpini needs to be changed - sendmail_from Changing it changes what address appears in the from address. You need to have a form in order to send mail. If you don't want to, edit : $name = $HTTTP_POST_VARS ['name']; $email = $HTTP_POST_VARS['email']; $comment = $HTTP_POST_VARS['comment']; to $subject = " - Subject - "; $email = " - To Email - "; $message = " - To Message - "; Edit the content inside. |
| |
| | #7 (permalink) |
| Senior Member | I think I have been working on this to much tonight . I need to give it a rest and try again tommorow. I just need this http://www.kitcar.ws/test.html (just a test) To function. Like I said I can get it to send, but with no message and with a server email. So if anyone can help it would be great
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #8 (permalink) |
| NamePros Regular | Sorry, missing out on the form posted. Heres a fix : Code: <form name="form1" method="post" action=""> <table width="450" border="0"> <tr> <td width="73">Name</td> <td width="367"><label> <input name="name" type="text" id="name"> </label></td> </tr> <tr> <td>Email</td> <td><label> <input name="email" type="text" id="email"> </label></td> </tr> <tr> <td>Subject</td> <td><label> <input name="subject" type="text" id="subject"> </label></td> </tr> <tr> <td>Message</td> <td><label> <textarea name="message" id="message"></textarea> </label></td> </tr> <tr> <td> </td> <td><label> <input name="Submit" type="submit" class="button" value="Send"> <input name="Submit2" type="reset" class="button" value="Clear"> </label></td> </tr> </table> </form> Code: /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$name = $HTTP_POST_VARS ['name'];
$email = $HTTP_POST_VARS['email'];
$message = $HTTP_POST_VARS['message'];
$subject = $HTTP_POST_VARS['subject'];
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>
|
| |
| | #9 (permalink) |
| Senior Member | Now im getting this Method Not Allowed The requested method POST is not allowed for the URL XXX/XXX.
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #10 (permalink) | |
| Domains my Dominion | Quote:
Also, if you are using third-party code make sure you understand the risk of E-mail injection: http://www.securephpwiki.com/index.php/Email_Injection
__________________ Buy now - MassDeveloper.com $500 | |
| |
| | #12 (permalink) |
| Senior Member | Thanks for everyones help. So does anyone have any idea of a simple script I can use. IM putting a site together as a favor to someone and dont really want to spend any money on it. This should have been simple and done by now..hhaha
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #13 (permalink) |
| Stud Sausage | This is my adapted version slipondajimmy, use it if you wish. PHP Code: Last edited by Matthew.; 01-01-2007 at 06:31 AM. |
| |
| | #14 (permalink) |
| Senior Member | thanks a bunch. Im still getting this though. I must be missing something Method Not Allowed The requested method POST is not allowed for the URL
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
| | #16 (permalink) | |
| NamePros Regular | Quote:
However, he asked for his contact form to be fixed with functionality. So I didn't make much changes to the script (how do i know what PHP version he has). Rename the file (the one Matthew provided) to *.php. | |
| |
| | #17 (permalink) |
| Senior Member | Thanks everyone. Its working fine now
__________________ Mascot Factory- Custom Plush, Promotional Plush, and Personalized Teddy Bears|The Squidget - The tiny travel trailer you build from plans| |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |