Jump to content

Archived

This topic is now archived and is closed to further replies.

aladiyat23

echo to url or redirect help

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";
}
?>

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites
awesome, thanks buyocat... thats exactly what i wanted to do... works now, thanks!!! :-*

Share this post


Link to post
Share on other sites
hey xyn, i tried your answer too, but it just redirected the page when it loaded. Thanks for the suggestion though!

Share this post


Link to post
Share on other sites

×

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.