General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 31st, 2002, 01:19 AM
adrian adrian is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 20 adrian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Redirect to new page after form submit

I'm trying to redirect visitors to a new page after they click on the submit button of a form but keep getting this error

Warning: Cannot add header information - headers already sent by (output started at /usr/home/xxxxxxxx_com/public_html/guestbook2.php:1) in /usr/home/xxxxxxxx_com/public_html/guestbook2.php on line 65

my script looks like this

<?
if ($_POST['enter_data']){
$date=date("Y-m-d");
$database_name = "xxxxx";
$dbh = mysql_connect("localhost","xxxxxx","xxxxx");
if (!mysql_select_db($database_name)) {
echo "Can't Select $database_name";

}

$sql = "insert into guestbook (date, name, country, email, comments)
values ('$date', '$name', '$country', '$email', '$comments')";
$res = mysql_query($sql,$dbh);
if (!$res) {
echo mysql_errno().": ".mysql_error ()."";
return 0;
}
header("Location:http://www.xxxxxxx.com/viewguestbook2.php");
exit;

}


?>

line 65 is the header line

header("Location:http://www.xxxxxxx.com/viewguestbook2.php");

Any help on where i am going wrong would be much appreciated. Thanks.

Reply With Quote
  #2  
Old July 31st, 2002, 01:49 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
this is because the headers have already been sent!

make sure the VERY first charcters in your php file is

<?php


make sure their isnt any whitespace, or carrage returns, otherwise you'll get errors.

also if you try that and your still having problems try removing these lines

echo "Can't Select $database_name";

and

echo mysql_errno().": ".mysql_error ()."";

as it maybe outputting for some reason?

Reply With Quote
  #3  
Old July 31st, 2002, 01:05 PM
adrian adrian is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 20 adrian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply Ben. I did everything you said but am still getting the same error.

Does anyone know of another way i can auto redirect to another page after the submit button has been pressed. I do not need to pass across any values or variables. The first script is just a guest book entry and then when the submit button is pressed i just want it to auto redirect to the view guestbook script.

Thanks for you time. Hope someone can help.

Reply With Quote
  #4  
Old July 31st, 2002, 08:05 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
try using meta tags?
<META HTTP-EQUIV="refresh" content="0;URL=index.php">

Reply With Quote
  #5  
Old August 2nd, 2002, 01:44 PM
adrian adrian is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 20 adrian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks again Ben. That did the trick.

Reply With Quote
  #6  
Old June 8th, 2010, 07:36 PM
abottBuGEmoto abottBuGEmoto is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2010
Location: USA
Posts: 4 abottBuGEmoto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 2 sec
Reputation Power: 0
Send a message via ICQ to abottBuGEmoto
Hi! Sorry!

Deals with lenders who charge up to 2,700 per cent interest have trebled in the past three years.Experts last night called on the Government to clamp down on “payday” lenders, blaming soaring bank charges and a decade of easy credit for their rise.They offer loans of up to ?1,000 for first-time applicants which are often paid into customers’ bank accounts within hours.Del this topic. Sorry!

Reply With Quote
  #7  
Old June 9th, 2010, 02:14 PM
abottBuGEmoto abottBuGEmoto is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2010
Location: USA
Posts: 4 abottBuGEmoto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 2 sec
Reputation Power: 0
Send a message via ICQ to abottBuGEmoto
Hi! Sorry!

Deals with lenders who charge up to 2,700 per cent interest have trebled in the past three years.Experts last night called on the Government to clamp down on “payday” lenders, blaming soaring bank charges and a decade of easy credit for their rise.They offer loans of up to ?1,000 for first-time applicants which are often paid into customers’ bank accounts within hours.Del this topic. Sorry!

Reply With Quote
  #8  
Old June 10th, 2010, 01:32 AM
abottBuGEmoto abottBuGEmoto is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2010
Location: USA
Posts: 4 abottBuGEmoto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 2 sec
Reputation Power: 0
Send a message via ICQ to abottBuGEmoto
Hi! Sorry!

Deals with lenders who charge up to 2,700 per cent interest have trebled in the past three years.Experts last night called on the Government to clamp down on “payday” lenders, blaming soaring bank charges and a decade of easy credit for their rise.They offer loans of up to ?1,000 for first-time applicants which are often paid into customers’ bank accounts within hours.Del this topic. Sorry!

Reply With Quote
  #9  
Old June 10th, 2010, 06:36 AM
abottBuGEmoto abottBuGEmoto is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2010
Location: USA
Posts: 4 abottBuGEmoto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 2 sec
Reputation Power: 0
Send a message via ICQ to abottBuGEmoto
Hi! Sorry!

Deals with lenders who charge up to 2,700 per cent interest have trebled in the past three years.Experts last night called on the Government to clamp down on “payday” lenders, blaming soaring bank charges and a decade of easy credit for their rise.They offer loans of up to ?1,000 for first-time applicants which are often paid into customers’ bank accounts within hours.Del this topic. Sorry!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Redirect to new page after form submit


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap