0

Hi There,

For some reason I need my form to be submitted twice (in one go).

Is there any way to do that instead of submitting once go back and submit again?

My form based on PHP and Javascript...

Thanks!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by nirwannursabda
0

mmm... it's little weird but unique

//you can do your action twice but with same parameter like this
<!---------------------- example.php --------------------->
<form id="one" name="one" method="get" action="action.php">
<table>
    <tr>
        <td>Id</td>
        <td>
        <input type="text" name="id" maxlength="30"/>            
        </td>
        </tr>
    <tr>
        <td>Name</td>
        <td>
        <input type="text" name="name" maxlength="30"/>          
        </td>
    </tr>
    <tr>
        <td>
                <input type="submit" value="Save"/>      
        </td>
    </tr>
</table>
</form>



<!------------------------ action.php ----------------------->
<?php
session_start();

$param1 = $_GET['id'];
$param2 = $_GET['name'];

/*................... your submit action ..................

*/

/*if session twice isset, you can do second action to send your parameter with method get */
if(!isset($_SESSION['twice'])){
    $_SESSION['twice'] = 1;
    ?>

    <script type="text/javascript">
        window.location = "<?php echo $_SERVER['PHP_SELF']."?id=".$param1."&name=".$param2; ?>"
    </script>
    <?php
}
else{
    $SESSION['twice'] = 2;
    unset($_SESSION['twice']);
}
?>


// Or if you still want to submit form with button twice, you can use ajax for submit form without refresh
// and you can submit form as many you want without lost your input
// sorry for my word and i'm newbie in php

Edited by Nick Evan: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.