Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-06-2007, 01:52 PM   #1 (permalink)
metazai
Regular Contributor
 
Join Date: Apr 2004
Location: Orange County, CA
Posts: 124
metazai is on a distinguished road
Need a fresh look at this . . .

I'm sure this is something simple and stupid, but I need a fresh pair of eyes on it since I can't get it to work. It gives me a blank HTML page under the address checklogin.php instead of going to home.php like it's supposed to. The returned page is blank -- no error, no nothing -- no matter whether I type in the correct username and password, incorrect, or even submitting nothing in the form fields.

I'm reworking a (formerly working) login script. Here's the form:

HTML Code:
<form action="checklogin.php" method="post">
<table width="600" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td align="right" valign="middle">Username:</td>
    <td align="left" valign="middle"><input name="myusername" type="text" id="myusername" /></td>
  </tr>
  <tr>
    <td align="right" valign="middle">Password:</td>
    <td align="left" valign="middle"><input name="mypassword" type="password" id="mypassword" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit"value="LOGIN" /></td>
  </tr>
</table></form>
Here's where the form goes (checklogin.php):

PHP Code:
<?php
include('includes/connect.php');
$sql="SELECT * FROM users WHERE username='$myusername'";
$result=mysql_query($sql);
$row mysql_fetch_array($result);
if (!
$row['username']) {
echo(
"Incorrect username . . . click <a href=\"index.php\">here</a> to try again.");
}
else if (
$row['password'] != $mypassword) {
echo(
"Incorrect password for username ".$row['username']." . . . click <a href=\"index.php\">here</a> to try again.");
}
else {
session_start();
$_SESSION['sess_username'] = $row['username']; 
$_SESSION['level_display'] = $row['userlevel'];
header("location:home.php");
}
?>
And here's the include (connect.php):

PHP Code:
<?php
$dbhost 
'hostinfo';
$dbuser 'username';
$dbpass 'password';
$conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to mysql');
$dbname 'databasename';
mysql_select_db($dbname);
or die(
"Select DB Error:".mysql_error());
?>
Any thoughts would be appreciated.
metazai is offline   Reply With Quote
Old 04-06-2007, 08:09 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
did you change your connect script at all? i think u are using 'or die' wrong for the mysql_select_db part.

mysql_connect / or die looks like correct usage.

you can always use this connect script too.

if that's not it, i'd print some lines in checklogin.php to see which if/elseif/else you are hitting.
__________________
Mike
sde is offline   Reply With Quote
Old 04-24-2007, 10:35 AM   #3 (permalink)
hoopla
Recruit
 
Join Date: Apr 2007
Posts: 1
hoopla is on a distinguished road
Maybe I'm missing something but I don't see where you're extracting your post data in checklogin.php

Unless you've put it in somewhere before and didn't show it to us in your example.

ie:
PHP Code:
$myusername $_POST['myusername'];
$mypassword $_POST['mypassword']; 
Like I said unless I'm missing something you need to grab that data and put it into a variable before you can run a query on it.

J
hoopla is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fresh apache install sde Linux / BSD / OS X 3 01-05-2003 10:53 AM


All times are GMT -8. The time now is 10:09 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting