473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple variable passing isn't working

5 New Member
I acquired a very basic redirect script from:
[HTML]http://www.minisitegal lery.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 2031
Dormilich
8,658 Recognized Expert Moderator Expert
the php code seems strange, try
[PHP]<?php echo $_GET['data']; ?>[/PHP]
Nov 18 '08 #2
nassausky
5 New Member
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.locati on.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 Recognized Expert Moderator MVP
$_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
nassausky
5 New Member
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 Recognized Expert Moderator MVP
OK, how are you calling this script?
Nov 20 '08 #6
nassausky
5 New Member
I was calling it inside the body of the html file.
Nov 24 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
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
4035
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 enough to convert a favorite PHP script to work on an ASP.NET site. I'm experimenting with simple example scripts that will help me learn how to implement each "piece" of the puzzle.
5
22971
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 post example code from a book to a newsgroup? 2) The program crashes as it tries to free memory and I would like to know the best way to correct THIS section of the code. By assigning current = head, current now points to the first structure in...
5
1021
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
5572
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 first request and I return failure or a session ID which I store, and further requests should have the session ID. isn't there a sim[ple way to do it? I keep reading about HTTP handlers. isn't there a simpler way to implement it?
20
6957
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 = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
27
4607
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 = $doc->loadHTMLFile("./aBasicSearchResult.html"); if ( $res == true ) { $zip = $doc->getElementById('zipRaw_id')->value; if ( 0 != $zip ) {
4
1515
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 who experience. (For some reason I have to implement Array not ArrayLists) Below are the simple following code: Dim Array() As String Dim intCounter As Integer
24
6320
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 have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
41
2077
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 *two;
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.