Jump to content

Need a form to be dynamically populated


trouble706

Recommended Posts

Hello,

I have a site that requires membership in order to receive information on plays that are available for usage. When a member views a play and wants more information, he/she is redirected to a form that should be submitted. I would like for the basic membership information name, etc. to be dynamically populated so that the member only has to select the particular play that they want information on.

I am not sure how to do this. Can someone point me in the right direction?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/142909-need-a-form-to-be-dynamically-populated/
Share on other sites

suppose a new user registered to become a member. You got user's details (name, address etc.) from registration form and saved in database.

 

Now, when this user logs in, views a play and wants more information, you redirect him to a form.

 

In this form file you can fetch user details you already entered in the database.

Echo this information in HTML part of the form.

 

e.g.

(i'm assuming you have user's id when he logs in)

<?php
$query = "SELECT * FROM users WHERE userId = ".$userId;
$resultSet = mysql_query($query, $link);        //-- $link is database connection link
$userData = mysql_fetch_array($resultSet);
?>
<html>
<head></head>
<body>
<form action="" method="post">
Name: <input type="text" name="userName" value="<?php echo $userData['userName']; ?>" />
Address: <input type="text" name="address" value="<?php echo $userData['address']; ?>" />
Question: <input type="text" name="question" value="" />
<input type="submit" name="submit" value=" Submit " />
</form>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.