Jump to content


Photo

Resetting the record pointer to go back to the first record, how?


  • Please log in to reply
2 replies to this topic

#1 bilis_money

bilis_money
  • Members
  • PipPipPip
  • Advanced Member
  • 621 posts

Posted 08 August 2006 - 05:08 AM

hi,

i have problem querying the record pointer.
only the first record my query can see and the record
after the first can't be seen by my query why?

please help?

ok this are the codes below;
<?php
session_start();
require_once ("opendb.php");
require_once ("error_messages.php");
$COerr_msgs = new error_messages; //instantiate object

//get all username & password variables and assign to variables.
	$user = $_POST['username'];
	$pass = $_POST['password'];
	
//check for empty fields
	if($user == ''){
		$COerr_msgs->err_msgs('register1');
		exit();
	} else if($pass == ''){
		$COerr_msgs->err_msgs('register1');	
		exit();
	}

//get old username and email address.
	$query  = "SELECT * FROM users"; //get from database
	$result = mysql_query($query);
	$chk_dup = mysql_fetch_array($result);
//assigning old data
	$user_old = $chk_dup[username];
	$pass_old = $chk_dup[password];


	//check username existence
	if($user_old == $user) {
		//encrypt new password
		$encrypted_pass = sha1($pass);
		//compare new and old password
		if($encrypted_pass == $pass_old) {
			//if password match redirect to authorized user page.
			echo "----> You are now registered!";
			include "authorize_page.php";
		//if password fail.
		} else {
			$COerr_msgs->err_msgs('activate3');
		}
	} else {
		//if not exist show error message
		$COerr_msgs->err_msgs('activate2');
		exit();
	}

#mysql_query("UPDATE `table` SET `field`='0' WHERE `id`='$id'") or die(mysql_error());
#$query = "INSERT INTO users (first_name, last_name, username, password, email_address, signup_date, activated) 
#VALUES ('$fname', '$lname', '$user', '$password', '$email', 1)";
#mysql_query($query) or die('Error, insert query failed');
?>

thanks in advance.


#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 08 August 2006 - 05:13 AM

$query  = "SELECT * FROM users WHERE `field` = '" . $user . "'";

replace field with what the user names are stored in and try it...
$chk_dup = mysql_fetch_array($result); is gonna return an array with all rows in users... if query is just
SELECT * FROM users
Why doesn't anyone ever say hi, hey, or whad up world?

#3 bilis_money

bilis_money
  • Members
  • PipPipPip
  • Advanced Member
  • 621 posts

Posted 08 August 2006 - 06:16 AM

many thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users