ainsleyclark Posted May 10, 2006 Share Posted May 10, 2006 hello everybody. i have made a login for usernames and passwords and it redirects them to their profile, i want the user to be able to edit their profile by using a save button then link that back to a table in my original document. here is the script that i got of a site but im still stuck on how to do it! please help me im only a rookie!PHP Code:<?php if(isset($_POST['save'])) { $id = $_SESSION['userid']; $customers_firstname = $_POST['customers_firstname']; $customers_lastname = $_POST['customers_lastname']; $customers_email = $_POST['customers_email']; $customers_email = $_POST['customers_email']; $customers_street_address = $_POST['customers_street_address']; $customers_city = $_POST['customers_city']; $customers_postcode = $_POST['customers_postcode']; $customers_state = $_POST['customers_state']; $customers_country = $_POST['customers_country']; $customers_phone = $_POST['customers_phone']; $customers_email_address = $_POST['customers_email_address']; $customers_phone2 = $_POST['customers_phone2']; $customers_username = $_POST['customers_username']; $account_created = $_POST['customers_date_account_created']; $now = date("Y-m-d H:i:s"); $update_customer = ("UPDATE $customer_table SET customers_firstname = '$customers_firstname', customers_lastname = '$customers_lastname', customers_email = '$customers_email', customers_street_address = '$customers_street_address', customers_city = '$customers_city', customers_postcode = '$customers_postcode', customers_state = '$customers_state', customers_country = '$customers_country', customers_phone = '$customers_phone', customers_phone2 = '$customers_phone2', customers_username = '$customers_username', customers_date_account_last_modified = '$now', customers_date_account_created = '$account_created' WHERE customers_id = '$id'"); $update_query = mysql_query($update_customer) or die(mysql_error()); if(!$update_query) { echo 'Error in updating customer contact information!'; } else { echo 'Customer contact information successfully updated!'; } } else { $id = $_SESSION['userid']; $order_details = mysql_query("SELECT * FROM customers WHERE customers_id= '$id' "); while ($line = mysql_fetch_array($order_details)) { $customers_id = $line["customers_id"]; $customers_firstname = $line["customers_firstname"]; $customers_lastname = $line["customers_lastname"]; $customers_email = stripslashes($line["customers_email"]); $customers_street_address = $line["customers_street_address"]; $customers_city = $line["customers_city"]; $customers_postcode = $line["customers_postcode"]; $customers_state = $line["customers_state"]; $customers_country = $line["customers_country"]; $customers_phone = $line["customers_phone"]; $customers_phone2 = $line["customers_phone2"]; $customers_username = $line["customers_username"]; $customers_ip = $line["customers_ip"]; //$customers_date_of_last_logon = date("m-d-Y h:i:s A", strtotime($line['customers_date_of_last_logon'])); $customers_number_of_logons = $line["customers_number_of_logons"]; $customers_date_account_created = date("m-d-Y h:i:s A", strtotime($line['customers_date_account_created'])); $customers_date_account_last_modified = date("m-d-Y h:i:s A", strtotime($line['customers_date_account_last_modified'])); echo''; } ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" name="customer_details" id="customer_details"> <table width="50%" border="0" align="center" class="newsheader"> <caption> Customer Details for ID <strong><?=$customers_id ?></strong> </caption> <tr> <td width="21%"><div align="right">First Name:</div></td> <td width="40%"><input name="customers_firstname" type="text" id="customers_firstname" value="<?=$customers_firstname ?>"></td> <td width="21%"><div align="right">E-Mail:</div></td> <td width="40%"><input name="customers_email" type="text" id="customers_email" value="<?=$customers_email ?>"></td> </tr> <tr> <td><div align="right">Last Name: </div></td> <td><input name="customers_lastname" type="text" id="customers_lastname" value="<?=$customers_lastname ?>"></td> <td><div align="right">User Name: </div></td> <td><input name="customers_username" type="text" id="customers_username" value="<?=$customers_username ?>"></td> </tr> <tr> <td><div align="right">Street:</div></td> <td><input name="customers_street_address" type="text" id="customers_street_address" value="<?=$customers_street_address ?>"></td> <td><div align="right">City:</div></td> <td><input name="customers_city" type="text" id="customers_city" value="<?=$customers_city ?>"></td> </tr> <tr> <td><div align="right">State:</div></td> <td><input name="customers_state" type="text" id="customers_state" value="<?=$customers_state ?>"></td> <td><div align="right">Zip:</div></td> <td><input name="customers_postcode" type="text" id="customers_postcode" value="<?=$customers_postcode ?>"></td> </tr> <tr> <td><div align="right">Phone:</div></td> <td><input name="customers_phone" type="text" id="customers_phone" value="<?=$customers_phone ?>"></td> <td><div align="right">Mobile:</div></td> <td><input name="customers_phone2" type="text" id="customers_phone2" value="<?=$customers_phone2 ?>"></td> </tr> <tr> <td><div align="right">IP:</div></td> <td><?=$customers_ip ?></td> <td><div align="right">Last Login: </div></td> <td><?=$customers_date_of_last_logon ?></td> </tr> <tr> <td><div align="right">Created:</div></td> <td><input name="customers_date_account_created" type="text" id="customers_date_account_created" value="<?=$customers_date_account_created ?>"></td> <td><div align="right">Modified:</div></td> <td><?=$customers_date_account_last_modified ?></td> </tr> <tr> <td colspan="4"><div align="center"> <input name="save" type="submit" id="save" value="Save"> </div></td> </tr> </table> </form> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/ Share on other sites More sharing options...
448191 Posted May 10, 2006 Share Posted May 10, 2006 I reviewed this code for you, and although very crude, it should work. There are several things you could be doing wrong though. What exactly "doesn't work"? Do you get any error messages? Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/#findComment-34903 Share on other sites More sharing options...
ainsleyclark Posted May 10, 2006 Author Share Posted May 10, 2006 [!--quoteo(post=372909:date=May 10 2006, 01:57 PM:name=448191)--][div class=\'quotetop\']QUOTE(448191 @ May 10 2006, 01:57 PM) [snapback]372909[/snapback][/div][div class=\'quotemain\'][!--quotec--]What exactly "doesn't work"? Do you get any error messages?[/quote]everything works, well i think as u think there are error messages in it? i was this save button to update the table in my php document,is this doing it? im really confused [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] what do i nee for a content manganment system? Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/#findComment-34906 Share on other sites More sharing options...
448191 Posted May 10, 2006 Share Posted May 10, 2006 [!--quoteo(post=372912:date=May 10 2006, 08:32 AM:name=ainsleyclark)--][div class=\'quotetop\']QUOTE(ainsleyclark @ May 10 2006, 08:32 AM) [snapback]372912[/snapback][/div][div class=\'quotemain\'][!--quotec--]everything works, well i think as u think there are error messages in it? i was this save button to update the table in my php document,is this doing it? im really confused [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] what do i nee for a content manganment system?[/quote]You've got ME confused! What is the problem? You want to check if the table is updated? To be absolutely positive, go to the mysql command line, select the database and type: SELECT * FROM (whatever the tablename)... You should see the new values.P.S. You should probably be in Newbie Help with this type of thing... Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/#findComment-34907 Share on other sites More sharing options...
wildteen88 Posted May 10, 2006 Share Posted May 10, 2006 From looking at your code you use sessions. But you havn't got session_start() at the beginning of your PHP script. In order for your session variaables to work you need put session_start in all files that read and write to session variables, otherwise your session variables wont work at all. So change where it says:[code]<?phpif(isset($_POST['save'])){ [/code]to:[code]<?phpsession_start();if(isset($_POST['save'])){ [/code] Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/#findComment-34914 Share on other sites More sharing options...
448191 Posted May 10, 2006 Share Posted May 10, 2006 [!--quoteo(post=372920:date=May 10 2006, 09:10 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 10 2006, 09:10 AM) [snapback]372920[/snapback][/div][div class=\'quotemain\'][!--quotec--]From looking at your code you use sessions. But you havn't got session_start() at the beginning of your PHP script. In order for your session variaables to work you need put session_start in all files that read and write to session variables, otherwise your session variables wont work at all. [/quote]I considered that, but since he's saying he's not getting any errors I assumed he's starting the session elsewhere (including this file)...Basicly it's just not clear what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/#findComment-34917 Share on other sites More sharing options...
sumityadav Posted May 11, 2006 Share Posted May 11, 2006 Yes the code is too large to gothrough. Should have posted only part of it that contains some errors etc... [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/9468-after-password-protection/#findComment-35164 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.