realife Posted December 25, 2010 Share Posted December 25, 2010 Hey, I have my contact form in my website working fine I'm just asking a simple question because I don't know so much about php and php syntax I have my html file calling this code below when i'm clicking on the submit button Just take a look at the last line when there is the 'echo' script I want it to go to this link, and instead it's just writing the link what is the right command/code that should i use? <? $subject="from ".$_GET['fName']; $headers= "From: ".$_GET['fEmail']."\n"; $headers.='Content-type: text/html; charset=UTF-8' . "\r\n"; mail("mymail@example.com", $subject, " <html> <head> <title> My Title </title> </head> <body> <br> ".$_GET['fName']. " <br> ".$_GET['fPhone']." <br> ".$_GET['fEmail']." <br><br> ".$_GET['pBody']." </body> </html>" , $headers); echo "http://avrikim123.co.cc/sent.html"; ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 25, 2010 Share Posted December 25, 2010 If you mean you want the user redirected after submission you should use a header redirect. You will however need to make sure there is no output sent to the browser before the header. Quote Link to comment Share on other sites More sharing options...
realife Posted December 25, 2010 Author Share Posted December 25, 2010 I need to know exactly what to write, i don't know to use PHP as i said, i don't know also the syntax I just need the command to open a new link ? Quote Link to comment Share on other sites More sharing options...
lastkarrde Posted December 25, 2010 Share Posted December 25, 2010 <? $subject="from ".$_GET['fName']; $headers= "From: ".$_GET['fEmail']."\n"; $headers.='Content-type: text/html; charset=UTF-8' . "\r\n"; mail("mymail@example.com", $subject, " <html> <head> <title> My Title </title> </head> <body> <br> ".$_GET['fName']. " <br> ".$_GET['fPhone']." <br> ".$_GET['fEmail']." <br><br> ".$_GET['pBody']." </body> </html>" , $headers); header("Location: http://avrikim123.co.cc/sent.html"); ?> Quote Link to comment Share on other sites More sharing options...
realife Posted December 25, 2010 Author Share Posted December 25, 2010 No, that's not working good, i'm getting error Warning: Cannot modify header information - headers already sent by (output started at /home/realife/domains//public_html/mavrikim/contact.php:2) in /home/realife/domains//public_html/mavrikim/contact.php on line 22 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 25, 2010 Share Posted December 25, 2010 If you mean you want the user redirected after submission you should use a header redirect. You will however need to make sure there is no output sent to the browser before the header. That would mean no markup and no whitespace at all can be sent prior to header(). Quote Link to comment Share on other sites More sharing options...
realife Posted December 25, 2010 Author Share Posted December 25, 2010 I don't know what output you talking about.. I just have my php file, and the html calling it: My form code in the HTML file: <form action="contact.php" method="get" enctype="multipart/form-data" id="form"> My form goes here <a href="#" onClick="document.getElementById('form').submit()"> <span class="style5"><input type="image" src="images/submit.jpg" /></span></a> </form> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 25, 2010 Share Posted December 25, 2010 (output started at /home/realife/domains//public_html/mavrikim/contact.php:2) "output started at line 2 of /home/realife/domains//public_html/mavrikim/contact.php" Quote Link to comment Share on other sites More sharing options...
the182guy Posted December 25, 2010 Share Posted December 25, 2010 You have blank line/new line at the top of your php script, that is causing the problem because that newline is getting sent to the browser before your php code is executed. Normally that would work but because you are setting a header (content-type) the error is thrown. No output can be sent to the browser before custom headers. Quote Link to comment Share on other sites More sharing options...
realife Posted December 25, 2010 Author Share Posted December 25, 2010 Solved! I guess you write, I'll never know why the blank line matter but thank you so much for helping me. Quote Link to comment Share on other sites More sharing options...
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.