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

Recommended Answers

All 3 Replies

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'];


    ?>

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.