bmdsherman Posted August 16, 2009 Share Posted August 16, 2009 I am creating a website in which users can login to and have access to certain applications, I am trying to allow users to edit their "profile" that is stored in a mysql database under the following headers, id, fname, lname (last name), email, cellphone, homephone, otherphone, address, status (0=inactive 1=active), pword. Here is the script to view your own profile: <?php $p = $_GET['p']; $dbhost = '**********; $dbuser = '**********'; $dbpass = '**********'; $dbname = '*********'; ?> <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> <?php session_start(); $email = $_SESSION['myusername']; //echo "$email"; //echo $_SESSION['email']; $sql = "SELECT * FROM email WHERE email='$email'"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo' <table border="0" cellspacing="10" cols="20" frame="true" rules="none" align="center" width="600"> <tbody> <tr> <td>First Name</td> <td>'.$row['fname'].'</td> </tr> <tr> <td>Last Name</td> <td>'.$row['lname'].'</td> </tr> <tr> <td>Email Address</td> <td>'.$row['email'].'</td> </tr> <tr> <td>Cell Phone Number</td> <td>'.$row['cellphone'].'</td> </tr> <tr> <td>Home Phone Number</td> <td>'.$row['homephone'].'</td> </tr> <tr> <td>Other Phone Number</td> <td>'.$row['otherphone'].'</td> </tr> <tr> <td>Home Address</td> <td>'.$row['address'].'</td> </tr> </tbody> </table> ';} ?> </table> </body> </html> <br><br> <?php include "footer.php"?> So far that is working perfectly, but what if I want to allow users to edit their profile? What would I have to do? Quote Link to comment https://forums.phpfreaks.com/topic/170497-solved-edit-profile/ Share on other sites More sharing options...
DEVILofDARKNESS Posted August 16, 2009 Share Posted August 16, 2009 first: there is missing a ' after dbhost = '**** second: You should make a form in which people can write their new email, address, ... and a submit button to get the php working Quote Link to comment https://forums.phpfreaks.com/topic/170497-solved-edit-profile/#findComment-899412 Share on other sites More sharing options...
bmdsherman Posted August 16, 2009 Author Share Posted August 16, 2009 first: there is missing a ' after dbhost = '**** Oops! my bad, in the actual script the ' is there, but when I changed it to *'s I accidentally deleted it. second: You should make a form in which people can write their new email, address, ... and a submit button to get the php working That's a good idea, but I'm trying to somehow create a forum with all of the values pr-entered and users can edit and resubmit it, but I don't know how to edit a mysql row. Quote Link to comment https://forums.phpfreaks.com/topic/170497-solved-edit-profile/#findComment-899488 Share on other sites More sharing options...
peter_anderson Posted August 16, 2009 Share Posted August 16, 2009 To edit a MySQL row, use: mysql_query("UPDATE tbl_name SET content = '$content WHERE id = $id") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/170497-solved-edit-profile/#findComment-899498 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.