SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking passing variables between forms

    In my application there are 3 files. My files are linked in following way.

    shop.htm-> order.php ->query.php

    I want to use shop.htm variables and text boxes values in query.php file. Which is not directly linked with shop.htm file. How can I pass variables and control value to query.php file. Please help me.

    Thanks

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Use sessions, or use hidden fields that contain the values from shop.htm in the form of order.php.

    And use the search funtion of this forum, because this exact question has been asked and answered many times.

  3. #3
    SitePoint Guru rageh's Avatar
    Join Date
    Apr 2006
    Location
    London, Formerly Somalia
    Posts
    612
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by archkhare View Post
    In my application there are 3 files. My files are linked in following way.

    shop.htm-> order.php ->query.php

    I want to use shop.htm variables and text boxes values in query.php file. Which is not directly linked with shop.htm file. How can I pass variables and control value to query.php file. Please help me.

    Thanks
    Put the code below in the order.php file. Make sure that you change the field names to match what you have in shop.htm. These code snippet first checks that fields are not empty, then it puts them in hidden form fields in order.php file. When you hit the submit buttom, your form fields will be submitted to query.php.

    I hope that helps.


    Code PHP:
    <?php
    if(!empty($_POST['field_one']) && 
    	!empty($_POST['field_two']) && 
    	!empty($_POST['field_three']) {
     
    	$field_one = $_POST['field_one'];
    	$field_two = $_POST['field_two'];
    	$field_three = $_POST['field_three'];
    ?>
    <form name='form' method='post' action='query.php'>
      <input type='hidden' name='field_one' value='<?php echo $field_one; ?>'>
      <input type='hidden' name='field_two' value='<?php echo $field_two; ?>'>
      <input type='hidden' name='field_three' value='<?php echo $field_three; ?>'>
       <input type='submit' value='Submit Order'>
    </form>
    <?php
    }else{
    	die("All fields must be filled. <a href='javascript:history.go(-1)'>Please go back</a> and try again.");
    	}
    ?>
    ------------------

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your answer.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •