Anyone Fancy a Challenge ????

General discussions related to php

Moderators: macek, egami, gesf

pbrane
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Nov 03, 2002 2:28 pm
Location: Nottingham UK
Contact:

Anyone Fancy a Challenge ????

Postby pbrane » Sat Jan 04, 2003 7:09 pm

Hello All,

im in the process of building a registration/login section of a site you can access the site on:

http://www.voconet.co.uk/adam/index.php

I can get users to register and it emails them etc etc. but when they come to actually login im having no luck, it keeps saying there is no match on the file but i know they are on the database! below is the code for my login page:


<?php
// This page receives a username and password and checks it against the stored
// information to validate the log in.

require_once ("config.inc");
session_start();
if ( (ereg ("^[[:alnum:]]+$", $HTTP_POST_VARS[username])) AND (eregi ("^[[:alnum:]]{8,16}$", $HTTP_POST_VARS[password])) )
{ // Check the submitted info.

$query = "SELECT user_id, first_name, password FROM users WHERE username='$HTTP_POST_VARS[username]'";
$query_result = mysql_query ($query, $db_connection) or die (mysql_error());
$result = @mysql_fetch_array ($query_result);
if ( (crypt($password, $result[password])) == $result[password]) {
session_start();
$user_id = $result[0];
$first_name = $result[1];
session_register ('user_id');
session_register ('first_name');
$sid_value = "?" .SID;
header ("Location: index.php$sid_value");
exit;
} else {
$message = urlencode ("The username and password submitted do not match those on file. Please try again.");
}
} else {
$message = urlencode ("Please enter your username and password to log in.");
}
$sid_value = "&" .SID;
header ("Location: index.php?error_message=$message$sid_value");
exit;
?>

No matter what happens i just get one of the else statements it should say Greetings(First_Name) as below:

// Greet them if they are logged in or show the log in form.
if ($HTTP_SESSION_VARS[first_name]) {
$header= "Greetings, $HTTP_SESSION_VARS[first_name]!";
} else {
$header = '<form action="login.php" method="post">
Username <input type="text" name="username" size="16" maxlength="16" />
Password <input type="password" name="password" size="16" maxlength="16" />
<input type="hidden" name="PHPSESSID" value="' .session_id() . '" />
<input type="submit" name="Submit" value="Go!" />
</form>';
}
$page->SetParameter("PAGE_HEADER", $header);


Im probly just being thick it is 3am and im still doing this since sometime lastweek :@

Please Guys (Gals)
:D

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: Anyone Fancy a Challenge ????

Postby WiZARD » Sun Jan 05, 2003 7:19 am

i'm tested you site that's all work...
see your personal setting. maby you in some wrong....

P.S.
I don't know how about sending e-mail form is forked: i'm register and and login....


Return to “PHP General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest