how to pass variable value from first form to third form

Discussion in 'PHP' started by kharearch, Jan 19, 2008.

  1. #1
    I have 3 files.
    Edit_del_bank.htm->edit_del.php->edit_bank.php file

    I want to send ‘bank’ listbox value from edit_del_bank.htm to edit_bank.php. But it’s not being passed. ?
    I have no submit button on mid file ‘edit_del.php’

    how can I pass 'bank' listbox value from edit_del_bank.htm to edit_bank.php file
    1) Code of edit_del.php file is –
    <body>
    <?php
    $n1=$_POST['bank'];
    echo $n1;
    ?>
    there is no php file is attached with action
    <form name="form1" method="post" action="">
    <input type="hidden" name='bank' value="<?php echo $n1;?>">
    </form>

    <?php
    if(isset($_POST['EDIT']))
    {
    header ("location:edit_bank.php");
    }
    ?>
    </body>


    2) code of edit_bank.php file is –
    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    echo "hello";
    echo $_POST['bank'];
    $result = mysql_query("SELECT * FROM bank where name ='" . $_POST[bank] . "'");

    ?>
    <form name="form1" method="post" action="update_bank.php">
    <p>name:
    <input type="text" name="name" value="<?php echo $row['name']; ?>">
    </p>
    <p>
    <select name="category" value="<?php echo $row['category'];?>">
    </select>
    </p>
    <p>Toll_Free_Number:
    <input type="text" name="toll_free_number" value="<?php echo $row['toll_free_number']; ?>">
    </p>

    <p><br>
    <input type="submit" name="Submit" value="Submit">
    <?php
    mysql_close($con);

    ?>
    </p>
    </form>
    </body>

    Please help me to do this.
     
    kharearch, Jan 19, 2008 IP
  2. alemcherry

    alemcherry Guest

    Best Answers:
    0
    #2
    You have many options:

    1. have them in hidden fields in second form.
    2. Save them in database after first page is submitted and keep on adding the rest as they are submitted,
    3. Save them in sessions and clear when you add it to db finally.

    This is simple task, I am not giving any sample code.
     
    alemcherry, Jan 19, 2008 IP
  3. glasglow

    glasglow Active Member

    Messages:
    926
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    <form name="form1" method="post" action="">

    The action is blank.. So when you press submit it goes where?

    I would _get the information and put it into a hidden field and pass it on to the next invisibly.
     
    glasglow, Jan 19, 2008 IP
  4. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    I am making them hidden in second form. but it is not being passed. Please can you check my code.
     
    kharearch, Jan 19, 2008 IP
  5. Denn

    Denn Peon

    Messages:
    76
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would recommend you to pass them on in either a hidden form or by SESSION.

    If you save them in a database, you give the database extra work.
     
    Denn, Jan 19, 2008 IP
  6. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    I am calling edit.php file through

    header ("location:edit_bank.php");

    can't I pass 'bank' variable value to edit.php without using action.
     
    kharearch, Jan 19, 2008 IP
  7. Denn

    Denn Peon

    Messages:
    76
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You should try something like this then:

    header("location:edit_bank.php&bank=$bank");

    and then on the bank_edit.php page you could get the variable:

    <?php
    $bank = $_GET['bank'];
    ?>
     
    Denn, Jan 19, 2008 IP