proctk Posted July 23, 2006 Share Posted July 23, 2006 HiI have a form that is used to update registered users information. I want the form to populate with the users information from the database table so that they can see current info before updatingI use the below code to display the logged in regestered users information but I cannot figure out how to assign the users information to variables that i can set to equal form values.any help is greatcode to get users information[code=php:0]<?include 'db.php';$username = $_SESSION['username']; // note, if userid is not a numeric type column, then $userid must be quoted$query = "SELECT * FROM users WHERE username = '$username'";$result = @mysql_query($query);if(!$result){ trigger_error("<p>SQL ERROR:<br>".mysql_error()."<br>Query: $query</p>", E_USER_WARNING);}elseif(mysql_numrows($result) != 1){ trigger_error("<p>DB ERROR: There were multiple matches on this User ID</p>", E_USER_WARNING);}else // we got exactly one match on the User ID{ echo "<b><center>Database Output</center></b><br><br>"; // only 1 match, so we don't need a loop $row = mysql_fetch_assoc($result); extract($row, EXTR_PREFIX_ALL, "user"); mysql_close(); echo <<<END <b>$user_first_name $user_last_name</b><br>Date of Birth: $user_DOB<br><b>Address</b><br>Street Address: $user_Street_address<br>Other Mailing Information: $user_post_office_box<br>City: $user_city <br>Province: $user_province<br>Postal Code: $user_postal<br>Home Phone Number: $user_home_phone<br>Email Address: $user_email_address<br>Family Relationship: $user_familyRelationship<br><hr><br>END;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/ Share on other sites More sharing options...
448191 Posted July 23, 2006 Share Posted July 23, 2006 [quote author=proctk link=topic=101575.msg402121#msg402121 date=1153680368]I use the below code to display the logged in regestered users information [b]but I cannot figure out how to assign the users information to variables that i can set to equal form values.[/b][/quote]I don't understand the question. Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/#findComment-62479 Share on other sites More sharing options...
proctk Posted July 23, 2006 Author Share Posted July 23, 2006 I want the form fields value to be set but a value in the table.the form field Date of Birth would be populated with the persons DOB in the database. Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/#findComment-62484 Share on other sites More sharing options...
aerospc Posted July 23, 2006 Share Posted July 23, 2006 Does the following help...?<form>First Name <input type="text" name="usrfn" value="<?php print($user_first_name);?>"><br><br>Last Name <input type="text" name="usrln" value="="<?php print($user_last_name);?>"><br><br><input type="submit" value="Update"></form> Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/#findComment-62491 Share on other sites More sharing options...
448191 Posted July 23, 2006 Share Posted July 23, 2006 Your using extract() and trigger_error(), I can't imagine your not familair with the value attribute of the html input element.. ??? Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/#findComment-62493 Share on other sites More sharing options...
proctk Posted July 23, 2006 Author Share Posted July 23, 2006 I'm a rookie, everything I have learned is from tutorials, and some code is copied and edited. Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/#findComment-62501 Share on other sites More sharing options...
448191 Posted July 23, 2006 Share Posted July 23, 2006 Ok, might I suggest you leave the MySQL tutorials for what they are for little while and do some basic html and forms tutorials first? You can't drive a car without wheels... ;) Quote Link to comment https://forums.phpfreaks.com/topic/15411-fill-form-fields-to-equal-mysql-table-values/#findComment-62505 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.