Jump to content

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


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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.