supermerc Posted March 23, 2007 Share Posted March 23, 2007 Hey, I have a code to edit profile, and the code used to have a field to be able to change email but I removed it, but Im not able to remove it completely now when I try to edit profile it says your email was empty and not in email formate, so I removed the error echos but then I was getting other errors, so I put it back, if anyone could help me because i dont know what I have to remove in order for it to work again. this is my code echo " <style> body { background: #ffffff; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #000000; } .register_box { border: 1px solid #323232; background: #202020; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #FFFFFF; } </style> "; if(isset($_SESSION['s_logged_n'])) { $session_username = $_SESSION['s_username']; // further checking... if(username_exists($session_username)) { $get_info = mysql_query("SELECT description FROM users WHERE username = '$session_username' LIMIT 1"); if(mysql_num_rows($get_info) > 0) { $user_info = mysql_fetch_assoc($get_info); if(!isset($_POST['do_edit'])) { echo ' <form action="edit_profile.php" method="post">' ?> <?php echo'<p>Description: </br> <textarea name="textfield" cols="45" rows="5">' . $user_info['description'] . '</textarea> <br/> <br> Click <a href="picupload.php">here</a> to edit your profile picture. <br/> <b><br/> <input type="submit" name="do_edit" value="Edit Your Profile" /> </form> <b><br/> <b><br/> <b>*Note that if you change your email to an invalid email you will not be able to receive emails to change your password etc.<br/> '; } elseif(isset($_POST['do_edit'])) { $email = mysql_real_escape_string($_POST['email']); // assign all errors to an array $errors = array(); if(empty($email)) { $errors[] = 'Your email was empty.'; } if(!is_valid_email($email)) { $errors[] = 'Your email was not in a valid email format.'; } // if array elements is greater than 0, // then we KNOW there was an error // else, no error, move on to processing if(count($errors) > 0) { echo '<b>ERRORS:</b><br />'; foreach($errors as $err) { echo $err . '<br />'; } } else { // everything is ok, update the DB mysql_query("UPDATE users SET description = '" . $_POST['description'] . "' WHERE username = '$session_username'"); echo 'Profile Edited.'; } } } else { echo 'Could not find profile info for your username.'; } } else { echo 'Sorry, your session username doesnt exist.'; } } else { echo 'You must be logged in to edit your profile.'; } ?> thanks Quote Link to comment Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 It's not enough to simply remove the echos, you must remove the validation if statements that cause the echos to be displayed. Try this: echo " <style> body { background: #ffffff; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #000000; } .register_box { border: 1px solid #323232; background: #202020; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #FFFFFF; } </style> "; if(isset($_SESSION['s_logged_n'])) { $session_username = $_SESSION['s_username']; // further checking... if(username_exists($session_username)) { $get_info = mysql_query("SELECT description FROM users WHERE username = '$session_username' LIMIT 1"); if(mysql_num_rows($get_info) > 0) { $user_info = mysql_fetch_assoc($get_info); if(!isset($_POST['do_edit'])) { echo ' <form action="edit_profile.php" method="post">' ?> <?php echo'<p>Description: </br> <textarea name="textfield" cols="45" rows="5">' . $user_info['description'] . '</textarea> <br/> <br> Click <a href="picupload.php">here</a> to edit your profile picture. <br/> <b><br/> <input type="submit" name="do_edit" value="Edit Your Profile" /> </form> <b><br/> <b><br/> <b>*Note that if you change your email to an invalid email you will not be able to receive emails to change your password etc.<br/> '; } elseif(isset($_POST['do_edit'])) { // if array elements is greater than 0, // then we KNOW there was an error // else, no error, move on to processing if(count($errors) > 0) { echo '<b>ERRORS:</b><br />'; foreach($errors as $err) { echo $err . '<br />'; } } else { // everything is ok, update the DB mysql_query("UPDATE users SET description = '" . $_POST['description'] . "' WHERE username = '$session_username'"); echo 'Profile Edited.'; } } } else { echo 'Could not find profile info for your username.'; } } else { echo 'Sorry, your session username doesnt exist.'; } } else { echo 'You must be logged in to edit your profile.'; } ?> Quote Link to comment Share on other sites More sharing options...
supermerc Posted March 23, 2007 Author Share Posted March 23, 2007 Thats what I had done before and it still doesnt work, it says profile edited but it doesnt actually edit it Quote Link to comment Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 Ok well keep that and then change: <textarea name="textfield" cols="45" rows="5">' . $user_info['description'] . '</textarea> to <textarea name="description" cols="45" rows="5">' . $user_info['description'] . '</textarea> Quote Link to comment Share on other sites More sharing options...
supermerc Posted March 23, 2007 Author Share Posted March 23, 2007 thx a lot it works now Quote Link to comment 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.