Jump to content

Recommended Posts

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. :)

Link to comment
https://forums.phpfreaks.com/topic/242113-simple-editing-script/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.