aladiyat23 Posted June 30, 2006 Share Posted June 30, 2006 Hi everyone... I'm trying to change this form to go to a url on submit instead of echoing a message... Here's the code... the echo script is at the bottom. What do I have to change on this code as well as my form script in my html page? ???Any help would be GREATLY appreciated. :)<?phpif(isset($_POST['submit'])) { $to = "..."; $subject = "..."; $name = $_POST['requiredname']; $email = $_POST['requiredemail']; $bname = $_POST['requiredbname']; $city = $_POST['requiredcity']; $state = $_POST['requiredstate']; $zip = $_POST['requiredzip']; $headers = "From: $email \r\n"; //Day Phone Number: $day1 = $_POST['requiredday1']; $day2 = $_POST['requiredday2']; $day3 = $_POST['requiredday3']; //Eve Phone Number: $eve1 = $_POST['eve1']; $eve2 = $_POST['eve2']; $eve3 = $_POST['eve3']; //Other Phone Number: $other1 = $_POST['other1']; $other2 = $_POST['other2']; $other3 = $_POST['other3']; //Fax Phone Number: $fax1 = $_POST['fax1']; $fax2 = $_POST['fax2']; $fax3 = $_POST['fax3']; //Comments: $comments =$_POST['requiredcomments']; $body = "From: $name\nE-Mail: $email\nBusiness Name: $bname\nLocation: $city, $state, $zip\nDaytime Phone: $day1-$day2-$day3\nEvening Phone: $eve1-$eve2-$eve3\nOther Phone: $other1-$other2-$other3\nFax: $fax1-$fax2-$fax3\nComments: $comments"; mail($to, $subject, $body, $headers); echo "Your message has been sent to ... Thank you for your inquiry. One of our friendly sales staff will be in touch with you soon";} else { echo "An error has occured. Please fill out the form and try again";}?> Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/ Share on other sites More sharing options...
Buyocat Posted June 30, 2006 Share Posted June 30, 2006 I take it you want to change the forms action dynamically? If not I suppose you could just go to the form open it up in an editor and change it to whatever you desire...If I was right then I would either A)[code]if (!isset($_POST['submit'])){// display the form here you can mix in the HTML / PHP and add have the action created dynamically}[/code]or B) configure your server so that it processes HTML files for PHP first, which is a good idea anyway imo, and then you can just put the PHP for the action in that file. If you can create a .htaccess file then it is pretty easy to do... I can look it up for you if you can't find it on Google.EDITThis thread seems to cover the apache stuffhttp://www.phpfreaks.com/forums/index.php/topic,98964.0.html Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/#findComment-51247 Share on other sites More sharing options...
aladiyat23 Posted June 30, 2006 Author Share Posted June 30, 2006 Thanks for the help... I'm sorry I don't understand. How will putting the php inside the html redirect to a specific url on submit? Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/#findComment-51248 Share on other sites More sharing options...
xyn Posted June 30, 2006 Share Posted June 30, 2006 Basically if you wanted to click Submit then it redirects to another page/location use this:[color=red]EDIT:Put this at the bottom instea dof echoing the thx message, it'll submit your email first...[/color]echo '<META HTTP-EQUIV="REFRESH" CONTENT="[color=red]3[/color];URL=[color=blue]http://www.URL.co.uk/page.htm[/color]">';[color=red]3[/color] - Seconds before redirecting...[color=blue]URL [/color] - the new location... Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/#findComment-51249 Share on other sites More sharing options...
Buyocat Posted June 30, 2006 Share Posted June 30, 2006 Maybe I didn't understand you... Do you want the form, when the submit button is pressed, to process in a different script than the one it created in? If so that was what I tried to answer above. If you just want the user to be redirected to a new page, such as index or something, the do the following.[code]header("Location: ./index.php"); // OK that will send them to index.php in the current directory[/code]I hope you can take it from here, keep in mind that you cannot echo anything or display any HTML before you use header(). Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/#findComment-51250 Share on other sites More sharing options...
aladiyat23 Posted June 30, 2006 Author Share Posted June 30, 2006 awesome, thanks buyocat... thats exactly what i wanted to do... works now, thanks!!! :-* Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/#findComment-51253 Share on other sites More sharing options...
aladiyat23 Posted June 30, 2006 Author Share Posted June 30, 2006 hey xyn, i tried your answer too, but it just redirected the page when it loaded. Thanks for the suggestion though! Quote Link to comment https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/#findComment-51256 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.