Jump to content

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


bilis_money

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.
Link to comment
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
Link to comment
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.