| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Nov 2006
Posts: 89
|
form direct
i am using a simple php form i found , and wondering if any ones how to simply when the send button is pressed and the email is sent the user of the website it directed back to the home page. *form* <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. */ $email = 'YourAddr@YourMail.com'; $subject = $HTTP_POST_VARS['subject']; $message = $HTTP_POST_VARS['message']; /* 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> cheers |
|
|
|
|
|
#4 (permalink) |
|
Senior Member
|
<?php /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */ $email = 'YourAddr@YourMail.com'; $subject = $HTTP_POST_VARS['subject']; $message = $HTTP_POST_VARS['message']; /* 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)) { header("Location: yourpage.html"); echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?> <html> <head><title>PHP Mail Sender</title></head> <body> </body> </html> easiest way to do it in that jumbled mess. |
|
|
|
#6 (permalink) |
|
Registered User
Join Date: Nov 2006
Posts: 89
|
i need help with this again , sorry does any one know how to fix this problem. when some one uses the contact form and sends it. when i look at the email it does not say its from the person how sent it but from root@dubli.purplecloud.com. does any one know how to fix this so it says the person how accully sent it? thanks for any help |
|
|
|
#8 (permalink) |
|
Junkie[scum]
Join Date: Oct 2006
Location: location, location
Posts: 1,813
|
Form Validation With PHP decent script which can show you your errors ... ignore the fuckin use of tables |
|
![]() |