abcdabcd Posted March 13, 2008 Share Posted March 13, 2008 This is what my script looks like, the script is doing some other things such as appending a code to the url. I don't know anything about php and had somebody create this script. The only problem is that it's redirecting to fast and not appending the code every time. <? $xxxx = $_POST['xxxx']; header("Location: http://xxxx.com/xxxx?sub=$xxxx"); ?> The coder had advised me: Replace header("Location: http://THE FINAL WEBSITE.COM"); ?> With <meta http-equiv="refresh" content="3;url=YOUR URL"> That's what I did and I got an "error on line 1" Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/ Share on other sites More sharing options...
revraz Posted March 13, 2008 Share Posted March 13, 2008 It's HTML Either echo it or bring it out of PHP echo "<meta http-equiv='refresh' content='3;url=YOUR URL'>"; Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491571 Share on other sites More sharing options...
zszucs Posted March 13, 2008 Share Posted March 13, 2008 or $url = 'http://yoururl.com'; header('Refresh: 3; URL="' . $url . '"'); Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491585 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 It's HTML Either echo it or bring it out of PHP echo "<meta http-equiv='refresh' content='3;url=YOUR URL'>"; If I bring it out of php, will the code that I'm appending to the url still work like that? Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491592 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 or $url = 'http://yoururl.com'; header('Refresh: 3; URL="' . $url . '"'); So it would be like this: <? $xxxx = $_POST['xxxx']; $url = 'http://yoururl.com?sub=xxxxx'; header('Refresh: 3; URL="' . $url . '"'); Thanks for everybodys replies! Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491603 Share on other sites More sharing options...
revraz Posted March 13, 2008 Share Posted March 13, 2008 Sure, but you would have to start PHP again. So probably easier to just echo it. It's HTML Either echo it or bring it out of PHP echo "<meta http-equiv='refresh' content='3;url=YOUR URL'>"; If I bring it out of php, will the code that I'm appending to the url still work like that? Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491607 Share on other sites More sharing options...
PFMaBiSmAd Posted March 13, 2008 Share Posted March 13, 2008 If the value is not available when the php code starts executing, it won't be present on the end of the URL. PHP code and PHP data is not asynchronous. External data either exists at the time the code starts or it does not exist. Putting a delay in the php code or in the redirect won't change anything. You need to find out why the value is not present and fix that issue or do it a different way. My guess is that this value is an optional header that the browser supplies and the browser is simply not supplying it on the visit when it does not get appended to the URL. Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491611 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 If the value is not available when the php code starts executing, it won't be present on the end of the URL. PHP code and PHP data is not asynchronous. External data either exists at the time the code starts or it does not exist. Putting a delay in the php code or in the redirect won't change anything. You need to find out why the value is not present and fix that issue or do it a different way. My guess is that this value is an optional header that the browser supplies and the browser is simply not supplying it on the visit when it does not get appended to the URL. I see what you're saying so I'm not going to put the delay in. I'm not sure what the problem could be. I'm getting the code from a form in html. Here's the code being used on the 1st page. <div id="apDiv2">Enter Code<br> <form name="formcode" id="formcode" method="post" action="http://xxxxx/code_forward.php"> <input size="6" maxlength="3" value="" name="code" id="code" type="text"> </form> After the user types in the code they are forwarded to a webpage on a different domain which is code_forward.php. Then the code on here is: <? $formcode = $_POST['formcode']; header("Location: http://xxxx.com/xxxx?sub=$formcode"); ?> There is a possibility that my reporting could have messed up and didn't record the code. With that line of code should it record it every time? Does that look like a good effective way of accomplishing what I'm doing? Thanks! Any help would be appreciated! Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491620 Share on other sites More sharing options...
PFMaBiSmAd Posted March 13, 2008 Share Posted March 13, 2008 The name of the form field is "code" The post variable would be $_POST['code'] Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491631 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 The name of the form field is "code" The post variable would be $_POST['code'] The name of the form field is "formcode" isn't it, below? <form name="formcode" id="formcode" method="post" action="http://xxxxx/code_forward.php"> the line that you're referring which has "code" in it is referring to the name of the submit button correct? Since it starts with, <input size= It does work sometimes. Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491638 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 I'm going to go ahead and try it out with the delay. I remember having this problem doing the same exact thing with javascript, and when it was instant the code wouldn't append most of the time but, when I slowed it down to 3 seconds it worked every time. Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491639 Share on other sites More sharing options...
BlueSkyIS Posted March 13, 2008 Share Posted March 13, 2008 The name of the form field is "code" The post variable would be $_POST['code'] Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491642 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 Sure, but you would have to start PHP again. So probably easier to just echo it. It's HTML Either echo it or bring it out of PHP echo "<meta http-equiv='refresh' content='3;url=YOUR URL'>"; How can I bring it in/out of php, actually there is some HTML that I would like to add in here. I need to add a loading animation. Thanks! If I bring it out of php, will the code that I'm appending to the url still work like that? Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491647 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 The name of the form field is "code" The post variable would be $_POST['code'] well that's strange, then how does it work sometimes? I've seen the numbers in my reporting, I use the time of day to test with so I know I put the numbers in there for testing. Anyway I just change anything called "code", to "formcode". Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491650 Share on other sites More sharing options...
abcdabcd Posted March 13, 2008 Author Share Posted March 13, 2008 seems that's what the problem was, I tried 3 different times and it worked every time without the delay. Thanks! Link to comment https://forums.phpfreaks.com/topic/96021-how-can-i-create-a-delay-in-a-php-redirect/#findComment-491687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.