0

How would I use two actions?

<form id="myForm" action="form.php","form1.php" method="GET">

Does this work? Now I have 2 actions. how to connect 2 pages using php? plz guide me

4
Contributors
3
Replies
24
Views
3 Years
Discussion Span
Last Post by Bachu
0

hi a simple solution to that is when the user click submit direct the user to your form.php and after the process in form.php is completed redirect the data from form.php to form1.php. you can use several approch to achieve this the most simple one is use GET to pass the data from form to form1 using the url which will look like this

form1.php?name=Michael Jordan&age=100

and another way is to use session like

form.php
<?php
session_start();

$name=$_SESSION['Sess_name'] = $_GET['name'];
$age=$_SESSION['Sess_age'] = $_GET['age'];

?>


 form1.php

    <?php 
    session_start();

   echo $_SESSION['Sess_name'];
   echo $_SESSION['Sess_age'];


    ?>

Edited by ehpratah: TYPO

0

Hi,
This <form id="myForm" action="form.php","form1.php" method="GET"> dont work.
But you can use two submit buttons in same form.

HTML

<form id="myForm" action="form.php" method="GET">
    .....
    <input type="submit" value="Action 1" name="act1" />
    <input type="submit" value="Action 2" name="act2">
</form>

When you submit a form, unset variables will evaluate false.
PHP form.php

if(isset($_GET["act1"]))
{
    ... Code for action 1
}
if(isset($_GET["act2"]))
{
    ... Code for action 2
}
This topic has been dead for over six months. 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.