Ugluth Posted November 2, 2008 Share Posted November 2, 2008 Hello there, i've got a registration and a login page that work fine. Now my problem is that i want to make a page where the user can change the data he has provided on the registration page. Those data are stored in a mysql database, where i can connect normally. If someone could post a sample page where the user could change his e-mail and password, and explaining a bit how the page works, it would be really nice, since i'm having trouble figuring out the logic behind it. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/131081-account-edit-page/ Share on other sites More sharing options...
graham23s Posted November 2, 2008 Share Posted November 2, 2008 Hi Mate, you need to grab the users say ID for example! say 2 the SELECT * FROM TABLE WHERE ID=2 kinda thing like: <?php include("inc/inc-sessions.php"); include("inc/inc-dbconnection.php"); include("inc/inc-online.php"); include("inc/inc-functions.php"); include("inc/inc-header.php"); include("inc/inc-navigation.php"); include("inc/inc-countries.php"); ?> <?php // titles array // $titles_array = array("Dr","Doctor","Mr","Mister","Ms","Mrs","Miss"); // query to get the logged in users details // $q = "SELECT * FROM `fcp_customers` WHERE `id`='$var_loggedinuserid'"; $r = mysql_query($q); $row = mysql_fetch_array($r); // vars // $cus_title = $row['title']; $cus_first_name = $row['first_name']; $cus_last_name = $row['last_name']; $cus_address = $row['address']; $cus_city = $row['city']; $cus_state_county = $row['state_county']; $cus_postal_zip_code = $row['post_zip_code']; $cus_country = $row['country']; $cus_email = $row['email']; $cus_home_number = $row['home_number']; $cus_mob_number = $row['mobile_number']; $cus_admin_level = $row['admin_level']; // ten op for button // $admin_button = ($cus_admin_level == "Y") ? "<b>[ <a class=\"smart_links\" href=\"admin.php\">A</a> ]</b>" : " "; ?> <?php // standard header // print("<div class=\"subheader\"><div id=\"title\">Welcome <span class=\"blue\">$var_loggedinuserfirstname!</span></div>Below you can edit your sign-up details, please make sure your address is correct for shipping. $admin_button</div>"); ?> <?php // grab the post data // if(isset($_POST['submit'])) { // vars from post // $form_title = mysql_real_escape_string($_POST['title']); $form_first_name = mysql_real_escape_string($_POST['first_name']); $form_last_name = mysql_real_escape_string($_POST['last_name']); $form_address = mysql_real_escape_string($_POST['address']); $form_city = mysql_real_escape_string($_POST['city']); $form_state_or_county = mysql_real_escape_string($_POST['state_or_county']); $form_post_zip_code = mysql_real_escape_string($_POST['post_zip_code']); $form_country = mysql_real_escape_string($_POST['country']); $form_home_number = mysql_real_escape_string($_POST['home_number']); $form_mobile_number = mysql_real_escape_string($_POST['mobile_number']); $form_email = mysql_real_escape_string($_POST['email']); // update mysql with the new info // $q_update = "UPDATE `fcp_customers` SET `title`='$form_title',`first_name`='$form_first_name',`last_name`='$form_last_name',`address`='$form_address',`city`='$form_city',`state_county`='$form_state_or_county',`post_zip_code`='$form_post_zip_code',`country`='$form_country',`email`='$form_email',`home_number`='$form_home_number',`mobile_number`='$form_mobile_number' WHERE `id`='$var_loggedinuserid'"; $r_update = mysql_query($q_update); // javascript refresh // print('<script type="text/javascript">window.location = "account.php"</script>'); } ?> <?php // CHECK LOGIN STATUS // //login_status($var_loggedinuserid); // display the form // print("<form action=\"account.php\" method=\"POST\" onSubmit=\"return account_form_check()\" name=\"account_form\">\n"); print("<table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" class=\"tbl_login\">\n"); print("<tr>\n"); print("<td colspan=\"2\" align=\"left\" class=\"c3\"><b>Update your account details</b></td>\n"); print("</tr>\n"); print("<tr class=\"c5\">\n"); print("<td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td>\n"); print("</tr>\n"); print("<tr class=\"c1\">\n"); print("<td class=\"font_for_forms\" align=\"right\">Title:</td><td class=\"font_for_forms\" align=\"left\">\n"); print("<select name=\"title\">\n"); foreach($titles_array as $title_value) { print("<option value=\"$title_value\" "); if($title_value == $cus_title) { print(" selected"); } print(">$title_value</option>\n"); } print("</select>\n"); print("</td>\n"); print("<tr>\n"); print("<td class=\"font_for_forms\" align=\"right\">First Name:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" id=\"first_name\" name=\"first_name\" value=\"$cus_first_name\"/></td>\n"); print("</tr>"); print("<tr class=\"c1\">\n"); print("<td class=\"font_for_forms\" align=\"right\">Last Name:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" id=\"last_name\" name=\"last_name\" value=\"$cus_last_name\"/></td>\n"); print("</tr>"); print("<tr>"); print("<td class=\"font_for_forms\" align=\"right\">Address:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" id=\"address\" name=\"address\" value=\"$cus_address\"/></td>\n"); print("</tr>"); print("<tr class=\"c1\">\n"); print("<td class=\"font_for_forms\" align=\"right\">City:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" id=\"city\" name=\"city\" value=\"$cus_city\"/></td>\n"); print("</tr>"); print("<tr>"); print("<td class=\"font_for_forms\" align=\"right\">State / County:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" id=\"state_or_county\" name=\"state_or_county\" value=\"$cus_state_county\"/></td>\n"); print("</tr>"); print("<tr class=\"c1\">\n"); print("<td class=\"font_for_forms\" align=\"right\">Postal / Zip Code:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" id=\"post_zip_code\" name=\"post_zip_code\" value=\"$cus_postal_zip_code\"/></td>\n"); print("</tr>"); print("<tr>"); print("<td class=\"font_for_forms\" align=\"right\">Country:</td><td class=\"font_for_forms\" align=\"left\">\n"); print("<select name=\"country\">\n"); foreach($countrylist as $value_country) { print("<option value=\"$value_country\" "); if($value_country == $cus_country) { print(" selected"); } print(">$value_country</option>\n"); } print("</select>\n"); print("</td>\n"); print("<tr class=\"c1\">\n"); print("<td class=\"font_for_forms\" align=\"right\">Contact Number:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" name=\"home_number\" value=\"$cus_home_number\"/></td>"); print("</tr>\n"); print("<tr>\n"); print("<td class=\"font_for_forms\" align=\"right\">Mobile Number:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" name=\"mobile_number\" value=\"$cus_mob_number\"/></td>"); print("</tr>\n"); print("<tr class=\"c1\">\n"); print("<td class=\"font_for_forms\" align=\"right\">E-Mail:</td><td class=\"font_for_forms\" align=\"left\"><input type=\"text\" size=\"40\" name=\"email\" value=\"$cus_email\"/></td>"); print("</tr>\n"); print("<tr>\n"); print("<td class=\"font_for_forms\" colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Update Details\"></td>"); print("</tr>\n"); print("</table>\n"); print("</form>\n"); print("$c_id"); ?> <?php // include the footer // include("inc/inc-footer.php"); ?> heres some of my code to pick apart Graham Link to comment https://forums.phpfreaks.com/topic/131081-account-edit-page/#findComment-680564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.