Jump to content

Recommended Posts

I am trying to figure out why my script isn't updating the information of the user names stored in the database. Can anyone give me the solution?

Below is the script:

<link href="images/style.css" rel="stylesheet" type="text/css">

<?php
if(session_id() == ""){
  session_start();
}
Authenticate();
UserStatus();
include("../class/config.php");
$self=$_SERVER['PHP_SELF'];

/* If form hasn’t been submitted */
if(!isset($_POST['submit']))
{ 
?>
<h2>Change A User's Password</h2>
<div id="admin-form">
<form method="post" action="admin_user_index.php?action=edituser">
<p><label for="username">Username: </label>
<select name="user" id="username">
<?
include("../class/config.php");

$sqlcats="Select * from news_saxon_saxon_users";
$rescats=mysql_query($sqlcats,$db);

while($onecats=mysql_fetch_object($rescats)){
echo "<option value=$onecats->USER_ID";
if($onecats->USER_ID==$onecat->USER_NAME)
echo " SELECTED " ;
echo ">$onecats->USER_NAME</option>";

} ?>
</select></p>
<p><label for="Password1">New Password: </label><input type="password" name="user_pwd1" id="Password1" /></p>
<p><label for="Password2">Re-enter Password: </label><input type="password" name="user_pwd2" id="Password2" /></p>
<p><input type="submit" class="submit button" name="submit" value="Submit" /> 
<input type="reset" class="button" name="reset" value="Reset" /></p>
</form>
</div>
<?php
}
// If form has been submitted
else
{
$user=$_POST['user'];
$user_pwd1=$_POST['user_pwd1'];
$user_pwd2=$_POST['user_pwd2'];
if($user_pwd1=="" && $user_pwd2=="")
{
?>
<h2>Change A User's Password</h2>
<div id="pwd-form">
<p class="error">Please enter a new password.</p>
</div>
<?php
	echo "</td></tr></table>";
	include('footer.php');		
	exit;
}
if($user_pwd1<>$user_pwd2)
{
?>
<h2>Change A User's Password</h2>
<div id="pwd-form">
<p class="error">Your passwords don't match! Please try again.</p>
<p><a href="admin_user_index.php?action=edituser">Previous page</a></p>
</div>
<?php
	echo "</td></tr></table>";
	include('footer.php');

	exit;
}
$error = DBConnect ($mhost,$muser,$mpass,$mdb);
if (trim($error) != "")
{
	echo "<p class=\"error\">User information not available at this time! Please contact the site administrator.</p>";
	echo $error;
	echo "</td></tr></table>";
	include('footer.php');
	exit;
}
// does this user exist?
$error=CheckUsername($user,$prefix);
if (trim($error) != "")
{
	echo "<p>Search completed for user ".$user."</p>\n";
	echo $error;
	echo "</td></tr></table>";
	include('footer.php');
	exit;
}
// get all user info
list($member_user_id,$member_full_name,$member_user_pwd,$member_user_status)=GetUser($user,$prefix);
$new_pwd=md5($user_pwd1);
$error = DBConnect ($mhost,$muser,$mpass,$mdb);
if (trim($error) != "")
{
	echo "<p class=\"warning\">Password not updated.</p>";
	echo $error;
	echo "Please contact the site administrator.</p>\n";
	echo "</td></tr></table>";
	include('footer.php');		
	exit;
}
$tblname = QuoteSmart($prefix."saxon_users");
$new_pwd = QuoteSmart($new_pwd);
$member_user_id = QuoteSmart($member_user_id);
$update= "UPDATE LOW_PRIORITY IGNORE $tblname SET USER_PWD='$new_pwd' WHERE USER_ID='$member_user_id'";
if (mysql_query($update))
{
	echo "<p class=\"success\">Password for ".$user." updated</p>";
	echo "</td></tr></table>";
	include('footer.php');		
	exit;
}
echo "<p class=\"error\">Error! Password not updated</p>";
echo "Please contact the site administrator.</p>\n";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/66859-user-info-not-posting-to-database/
Share on other sites

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.