Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 7th, 2004, 03:41 PM
Registered User
Join Date: Oct 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default session login with access db

first i'd like to thank you guys on these forums for being so helpful, i've been able to fix almost every issue with my current project. now that i'm coming to the home stretch this is where i'm having the most issues. i'm tryin to make a login using a access db but its not reposonding, it just reloads the forms basically and doesn't say if password failed or not. here is the code. it looks crappy i know, i am a beginner


function auth_user($userid, $userpassword) {
global $default_dbname, $user_tablename;

$user_tablename = "Table2";

$link_id = odbc_connect('phpaccess', '', '') or die("Could not connect !");

$query = "SELECT username From Table2 WHERE userid = '$userid' AND userpassword = password('$userpassword')";

$result = odbc_do($link_id, $query);
if(!odbc_num_rows($result)) return 0;
else {
$query_data = odbc_fetch_row($result);
return $query_data[0];

function login_form() {
global $PHP_SELF;

<title>test session login</title>
<form method="post" action="<? echo $PHP_SELF ?>">
<div align="center"><center>
<table border="1" width="200" cellpadding="2">
<th width="18%" align="right" nowrap>id</th>
<td width="82%" nowrap>
<input type="text" name="userid" size="8">
<th width="18%" align="right" nowrap>password</th>
<td width="82%" nowrap>
<input type="password" name="userpassword" size="8">
<td width="100%" colspan=2" align="center" nowrap>
<input type="submit" value="login" name="submit">


if(!isset($userid)) {
else {
session_register("userid", "userpassword");
$username = auth_user($userid, $userpassword);
if(!username) {
echo "fail" .
"username/password invalid or not registered" .
"try again <br>\n";

echo "<a href=\"$PHP_SELF\">login</a><br>";

else echo "welcome $username";
Reply With Quote
  #2 (permalink)  
Old October 28th, 2004, 12:39 PM
Registered User
Join Date: Oct 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

any help?

Reply With Quote
  #3 (permalink)  
Old November 19th, 2004, 09:48 AM
Registered User
Join Date: Nov 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

Your first problem is form action

If you are not getting any errors that means your form action is wrong.
get rid of echo from action.

second and very basic problem is you are not checking $_POST['submit']...you form method is post so
you have to check if($_POST['submit']){all code}

try it

Reply With Quote
  #4 (permalink)  
Old November 19th, 2004, 04:34 PM
Friend of Wrox
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts

Hey there,

About the form action. Either way works fine, so it was fine before.

The second thing... I suggest you use if(isset()) instead of just if() like this:

if(isset($_POST['submit'])) {code}

I also suggest you using up-to-date methods for sessions! session_register and session_unregister are long depreciated. Read the manual for more info.

But, I believe your problem is here: you are not using superglobals. _POST variables and _SESSION variables are superglobals. For example, you seem to be getting the variable $userid from nowhere - use $_POST['userid'] instead, because you are passing values from the first page to the next page with the POST method.

Where will you be in 100 years?
Try new FreshView 0.2!
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 Blog - Cannot Login Access DB bmoran007 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 November 26th, 2007 10:53 AM
pass a login name as session variable abhishek0807 ASP.NET 2.0 Professional 1 March 30th, 2007 12:49 AM
User Login - For Session helga@trisyn.co.za ADO.NET 2 September 25th, 2005 12:20 PM
login page and session variables scdownload Classic ASP Basics 0 December 8th, 2003 06:13 PM
login and session sahabat_id2000 Beginning PHP 1 July 9th, 2003 03:24 PM

All times are GMT -4. The time now is 11:29 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.