php redireck based with timer set

Discussion in 'PHP' started by rontdu, Sep 5, 2009.

  1. #1
    actually i want to make php code where action="" tag will depends upon 2 things,they are
    (i) submit button
    (ii) and timer
    here i can make a code which only works upon submit button.
    the code is given bellow:

    --------------------------------------------------
    index.html
    -----------
    <html>
    <body>
    <form name='form1' method='post' action='receive.php'>
    <!-- here a timer nedded -->

    <tr> (1) 1+1=?</br></tr>
    <tr><input type='radio' name='ques' value='1'> 1</br></tr>
    <tr><input type='radio' name='ques' value='2'> 2</br></tr>
    <tr><input type='radio' name='ques' value='3'> 3</br></tr>
    <tr><input type='radio' name='ques' value='4'> 4</br></tr>

    <input name='Submit' type='submit' value='submit'>
    </form>
    </body>
    </html>

    ----------------
    receive.php
    ----------------
    <?php
    $ans=$_POST['ques'];
    echo "You Enter: "."$ans";
    ?>
    --------------------------------------------------

    now, i want to make a timer that if i can't press submit button then the timer will automatically make a alert box(show:Your limited time is complete) after 1 minute.then pressing ok button its automatically take the action="receive.php" work and show the output. But if i press the submit button within 1 minute then this timer will do nothing......
    [ i think i need js for alert box: if anyone know this please submit the code after check with my submitted code ]
    :D:D:D
     
    rontdu, Sep 5, 2009 IP
  2. Sporsho

    Sporsho Peon

    Messages:
    153
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think building a timer with php is not a good idea. You can use javascript timer, which will run on client browser.
    you can develop a funciton like this
    function timer()
    {
    setTimeout("funct()",60000);
    }
    function funct()
    {
    alert("Your limited time is complete");
    //do other things
    // you can disable the form input using document.getElementById("YOUR ID").disabled="disabled";
    // so that your visitor cant answer after the time
    }
     
    Sporsho, Sep 5, 2009 IP
  3. rontdu

    rontdu Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    @ Sporsho, please sent me the full code after checking.....i am waiting..
    [N.B: U can use my code as base,then for timer u can use new things]

    :D:D:D
     
    rontdu, Sep 5, 2009 IP
  4. rontdu

    rontdu Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    oowww....i got it...its now working :
    its automatically redirect after 10 sec if i don't take any response:

    ----------------------------------------
    <?php header('Refresh:10; url=receive.php');?>
    <html>
    <body>
    <form name='form1' method='post' action='receive.php'>
    <!-- here a timer will -->

    <tr> (1) 1+1=?</br></tr>
    <tr><input type='radio' name='ques' value='1'> 1</br></tr>
    <tr><input type='radio' name='ques' value='2'> 2</br></tr>
    <tr><input type='radio' name='ques' value='3'> 3</br></tr>
    <tr><input type='radio' name='ques' value='4'> 4</br></tr>

    <input name='Submit' type='submit' value='submit'>

    </form>
    </body>
    </html>
    ----------------------------------------
     
    rontdu, Sep 5, 2009 IP