graham23s Posted July 1, 2007 Share Posted July 1, 2007 Hi Guys, on my site the users can goto the control panel and edit there profile (age,location etc) from input boxes and drop down boxes, but if i just for the heck of it press the "update profile" button WITHOUT putting in the correct data it is all lost (no input in the input boxes defaults to zero in mysql) what would be the best way to only update mysql when the user input the data, i have attatched a screencap of some of the fields http://img61.imageshack.us/my.php?image=testvx9.jpg cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/ Share on other sites More sharing options...
mmarif4u Posted July 1, 2007 Share Posted July 1, 2007 Validation will work here. Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287138 Share on other sites More sharing options...
hackerkts Posted July 1, 2007 Share Posted July 1, 2007 Get the informations from the database and make it the default value for each form. Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287141 Share on other sites More sharing options...
graham23s Posted July 1, 2007 Author Share Posted July 1, 2007 Hi Guys, how would i go about getting the "default value for each form". thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287152 Share on other sites More sharing options...
hackerkts Posted July 1, 2007 Share Posted July 1, 2007 At the form, put value="" Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287153 Share on other sites More sharing options...
AndyB Posted July 1, 2007 Share Posted July 1, 2007 how would i go about getting the "default value for each form". Get the informations from the database and make it the default value for each form. Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287154 Share on other sites More sharing options...
graham23s Posted July 1, 2007 Author Share Posted July 1, 2007 ah so for example: <option value="$location">$location</option> is that right would you say? cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287386 Share on other sites More sharing options...
AndyB Posted July 1, 2007 Share Posted July 1, 2007 Is that right? Yes, No, and Maybe, and depends on how your code retrieves information from the database (code we've not seen). For a data field such as text: <?php echo '<input type="text" name="something" value="'. $something. '"/>';?> For a drop down, you'll want all of the possible values in an array, and display the chosen value, something like this <?php for ($i=0;$i<count($myvalues);$i++) { echo 'option value="'. $myvalues[$i]. '"; if ($myvalues[$i]== $database_value) { echo ' selected="selected"'; } echo '>'. $myvalues[$i]. '</option>\n'; }?> Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287396 Share on other sites More sharing options...
graham23s Posted July 1, 2007 Author Share Posted July 1, 2007 Hi Andy, this is how im getting the information from mysql: $display_query = "SELECT * FROM `users` WHERE `username`='$member'"; $display_result = mysql_query($display_query) or die (mysql_error()); $display = mysql_fetch_array($display_result) or die (mysql_error()); $fname = $display['first_name']; $lname = $display['last_name']; $mail = $display['email']; $bmonth = $display['birth_month']; $bday = $display['birth_day']; $byear = $display['birth_year']; $gender_dis = $display['gender']; $tphone = $display['telephone']; $mbile = $display['mobile']; $ctry = $display['country']; $ft = $display['feet']; $in = $display['inches']; $st = $display['stones']; $lb = $display['lbs']; $eyec = $display['eye']; $hairc = $display['hair']; $bild = $display['build']; $pf = $display['play_ages_from']; $pt = $display['play_ages_to']; $eth = $display['ethnicity']; $skillz = $row['skills']; $add_inf = $row['add_info']; this is the smallest drop down example: <td align="right">Gender:</td><td align="left"><select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> </td> the text areas are easy enough i have them down , it just seems to be the drop down boxes i have trouble displaying the selected information also i have some for each loops cycling through the initial screen to input you data like: <td align="right">Country:</td><td align="left">'; echo '<select name="country">'; foreach ($country_list as $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select> how would i go about implememnting the code you have selected with this one? thanks for any help guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287464 Share on other sites More sharing options...
AndyB Posted July 1, 2007 Share Posted July 1, 2007 <td align="right">Country:</td><td align="left">'; echo '<select name="country">'; foreach ($country_list as $value) { echo "<option value='". $value. "'"; if ($value == $ctry) { echo " selected='selected'"; } echo ">". $value. "</option>\n"; } echo '</select>'; Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-287466 Share on other sites More sharing options...
graham23s Posted July 2, 2007 Author Share Posted July 2, 2007 Thank you Andy that has done it for me:) Graham Quote Link to comment https://forums.phpfreaks.com/topic/57944-solved-edit-profile-form/#findComment-288387 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.