Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-11-2012, 05:16 PM   #1
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
php form header location problem

hi

i've got a form on a webpage http://www.domain.com/contact.htm but when it is submitted rather than the page redirecting to the thanks.htm page, the thanks.htm page just shows up on top of the contact.htm page. any idea what i'm doing wrong? btw the form does send the email its just this redirection that is a problem. below is the code i'm using.


if($send)
{header("Location: http://www.domain.com/thanks.htm");
exit();
}
else
{print "We encountered an error sending your mail"; }
exit();
}

anyone got any ideas?

thanks in advance
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 05:25 PM   #2
Zoxxa
Confirmed User
 
Zoxxa's Avatar
 
Industry Role:
Join Date: Feb 2011
Location: Ontario, Canada
Posts: 1,026
Hard to tell with what you posted, would have to see the form and rest of the page(s).

I cleaned this up a bit:

Code:
if(isset($send)) {
	header("Location: http://www.domain.com/thanks.htm");
} else {
	echo "We encountered an error sending your mail";
}
 
// Everything below this is useless unless there is more code not shown.
exit();
}
__________________
[email protected]
ICQ: 269486444
ZoxEmbedTube - Build unlimited "fake" tubes with this easy 100% unencoded CMS!
Zoxxa is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 05:28 PM   #3
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
I'm just off to bed but i'll give that a try in the morning. Thanks for your help
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 05:30 PM   #4
Zoxxa
Confirmed User
 
Zoxxa's Avatar
 
Industry Role:
Join Date: Feb 2011
Location: Ontario, Canada
Posts: 1,026
The code should do the same thing, I didn't really change anything overly important, just easier to read. Would have to see the rest of your stuff to see the issue.
__________________
[email protected]
ICQ: 269486444
ZoxEmbedTube - Build unlimited "fake" tubes with this easy 100% unencoded CMS!
Zoxxa is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 05:42 PM   #5
helterskelter808
So Fucking Banned
 
Industry Role:
Join Date: Sep 2010
Posts: 3,405
Actually it's good practice to have an exit after a header redirect, as in the code he posted, and you removed it. Also why did you add isset?

Last edited by helterskelter808; 09-11-2012 at 05:51 PM..
helterskelter808 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 05:51 PM   #6
Zoxxa
Confirmed User
 
Zoxxa's Avatar
 
Industry Role:
Join Date: Feb 2011
Location: Ontario, Canada
Posts: 1,026
Quote:
Originally Posted by helterskelter808 View Post
Actually it's good practice to have an exit after a header redirect, as in the code he posted, and you removed it.
Yep, I wasn't really thinking.
__________________
[email protected]
ICQ: 269486444
ZoxEmbedTube - Build unlimited "fake" tubes with this easy 100% unencoded CMS!
Zoxxa is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 06:48 PM   #7
EDepth
Confirmed User
 
Join Date: Nov 2005
Location: Seattle, WA
Posts: 510
need to see entire code...
__________________
ICQ: 275335837
EDepth is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 06:56 PM   #8
shake
frc
 
Industry Role:
Join Date: Jul 2003
Location: Bitcoin wallet
Posts: 4,663
Haven't see the exact problem before - but strange things happen if you have anything (even a space or line-break) before the header redirect. It has to be the FIRST thing sent to the browser.
__________________
Crazy fast VPS for $10 a month. Try with $20 free credit
shake is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 07:24 PM   #9
AdultEUhost
ORLY?
 
AdultEUhost's Avatar
 
Industry Role:
Join Date: Oct 2005
Location: NL & US
Posts: 2,579
Quote:
Originally Posted by Zoxxa View Post
Hard to tell with what you posted, would have to see the form and rest of the page(s).

I cleaned this up a bit:

Code:
if(isset($send)) {
	header("Location: http://www.domain.com/thanks.htm");
} else {
	echo "We encountered an error sending your mail";
}
 
// Everything below this is useless unless there is more code not shown.
exit();
}
Hey Ian,

$send is probable $_POST['send'] unless you have register_globals = on which you really shouldnt :-)

Edit; Just thought of that $send might be the return of the mail(); function, in that case ignore my reply.

You say you want to include the thanks.html code at the top of your form, yet you use a header('location: ') statement. You are probably looking for an include('url'); statement no?
__________________
ICQ: 267-443-722 / leon [at] adulteuhost [dotcom]

Nominated for an XBIZ Award as "Webhost of the Year" in 2007, 2012, 2013 and 2014

Last edited by AdultEUhost; 09-11-2012 at 07:33 PM..
AdultEUhost is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2012, 11:12 PM   #10
KillerK
Confirmed User
 
Join Date: May 2008
Posts: 3,406
He/She probably has

if (Form is Good)
$send = 1;
else
$send = 0;

or something to that effect above this code?

So you wouldn't want to do isset, the if ($send) is better
KillerK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2012, 12:49 AM   #11
CHMOD
Confirmed User
 
CHMOD's Avatar
 
Join Date: Jun 2003
Posts: 1,697
Quote:
Originally Posted by roly View Post
hi

i've got a form on a webpage http://www.domain.com/contact.htm but when it is submitted rather than the page redirecting to the thanks.htm page, the thanks.htm page just shows up on top of the contact.htm page. any idea what i'm doing wrong? btw the form does send the email its just this redirection that is a problem. below is the code i'm using.


if($send)
{header("Location: http://www.domain.com/thanks.htm");
exit();
}
else
{print "We encountered an error sending your mail"; }
exit();
}

anyone got any ideas?

thanks in advance


Your first if($send) doesn't do anything. Like Zoxxa pointed out, it has to be either if(isset($send)) or if("$send" == "something")

__________________
Sell our Silicone Dolls and make big money!

Our website:
https://www.sexdolls-shop.com/

Signup:
http://www.sexdollscash.com/sliiing/registration.php

Contact:
[email protected]
CHMOD is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2012, 01:34 AM   #12
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
hi guys

thanks very much for all the advice. i've added the isset although that didn't help my problem. i'm not sure if i explained it very well. upon succesful form submit i want the surfer to be redirecte3d to the thanks.htm page. however currently rather than redirect the thanks.html page weirdly lays on top of the contact htm page so that you can see both in the same window.

this is the code i'm using

PHP Code:
error_reporting(E_ALL); ini_set('display_errors''On'); 
ini_set("sendmail_from""[email protected]"); 
$email_to "[email protected]"
$from $_REQUEST['email'];
$headers "From: $from"
$email_subject "Web Contact Data"

$name $_POST['name'];  
$email $_POST["email"];  
$email_message $_POST["message"]; 
$from $_POST["email"]; 
$phone $_POST["phone"];

$company $_POST["company"];


$email_message "We have received the following message:\n\nName: " $name "\r\nEmail: " $email "\r\nPhone: " $phone "\r\nCompany: " $company "\r\nMessage: " $email_message;



if(
$from == '') {print "You have not entered an email, please go back and try again";} 
else { 
if(
$name == '') {print "You have not entered a name, please go back and try again";} 
else { 
$send mail($email_to$email_subject$headers$email_message"[email protected]"); 

if(isset(
$send)) 
{
header("Location: http://www.mydomain.com/thanks.html");
exit();

else 
{echo 
"We encountered an error sending your mail, please notify [email protected]";} 
exit();
}

one other problem that i can't see where its wrong is that it i get the error "Notice: Undefined variable: phone in /home/admin/domains/mydomain.com/public_html/contact.php on line 19 however as far as i can see i've defined what phone is?

can anyone see what's wrong with my code?

thanks in advance

Last edited by roly; 09-12-2012 at 01:38 AM..
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2012, 01:55 AM   #13
CHMOD
Confirmed User
 
CHMOD's Avatar
 
Join Date: Jun 2003
Posts: 1,697
Your code is not secure by the way. It may cause you issues. People could use your email script to spam others using your server. Your have to filter your POST variables

Here is what you are looking for:

if($send === TRUE)
{header("Location: http://www.mydomain.com/thanks.html");
exit();
}
__________________
Sell our Silicone Dolls and make big money!

Our website:
https://www.sexdolls-shop.com/

Signup:
http://www.sexdollscash.com/sliiing/registration.php

Contact:
[email protected]
CHMOD is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2012, 05:11 AM   #14
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
thanks, that still gave the same error, not sure why. i've now given up and i'm modifying someone elses form (which is more secure). thanks again
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2012, 05:43 AM   #15
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Roly, your error is not an error, it's a notice. You can turn down the error reporting level in php.ini. Your header redirect isn't working because the error is outputting before the header() line, and you cannot send anythign to the output buffer before header().

ini_set('display_errors', 'Off');

Last edited by k0nr4d; 09-12-2012 at 05:44 AM..
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-12-2012, 01:27 PM   #16
roly
Confirmed User
 
Join Date: Aug 2002
Posts: 1,844
Quote:
Originally Posted by k0nr4d View Post
Roly, your error is not an error, it's a notice. You can turn down the error reporting level in php.ini. Your header redirect isn't working because the error is outputting before the header() line, and you cannot send anythign to the output buffer before header().

ini_set('display_errors', 'Off');
hi konrad

understood, although that variable wasn't getting passed which was the problem. i added the error reporting to try and help diagnose my problems. anyhow i gave up on this and i've got something else working now.

thanks anyway
roly is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.