This is a discussion on Simple Form With mailto Function within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi All I have a simple form that should enable visitors to my website to send me feedback. I would ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi All
I have a simple form that should enable visitors to my website to send me feedback. I would also like to have visitors redirected to certain pages of my site depending on the success of the following - I am using something like: if (email_valid($from_email)) { mail($to_my_email, $subject, $message); // need soemthing to redirect to home page } else{ echo "email address invalid"; //how to redirect back to the form ?? } Is it also possible to enable users to attach a file and include it in their e-mail? Any help greatly appreciated, George |
|
|||
|
george wrote:
> Hi All > I have a simple form that should enable visitors to my website to send me > feedback. I would also like to have visitors redirected to certain pages of > my site depending on the success of the following - I am using something > like: > if (email_valid($from_email)) > { > mail($to_my_email, $subject, $message); > // need soemthing to redirect to home page > } > else{ > echo "email address invalid"; > //how to redirect back to the form ?? > } > Is it also possible to enable users to attach a file and include it in their > e-mail? > Any help greatly appreciated, > George > > It is usual for the user to want to know the mail was sent, so automatically forwarding them back to index.php might not be the best course of action, the header function will forward people to another page if you wish (see option 1) if(isset($_POST["submit")) { #If the form is submitted, process it: if(valid($from_email)) { #Option 1: Automatically send them elsewhere: header("Location: http://www.somewhere.com"); #Option 2: Tell them it was successful, let them click #to go to next page (and/or use a javascript timer to # forward them on): include 'woohoo_email_sent.php'; } else { #Form failed input: include 'error_email.php'; # (error_email will automatically show the form and fill # it with the results it recieved from $_POST/$_GET so # the user doesn't need to enter everything again } } else { #Show the original form, for inital input include 'form_email.php'; } Hope that helps, Anthony. |