Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Form redirect on submission


PHP Form redirect on submission

Reply
  #1 (permalink)  
Old 12-14-03, 01:46 PM
RJDavison RJDavison is offline
New Member
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Form redirect on submission

This subject has probably been flogged to death, but as a PHP newbie its giving me a bit of grief.

Its a simple form redirect on submission. Ive used a piece of code ive found and have altered is slightly for my own use.

Ive read many artices on the subject and think im in the right area, but cant seem to get the syntax right within the code. Im using the:

header("Location:http://www.xxxxxxx.com/index.php"

command. Below is my code so far.

<?php

if ($submit) {

if ($customerName <= "")
$message = "Please enter your name.";
else if ($customerEmail <= "")
$message = "Please enter your email address.";
else if ($customerMessage <= "")
$message = "Please insert your message.";

if ($message)
echo ($message);
else {
mail("webmaster@turkeybrain.co.uk",
"Form Results",
"$customerName submitted the following message

Subject: $subject
Operating System: $operatingsystem
Browser: $browser
Message: $customerMessage",
"From: $customerName <$customerEmail>");

echo ("Thank you for submitting your message. A representative will contact you shortly if necessary.");
die();
}

}

?>

Any direction where to add the script would be helpful. I have experimeted but get the 'headers already sent' error message
Reply With Quote
  #2 (permalink)  
Old 12-14-03, 03:33 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post


Try...

echo header ("Location: www.xxxx.com");

?>

See what happens.
Reply With Quote
  #3 (permalink)  
Old 12-15-03, 01:30 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Originally Posted by mdhall
Try...

echo header ("Location: www.xxxx.com");

?>

See what happens.
why echo ?
just header("Location: file.php"); is enough ..
also it is important to know that headers are always sent first before any output .. so if you want to use header use it before any echo/print ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #4 (permalink)  
Old 12-15-03, 07:03 AM
jv2222 jv2222 is offline
The Freshmaker
 
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Dont forget you need header ("Location: http://www.etc.com");
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)

Last edited by jv2222; 12-15-03 at 07:06 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 03:06 AM
PHP Upload Form Help tsb PHP 19 12-15-03 07:09 PM
redirect on form submit simone PHP 11 11-25-03 12:01 PM
PHP script that uploads and emails the form. ./n00b3 PHP 5 11-24-03 03:16 PM
PHP Triad/Upload form eddyvlad PHP 6 10-06-03 11:17 PM


All times are GMT -5. The time now is 07:33 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.