Jump to content

Recommended Posts

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. :)

<?php
if(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\n
E-Mail: $email\n
Business Name: $bname\n
Location: $city, $state, $zip\n
Daytime Phone: $day1-$day2-$day3\n
Evening Phone: $eve1-$eve2-$eve3\n
Other Phone: $other1-$other2-$other3\n
Fax: $fax1-$fax2-$fax3\n
Comments: $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";
}
?>
Link to comment
https://forums.phpfreaks.com/topic/13301-echo-to-url-or-redirect-help/
Share on other sites

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.

EDIT
This thread seems to cover the apache stuff
http://www.phpfreaks.com/forums/index.php/topic,98964.0.html
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...

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().
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.