swartsz 7 Posted June 28, 2005 Share Posted June 28, 2005 i have a little question about PHP i hope someone here can answer for me. i have been working on a little mailscript for my website and came up with this: <?php $naam="Name: $_POST[naam]\n \n"; $email="Email address: $_POST\n \n"; $bericht="Message: \n $_POST[bericht]\n"; mail('info@swartsz.com','mail from swartsz.com',$naam . $email . $bericht); echo("Your message has been sent"); ?> right now when you press submit it sends you to a blank page thanking you for sending me a message, but how can i make it so it will send you to the homepage of my website? thanks! Quote Link to post Share on other sites
firefly2442 0 Posted June 28, 2005 Share Posted June 28, 2005 (edited) Are you asking whether the code is correct or once the email has been sent how to do a redirect to the homepage? I would just put a link like this after "your message has been sent". echo "<a href='/'>Ok</a>"; You could also do an automatic redirect so that after a couple seconds it goes to the homepage. I'm not sure on the specifics of that though. Hope this helps. Edited June 28, 2005 by firefly2442 Quote Link to post Share on other sites
swartsz 7 Posted June 28, 2005 Author Share Posted June 28, 2005 (edited) Are you asking whether the code is correct or once the email has been sent how to do a redirect to the homepage? I would just put a link like this after "your message has been sent". echo "<a href='/'>Ok</a>"; You could also do an automatic redirect so that after a couple seconds it goes to the homepage. I'm not sure on the specifics of that though. Hope this helps. ← a bit of both actually. the problem is when you press the submit button it keeps sending me to a blank page, even after i inserted the code you suggested. to have a closer look at the contact page and the problem, go here: http://www.swartsz.com/contact.html so i am kinda lost with this one. Edited June 28, 2005 by swartsz Quote Link to post Share on other sites
firefly2442 0 Posted June 29, 2005 Share Posted June 29, 2005 Hmm, I think the contact page is ok. Can you post the code to "verwerk.php"? All that I get when I look at that source is... <a href=\http://www.swartsz.com/index.html\></a> Quote Link to post Share on other sites
swartsz 7 Posted June 29, 2005 Author Share Posted June 29, 2005 Hmm, I think the contact page is ok. Can you post the code to "verwerk.php"? All that I get when I look at that source is... <a href=\http://www.swartsz.com/index.html\></a> ← here is the code of the form: <form name="form1" method="post" action="verwerk.php"> <table width="466" height="274" border="0"> <tr> <td width="123" valign="top"><font color="#CCCCCC" size="1" face="Verdana">Name:</font></td> <td width="238" valign="top"><input name="naam" type="text" size="30"></td> </tr> <tr> <td valign="top"><font color="#CCCCCC" size="1" face="Verdana">Email address:</font></td> <td valign="top"><input name="email" type="text" size="30"></td> </tr> <tr> <td valign="top"><font color="#CCCCCC" size="1" face="Verdana">Message:</font></td> <td valign="top"><textarea name="bericht" cols="30" rows="10"></textarea></td> </tr> </table> <p align="center"> <input type="submit" name="Submit" value="Submit"> </p> </form> Quote Link to post Share on other sites
firefly2442 0 Posted June 29, 2005 Share Posted June 29, 2005 Yep, but can you post the verwerk.php code? The one that you first posted? Is that all that's to it? Quote Link to post Share on other sites
swartsz 7 Posted June 29, 2005 Author Share Posted June 29, 2005 yes, that is all there is. Quote Link to post Share on other sites
firefly2442 0 Posted June 30, 2005 Share Posted June 30, 2005 Here is what I just setup for my website. It's kind of rough right at the moment but it should give you a basis for what to do. Hope this will help ya. ------------ email.php ----------- <br> <center><big><p>Have a question, comment, or suggestion? Send RivetCode an email!</p></big></center> <br> <br> <FORM method=POST ACTION="../php/php_email/send.php"> Your Name: <br> <input type="text" size="60" name="f_name"></input> <br> Your Email Address: <br> <input type="text" size="60" name="f_emailaddress"></input> <br> Subject: <br> <select name="f_subject"> <option value="RivetCode Question" selected>Question <option value="RivetCode Comment">Comment <option value="RivetCode Suggestion">Suggestion <option value="RivetCode Support">Support <option value="RivetCode Bug Report">Bug Report <option value="RivetCode Other">Other </select> <br> Message: <br> <textarea name="f_message" rows="20" COLS="90"></textarea> <br> <br> <input type="submit" value="Send Email"> </form> ------- send.php ------- <html> <title>Sending Email...</title> <body> <?php $name = $_POST['f_name']; $emailaddress = $_POST['f_emailaddress']; $subject = $_POST['f_subject']; $message = $_POST['f_message']; $mailto = "username@domain-name.com"; $email_body = "From: "; $email_body .= $name . "\n"; $email_body .= "Email: "; $email_body .= $emailaddress . "\n"; $email_body .= "\n" . $message; if(mail($mailto, $subject, $email_body)) echo "Thank you for the email, " . $name . "."; else echo "Error sending email, please try again later."; ?> <br> <br> <center><a href="/"><big><big>Ok</big></big></a></center> </body> </html> Quote Link to post Share on other sites
DonMiguel 11 Posted June 30, 2005 Share Posted June 30, 2005 (edited) why not just toss in a small javascript to redirect the site in a few seconds while giving the option of manual? <script type="text/javascript"> setTimeout('countdown()', 3000) Â function countdown() { Â top.location = 'index.php' } </script>[/code] just stick that after the </head> tag and before the <body> Edited June 30, 2005 by DonMiguel Quote Link to post Share on other sites
swartsz 7 Posted June 30, 2005 Author Share Posted June 30, 2005 thanks guys for your help. I think i have it sorted now with the help of a new script and form. Now it sends the user back to the homepage when the message was sent succesfully and to a error page when something went wrong. again thanks a lot for your help! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.