Jump to content


Photo

echo to url or redirect help


  • Please log in to reply
6 replies to this topic

#1 aladiyat23

aladiyat23
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • Locationflorida

Posted 30 June 2006 - 02:35 PM

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

#2 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 30 June 2006 - 02:39 PM

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)
if (!isset($_POST['submit']))
{
// display the form here you can mix in the HTML / PHP and add have the action created dynamically
}
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...ic,98964.0.html
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#3 aladiyat23

aladiyat23
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • Locationflorida

Posted 30 June 2006 - 02:46 PM

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?



#4 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 June 2006 - 02:47 PM

Basically if you wanted to click Submit then it redirects to another page/location use this:

EDIT:
Put this at the bottom instea dof echoing the thx message, it'll submit your email first...


echo '<META HTTP-EQUIV="REFRESH" CONTENT="3;URL=http://www.URL.co.uk/page.htm">';

3 - Seconds before redirecting...
URL - the new location...



#5 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 30 June 2006 - 02:50 PM

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.
header("Location: ./index.php"); // OK that will send them to index.php in the current directory

I hope you can take it from here, keep in mind that you cannot echo anything or display any HTML before you use header().
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#6 aladiyat23

aladiyat23
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • Locationflorida

Posted 30 June 2006 - 02:51 PM

awesome, thanks buyocat... thats exactly what i wanted to do... works now, thanks!!! :-*

#7 aladiyat23

aladiyat23
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • Locationflorida

Posted 30 June 2006 - 02:53 PM

hey xyn, i tried your answer too, but it just redirected the page when it loaded. Thanks for the suggestion though!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users