Jump to content

Auto Filling Form


thelee

Recommended Posts

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.email .can someone help me ?

 

here is the order form 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"> </p>
 <p align="center" class="style10"> </p>
 <p align="center" class="style10"> </p>
 <p align="center" class="style10"> </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> </td>
               <td><input type="submit" name="Submit" value="Order">     <input name="Reset" type="reset" id="Reset" value="Reset"></td>
         </tr>
       </table>
 </div>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
 <p> </p>
</form>
</body>
</html>
<?PHP } ?>

 

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

Link to comment
Share on other sites

the same way you stored the session user name is the same way you are going to store all other session data that you want to use.

 

you can query your database with the select query and the store the results in a session for each and every data that you want to use after that call that sessio9n where ever you want to use it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.