473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Simple variable passing isn't working

I acquired a very basic redirect script from:
[HTML]http://www.minisitegallery.com/blog/php-javascript-countdown-script-with-timezone-setting.html[/HTML]
which is supposed to count down to a specified date and switch to a new webpage after that date. The original coder had included this quote with the code:


WARNING…

This script is not created with proper error trapping. If it’s not working, then something is wrong with your implementation. And I can’t provide support for it either. Oh yeah, it’s poorly documented to.

So use at in anyway you want but don’t bug me with it.

It uses PHP to acquire the date from the server and javascript to keep refreshing the live countdown timer. Ok the javascript counter works fine but the redirect isn't working.

Expand|Select|Wrap|Line Numbers
  1. document.location.href = "<?=$_GET['data']?>";
  2. alert("New Redirect Page="+ document.location.href);
  3.  
The output to this alert box showings the varbiable is equal to
http://www.oldwebpage.com

Then I click the OK button to the alert and for some reason it's substituting an odd redirect location as follows:

http://www.oldwebpage.com/www.newwebpage.com

Not sure why it is attaching both variables during runtime.
Nov 18 '08 #1
7 2003
Dormilich
8,658 Expert Mod 8TB
the php code seems strange, try
[PHP]<?php echo $_GET['data']; ?>[/PHP]
Nov 18 '08 #2
the php code seems strange, try
[PHP]<?php echo $_GET['data']; ?>[/PHP]
OK I tried that but it didn't work. It looks like the original coder intended on assigning the javascript variable document.location.href with the value being parsed from the input file. My javascript is weak and am I wrong to say that your method just prints out the text during runtime.
Nov 18 '08 #3
acoder
16,027 Expert Mod 8TB
$_GET['data'] would get the data parameter passed in the URL, e.g. for
http://someurl/index.php?data=somesite/test.php, it would output "somesite/test.php". In JavaScript, the correct variable/object to set is window.location.href. Also, use full URLs to go to another site.
Nov 19 '08 #4
Thanks.. I understood both.. If you try out that simple script from the website you will see that it doesn't seem to work as you explained. I realize where it is getting the post data from and also have tried the full URLS and it still is keeping the old URL and appending the new URL as one string for some reason...
Nov 20 '08 #5
acoder
16,027 Expert Mod 8TB
OK, how are you calling this script?
Nov 20 '08 #6
I was calling it inside the body of the html file.
Nov 24 '08 #7
acoder
16,027 Expert Mod 8TB
No, I meant the actual code that you're using to call the script.
Nov 24 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Friday | last post by:
Sorry if this is the wrong group. I tried to find the one I thought would be most relevant. I'm an old PHP guy, who knows little about asp and NOTHING about asp.net, but need to learn at least...
5
by: disco | last post by:
I am working on this example from a book "C Primer Plus" by Prata 4th edition - p. 672. There is no erata on this problem at the publisher's website. 1) Is it a violation of copyright laws to...
5
by: Tim::.. | last post by:
How do I transfer the value of one variable in one sub to another variable in another sub??? Thanks
6
by: Jerome Cohen | last post by:
I need to implement a simple application that listens for web requests on a well-known URL, grab the request , which is an XML document, and send as respnse an XML document. each client sends a...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
4
by: Armand | last post by:
Hi Guys, I have a set of array that I would like to clear and empty out. Since I am using "Array" not "ArrayList", I have been struggling in finding the solution which is a simple prob for those...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
41
by: SkyBlue | last post by:
Hi, can someone explain why the following simple C code segfaulted? I've stared it for 30mins but couldn't find the problem. Thx in advance #include <stdio.h> int main() { char *one; char...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.