Reply
redirect from after submission
Old 07-10-2004, 11:11 AM redirect from after submission
Experienced Talker

Posts: 34
have a php form that works perfectly, then i wanted to set it up to do a redirect after the form is processed, but i am having a hard time getting it so work: I used the header function with no luck,. I researched online and it stated that the header function must not have whitepaces before it or a echo statement. I have a check setup so that if a user leave info blacnk it will print a message to the screen. So how do I have it check and if it passess the check then my the user be redirect to another page.

listed below is the script


<?php

if($_POST[check]== "true") {

$errmsg="";

if ($_POST[sender_name]== "") {
$errmsg .= "<font color=red>Enter your name</font><BR />";
}

if ($_POST[sender_email]== "") {
$errmsg.= "<font color=red>Enter your email</font><BR />";
}

if ($_POST[sender_phone]== "") {
$errmsg.= "<font color=red>Enter your phone number</font><BR />";
}

if ($_POST[OS]== "") {
$errmsg.= "<font color=red>Enter your Operating System</font><BR />";
}

if ($_POST[message]== "") {
$errmsg.= "<font color=red>Please, give us a description of your problem</font><BR />";
}
if ($errmsg!="") {
echo $errmsg;
}

else
$to = "support@nucitytech.com";
$msg = "Sender's Name: $_POST[sender_name]\n";
$msg .= "Sender's Email:$_POST[sender_email]\n";
$msg .= "Sender's Phone: $_POST[sender_phone]\n";
$msg .= "Sender's OS:$_POST[OS]\n";
$msg .= "Message: $_POST[message]\n";
$subject = "From: NuCityTech Website";
$mailheaders = "From: Nucitytech Support Page\n";
$mailheaders .= "Reply-To:$_POST[sender_email]\n";
mail($to, $subject, $msg, $mailheaders);

header("Location: services.html");
}

?>

Any thoughts?

Last edited by cedtech23 : 07-10-2004 at 11:53 AM. Reason: Where to place header function
cedtech23 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-10-2004, 01:18 PM
cmonkey's Avatar
Ultra Talker

Posts: 268
you could just echo a javascript statement:

PHP Code:
echo "<script language='JavaScript'> window.location='PAGE.HTM'; </script>"
that's what I usually do
cmonkey is offline
Reply With Quote
View Public Profile
 
Old 07-10-2004, 01:33 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Not sure if this will actually work, but might be worth a go as I have something similar: -

PHP Code:
//CHANGE THIS
mail($to$subject$msg$mailheaders);

header("Location: services.html");
}

//TO THIS
if(mail($to$subject$msg$mailheaders)) {

header("Location: services.html");

}


Regards
Ian
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-10-2004, 01:39 PM
Veter's Avatar
Super Talker

Posts: 136
Quote:
<META HTTP-EQUIV="refresh" content="5;URL=http://internet-tips.net/About/about.htm">
Will redirects the page after 5 sec.
__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-10-2004, 11:27 PM problem solved
Experienced Talker

Posts: 34
I used the following method

mail($to, $subject, $msg, $mailheaders);

echo "<meta http-equiv=\"Refresh\" content=\"1;URL=http://nucitytech.com/thankyou.htm\">";

I will try the other methods later tonight. Thanks again, I love PHP
cedtech23 is offline
Reply With Quote
View Public Profile
 
Old 07-11-2004, 04:55 AM
troatie's Avatar
Skilled Talker

Posts: 64
the idea is fine....just put your one echo state after everything....

so change to:
PHP Code:
if ($errmsg=="")
{
  
// do all mailing and redirecting....
} else {
   echo 
$errmsg;

Also make sure there's a "{" after the "else"
__________________
Troatie.com
troatie is offline
Reply With Quote
View Public Profile Visit troatie's homepage!
 
Reply     « Reply to redirect from after submission
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 4.51088 seconds with 12 queries