haku87 Posted May 5, 2007 Share Posted May 5, 2007 What is the difference between index.php and index.php?quizname=???. Why my timer cannot work when i used index.php?quizname=??? and yet it work when i used index.php There is my javascript code : <?php function setTimer($seconds, $address){ ?> <script type="text/javascript"> var reqAry = new Array(); var cnt = <?php echo $seconds ?>; // 2 minutes convert to seconds if (location.search.length > 0) {requestForm = location.search.substr(1).split("&"); for (i=0; i<requestForm.length; i++) {tmp = requestForm[i].split("="); reqAry[tmp[0]] = tmp[1];} if (reqAry["h"] != "") {cnt = reqAry["h"] * 1;} // convert string to number } function showCount() { minutes = Math.floor(cnt / 60); sec = cnt - (minutes * 60); if (sec < 10) {sec = "0" + sec;} if (minutes < 10) {minutes = "0" + minutes;} document.f.c.value = minutes + ":" + sec; } function countdown() { if (cnt == 0) { window.location.href = "<?php echo $address ?>"; } else {cnt--; showCount(); _timer = setTimeout("countdown()", 1000); } } function updateTime(frm) { frm.h.value = cnt; } window.onload = showCount; var _timer = setTimeout("countdown()", 1000); // tick </script> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50162-different-between-indexphp-and-indexphpquizname/ Share on other sites More sharing options...
pocobueno1388 Posted May 5, 2007 Share Posted May 5, 2007 Because you have no code telling it what to do if the URL is "index.php?quizname=--". If it is working how you want on just index.php, what is the problem? If you did want to add code to make something happen when that url was type in, you could do something like this: if (isset($_GET['quizname'])){ //put code here } Quote Link to comment https://forums.phpfreaks.com/topic/50162-different-between-indexphp-and-indexphpquizname/#findComment-246311 Share on other sites More sharing options...
haku87 Posted May 6, 2007 Author Share Posted May 6, 2007 Ok. For Example. When i put in index.php?quizname=testingout. It supposed to fetch from database the time and question. However, for testing purpose. I put in the setTimer(60,"http://www.yahoo.com"); in the <head> tags. The timer start running when i visited index.php. However, using the same code, I type in index.php?quizname=testingout. The timer display Nah:Nah even though the javascript echo back look fine. Quote Link to comment https://forums.phpfreaks.com/topic/50162-different-between-indexphp-and-indexphpquizname/#findComment-246496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.