dean7 Posted July 16, 2011 Share Posted July 16, 2011 Hey all, I'm coding a script for my website which simply updates there profile though the Owners CP. I have manged to get it to show the information on the profile, but when I click the Update button it doesn't update there profile... <?php session_start(); header("Cache-control: private"); include "../../includes/config.php"; include "../../includes/functions.php"; logincheck(); $userlevel = mysql_query("SELECT userlevel FROM users WHERE username='$username'"); $userlevel1 = mysql_fetch_object($userlevel); if ($userlevel1->userlevel == 1){ header("Location: 404.php"); }elseif ($userlevel1->userlevel >= 2){ if ((strip_tags(addslashes($_POST['view']))) || strip_tags(addslashes($_POST['subby']))){ $user = strip_tags(addslashes($_POST['view'])); // Lets make sure the User is Real... $check = mysql_query("SELECT * FROM users WHERE username = '$user'"); $checknum = mysql_num_rows($check); $checkobj = mysql_fetch_object($check); if ($checknum == "0"){ echo ("<table width='30%' cellpadding='0' cellspacing='0' border='1' align='center' class='table'> <tr> <td class='e_header' align='center'>Error</td> </tr> <tr> <td align='center'>No Such User!</td> </td> </table> <br /> "); }elseif ($checknum != "0"){ if ((strip_tags(addslashes($_POST['newcon'])) && strip_tags(addslashes($_POST['conn'])))){ $conn = strip_tags($_POST['conn']); mysql_query ("UPDATE users SET quote='$conn' WHERE username='$user'") or die ("Error Updating Profile" . mysql_error()); mysql_query("INSERT INTO stafflogs (`id`,`username`,`time`,`whathappend`)VALUES('','$username','$date','$username updated $user content!')") or die ("Error Updating Staff Logs" . mysql_error()); echo ("<table border='1' align='center' cellpadding='0' cellspacing='0' class='table'> <tr> <td class='header' align='center'>Success</td> </tr> <tr> <td>You successfully changed $user profile content!</td> </tr> </table> <br />"); } } } } ?> <html> <head> <title>SD | Change Content</title> </head> <form action='' method='POST' name='doit'> <link rel="stylesheet" href="../../style.css" type="text/css"> <table width="30%" class="table" cellpadding="0" cellspacing="0" border="1" align="center"> <tr> <td class="header" align="center" colspan='2'>View Profile</td> </tr> <tr> <td>Username:</td><td align='center'><input type='text' name='view' id='user' class='input'></td> </tr> <tr> <td align='center' colspan='2'><input type='submit' name='subby' value='View Profile' class='button'></td> </tr> </table> <br /> <table width="50%" class="table" cellpadding="0" cellspacing="0" border="1" align="center"> <tr> <td class="header" align="center">Edit <?php echo $user; ?> Profile Content</td> </tr> <tr> <td class="omg" align="center">Everything you change will be logged!</td> </tr> <tr> <td align="center"><a href="javascript:addon(' ')"><img src="../../images/faces/smile.gif" border="0"></a> <a href="javascript:addon(' ')"><img src="../../images/faces/sad.gif" border="0"></a> <a href="javascript:addon(' ')"><img src="../../images/faces/v.happy.gif" border="0"></a> <a href="javascript:addon(':S ')"><img src="../../images/faces/wacko.gif" border="0"></a> <a href="javascript:addon(' ')"><img src="../../images/faces/wink2.gif" border="0"></a> <a href="javascript:addon('::laugh ')"><img src="../../images/faces/laugh.gif" border="0"></a> <a href="javascript:addon('::blush ')"><img src="../../images/faces/blush.gif" border="0"></a> <a href="javascript:addon(' ')"><img src="../../images/faces/tongue.gif" border="0"></a> <a href="javascript:addon('::dry ')"><img src="../../images/faces/dry.gif" border="0"></a></td> </tr> <tr> <td align="center"><textarea name="conn" cols="85" rows="10" id="conn" class="input"><?php echo "$checkobj->quote"; ?></textarea></td> </tr> <tr> <td><input type="submit" name="newcon" value="Update Profile" class="button"></td> </tr> </table> </br /> </form> Anyone see why its not updating the posted users profile? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/242113-simple-editing-script/ Share on other sites More sharing options...
TeNDoLLA Posted July 16, 2011 Share Posted July 16, 2011 Do you get any PHP or MySQL errors? Do you have error reporting on? Have you tried to echo out your SQL queries in case of update and see how they are formed, are they as they should be ? Quote Link to comment https://forums.phpfreaks.com/topic/242113-simple-editing-script/#findComment-1243389 Share on other sites More sharing options...
dean7 Posted July 16, 2011 Author Share Posted July 16, 2011 Do you get any PHP or MySQL errors? Do you have error reporting on? Have you tried to echo out your SQL queries in case of update and see how they are formed, are they as they should be ? Yes I have Error Reporting on and its not displaying any errors, and yeah I've also tried echoing out the SQL Queries and its still not displaying no errors - Unless I'm doing something wrong along the line somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/242113-simple-editing-script/#findComment-1243392 Share on other sites More sharing options...
TeNDoLLA Posted July 16, 2011 Share Posted July 16, 2011 Well if you have echoed the SQL queries, did they look as they should be with the update data? Meaning is it correct SQL syntax, are the values missing or anything weird? Quote Link to comment https://forums.phpfreaks.com/topic/242113-simple-editing-script/#findComment-1243393 Share on other sites More sharing options...
dean7 Posted July 16, 2011 Author Share Posted July 16, 2011 Well if you have echoed the SQL queries, did they look as they should be with the update data? Meaning is it correct SQL syntax, are the values missing or anything weird? Yeah when I echoed them I didn't get any errors, so must all be right? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/242113-simple-editing-script/#findComment-1243396 Share on other sites More sharing options...
TeNDoLLA Posted July 16, 2011 Share Posted July 16, 2011 No, thats not what I mean. You need to inspect the echoed SQL queries if they are correct. DO they contain the data you expect them to contain? Is that correct SQL syntax, etc. Though if they are not correct syntax you should be getting some sort of syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/242113-simple-editing-script/#findComment-1243398 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.