Jump to content

Archived

This topic is now archived and is closed to further replies.

bilis_money

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

Recommended Posts

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;
[code]
<?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');
?>
[/code]

thanks in advance.

Share this post


Link to post
Share on other sites
$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

Share this post


Link to post
Share on other sites

×

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.