bhavin_85 Posted March 5, 2007 Share Posted March 5, 2007 hey guys i want to create a form that updates a users account details...is there a way that i can get the form to show the users current details in each text box? then the user clicks on that box to edit the deails? also how would i structure a query so that it only updates the edited fields? and keeps the rest the same? i had a good at creating some code but get a parse code <tr> <td> <?php <form name="account_edit" method="post" action="page2.php"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td> </td> <td> </td> <td colspan="2"> </td> </tr> <tr> <td height="40"><div align="right"><span class="style1">Field you want to edit </span></div></td> <td width="28" height="40"> </td> <td height="40" colspan="2"><input name="field" type="text" id="songtitle" size="20" value="$date" ></td> </tr> <tr> <td height="53"> </td> <td width="28" height="53"> </td> <td width="83" height="53"> </td> <td width="157"><div align="left"> <input type="submit" name="Submit" value="Edit" /> </div></td> </tr> </table> </form> ?> </td> </tr> parse error is because the <form> is inside the <?Php Link to comment https://forums.phpfreaks.com/topic/41269-session-variables-in-a-form/ Share on other sites More sharing options...
benjaminbeazy Posted March 5, 2007 Share Posted March 5, 2007 <input type="text" name="first_name" value="<?=$_SESSION["user_first_name"];?>"> your query should just update all the fields, if you use the schema above no info will be lost this is easier than testing for altered form fields Link to comment https://forums.phpfreaks.com/topic/41269-session-variables-in-a-form/#findComment-199949 Share on other sites More sharing options...
bhavin_85 Posted March 5, 2007 Author Share Posted March 5, 2007 ahh right i get what u mean, ill give that a go cheers Link to comment https://forums.phpfreaks.com/topic/41269-session-variables-in-a-form/#findComment-199951 Share on other sites More sharing options...
benjaminbeazy Posted March 5, 2007 Share Posted March 5, 2007 actually come to think of it, you should perform a query at the beginning of the user details page and use the results for field values i.e. $user_id = $_SESSION['user_id']; $sql = "SELECT * from `users` WHERE `id`='$user_id'"; $result = mysql_query($sql); $row = mysql_fetch_object($result); <input type="text" name="user_name" value="<?=$row->user_name;?>"> Link to comment https://forums.phpfreaks.com/topic/41269-session-variables-in-a-form/#findComment-199952 Share on other sites More sharing options...
bhavin_85 Posted March 5, 2007 Author Share Posted March 5, 2007 the second way you suggested didnt work, the first way is fine though it does the trick got 1 other issue though, the page shows the customer date of birth how do i get it to print the date as dd/mm/yyyy ive turned the date into $date as a variable value="<?('j/n/Y',strtotime($date));?>" the other problem i can think of is if they change their date of birth (say it was entered wrong) would they have to enter it as yyyy/mm/dd as thats the way its stored inthe database? Link to comment https://forums.phpfreaks.com/topic/41269-session-variables-in-a-form/#findComment-199969 Share on other sites More sharing options...
bhavin_85 Posted March 5, 2007 Author Share Posted March 5, 2007 or maybe it would be easier to have a calandar open where they can select the date? any ideas? really struggling with this ! Link to comment https://forums.phpfreaks.com/topic/41269-session-variables-in-a-form/#findComment-200028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.