Jump to content

Different between index.php and index.php?quizname=???


haku87

Recommended Posts

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 } ?>

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

}

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.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.