SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    9
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    auto filling form

    i have create a order form and the username is autofill based on the session login username.but i do not know how i can autofill the address or email .can someone help me ?

    here is the order form code
    Code:
    <?php
    error_reporting(E_ALL);
    session_start(); 
    if(!isset($_SESSION['MM_Username'])) {
    echo "You are not logged in or registered / Click <a href='login.php'>Here</a> to login !";
    } else {
    ?>
    <style type="text/css">
    <!--
    body { background:#000; background-attachment:fixed; background-repeat:no-repeat; color:#fff; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; }
    table { background:#000; border:1px solid white;}
    -->
    </style>
    </head>
    
    
    
    <body>
    <p><b>Welcome <?PHP echo $_SESSION['MM_Username']; ?> !</b></p>
    <form name="form1" method="post" action="order_product_process.php">
      <p align="center" class="style10">&nbsp;</p>
      <p align="center" class="style10">&nbsp;</p>
      <p align="center" class="style10">&nbsp;</p>
      <p align="center" class="style10">&nbsp;</p>
      <p align="center" class="style10">Order Form:</p>
      <div align="center">
                    <table width="500" >
                      <tr>
                                    <td width="239">Username</td>
                                    <td width="249"><?PHP echo $_SESSION['MM_Username']; ?></td> 
                      </tr>
                      <tr>
                                    <td>Address</td>
                                    <td><textarea name="address" id="address"></textarea></td>
                      </tr>
                      <tr>
                                    <td>Phone</td>
                                    <td><input name="phone" type="text" id="phone" maxlength="30"></td>
                      </tr>
                      <tr>
                                    <td>IC Number</td>
                                    <td><input name="ic" type="text" id="ic" maxlength="30"></td>
                      </tr>
                      <tr>
                                    <td>Product Name</td>
                                    <td><input name="product_name" type="text" id="product_name" maxlength="30"></td>
                      </tr>
                      <tr>
                                    <td>Quantity</td>
                                    <td>      <input name="quantity" type="text" id="quantity" maxlength="30"></td>
                      </tr>
                      <tr>
                                    <td>&nbsp;</td>
                                    <td><input type="submit" name="Submit" value="Order">    <input name="Reset" type="reset" id="Reset" value="Reset"></td>
                      </tr>
                    </table>
      </div>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
    </form>
    </body>
    </html>
    <?PHP } ?>
    Code:
    CREATE TABLE `order` (
    `order_id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(30) NOT NULL DEFAULT '',
    `address` varchar(30) NOT NULL DEFAULT '',
    `phone` varchar(30) NOT NULL DEFAULT '',
    `ic` varchar(30) NOT NULL DEFAULT '',
    `product_name` varchar(30) NOT NULL DEFAULT '',
    `quantity` int(30) NOT NULL DEFAULT '0',
    PRIMARY KEY (`order_id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=latin1

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Well if you have this information stored in the table already, why are you looking to re-submit it through a form, potentially allowing them to change it again without affecting your table?

    You can use this though once you have pulled your information from your table:
    Code:
    <textarea name="address" id="address" value = "<?php echo $propAddress; ?>"></textarea>

  3. #3
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you are trying to get
    order form
    pre filled shipping details from user details
    (and allow to make some changes,which many websites do allow)
    then
    you have query for data from table again using id or username in session and populate the details in text as show above.

    select fields from table where username=sanitize_if_required($_sesssion['username']);
    then fields are available to use in form...

    Sorry if i got your question wrong.


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
  •