Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    User Info not posting to database

    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:
    Code:
    <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";
    }
    ?>

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Use [php][/php] tags, and are you getting any errors? If not add mysql_error() to your queries.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •