execute form on refresh

Discussion in 'PHP' started by DeFacto, May 7, 2008.

  1. #1
    Hi,

    i've made code that needs to refresh page if result is set:

    
    if($result){
    echo "<meta http-equiv=\"refresh\" content=\"0;URL=del.php\">";
    
    Code (markup):
    and i need to execute form on that refresh

    
    <form action=" ">
    <input type="hidden" name="upern" value="<?php echo $name; ?>">
    <input type="hidden" name="uperc" value="<?php echo $sname; ?>">
    </form>
    
    Code (markup):
    anybody could help me with that, please?
     
    DeFacto, May 7, 2008 IP
  2. Noodles25

    Noodles25 Active Member

    Messages:
    75
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #2
    You'd probably need to do this with javascript, rather than php

    e.g. put this somewhere after the form (assuming that it's the first form on your page)
    
    <script>
    document.form[0].submit();
    </script>
    
    Code (markup):
     
    Noodles25, May 7, 2008 IP
  3. DeFacto

    DeFacto Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for reply, but that code

    if($result){
    echo "<meta http-equiv=\"refresh\" content=\"0;URL=trinti.php\">";
    echo '<form action=" " name="MyForm">';
    echo '<input type="hidden" name="upern" value="'; echo $name; '">';
    echo '<input type="hidden" name="uperc" value="'; echo $sname; '">';
    echo '</form>';
    echo '<script>
    document.MyForm.submit();
    </script>';
    
    Code (markup):
    doesn't give me what i want.
    i will try to make it more clear, when i am doing that refresh

    
    echo "<meta http-equiv=\"refresh\" content=\"0;URL=trinti.php\">";
    
    Code (markup):
    i need those variables $name and $sname to be posted. and i would like to avoid js.
     
    DeFacto, May 7, 2008 IP
  4. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sorry, then you can not do it. JS is the only way. setting an onload event then the rest. sorry man.
     
    NatalicWolf, May 7, 2008 IP
  5. DeFacto

    DeFacto Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thank for reply, it means that i need to change whole code.
     
    DeFacto, May 7, 2008 IP