How do I handle not found conditions?

This is a discussion on How do I handle not found conditions? within the MySQL Database forums, part of the Database Forums category; The code below is my login validation script - check_login.php. I have been testing with a non-existent user and ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-09-2007
Big Moxy
 
Posts: n/a
Default How do I handle not found conditions?

The code below is my login validation script - check_login.php. I have
been testing with a non-existent user and end up with a blank page.
Can someone please tell me what I'm doing wrong?

http://projects.missioninternet.com/dynamixsi/login.php

Thank you!
Tim

<?php
session_start();
require_once("Connections/usersDB.php");

// username and password sent from signup form
$userID=$_POST['userID'];
$password=$_POST['password'];
$userType=$_POST['clientType'];

// encrypt password
$encrypted_password=md5($password);
$_SESSION["password"] = $encrypted_password;

// if password encryption is not used
//$sql="SELECT * FROM $table_name WHERE userName='$userID' and
password='$password'";
//$result=mysql_query($sql);

// if password encryption is used
$sql="SELECT * FROM $table_name WHERE userName = '$userID' and
userPassword = '$encrypted_password'";
$result=mysql_query($sql)or die($sql.' failed because
'.mysql_error());
if (!$result) {
$_SESSION['msg'] = "mysql query failed";
}
else {
$rows = mysql_num_rows($result) or die(mysql_error());
if($rows > 0) {
$_SESSION['msg'] = "Success Rows: ".$rows;
}
else {
// Return to login page with error message
$_SESSION['msg'] = "Your email address or password is incorrect. If
this is the first time you are using our system, enter your email
address, desired password and indicate your user status then click
'Register' instead of 'Login'.";
}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Error</title>
</head>

<body>
<br /><br />
<div align="center" style="border:5px; border-color:#3366FF; width:
410px;">
<table width="400" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><?php echo $_SESSION['msg']; unset($_SESSION['msg']); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="login.php">Click here to continue.</a></td>
</tr>
</table>
</div>
<br />
</body>
</html>

Reply With Quote
  #2 (permalink)  
Old 11-09-2007
Rik Wasmus
 
Posts: n/a
Default Re: How do I handle not found conditions?

On Fri, 09 Nov 2007 18:10:33 +0100, Big Moxy <bigmoxy@gmail.com> wrote:

> The code below is my login validation script - check_login.php. I have
> been testing with a non-existent user and end up with a blank page.
> Can someone please tell me what I'm doing wrong?


comp.lang.php / alt.php / alt.comp.lang.php / etc.
--
Rik Wasmus
Reply With Quote
  #3 (permalink)  
Old 11-09-2007
Big Moxy
 
Posts: n/a
Default Re: How do I handle not found conditions?

On Nov 9, 9:21 am, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Fri, 09 Nov 2007 18:10:33 +0100, Big Moxy <bigm...@gmail.com> wrote:
> > The code below is my login validation script - check_login.php. I have
> > been testing with a non-existent user and end up with a blank page.
> > Can someone please tell me what I'm doing wrong?

>
> comp.lang.php / alt.php / alt.comp.lang.php / etc.
> --
> Rik Wasmus


I thought this was a mysql question. sorry.

Reply With Quote
  #4 (permalink)  
Old 11-10-2007
Peter H. Coffin
 
Posts: n/a
Default Re: How do I handle not found conditions?

On Fri, 09 Nov 2007 09:23:56 -0800, Big Moxy wrote:
> On Nov 9, 9:21 am, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Fri, 09 Nov 2007 18:10:33 +0100, Big Moxy <bigm...@gmail.com> wrote:
>> > The code below is my login validation script - check_login.php. I have
>> > been testing with a non-existent user and end up with a blank page.
>> > Can someone please tell me what I'm doing wrong?

>>
>> comp.lang.php / alt.php / alt.comp.lang.php / etc.
>> --
>> Rik Wasmus

>
> I thought this was a mysql question. sorry.


If you can use the others to prove that you're coming up with zero rows
returned, or can produce a mysql error, then it's a mysql question. But
a dump of php with "It it outputs a blank page" is more likely a php
syntax issue as this is what happens when the interpreter goes into a
snit before getting to your HTML.

--
I got told by a friend's ex-girlfriend that she could tell I was
a Linux geek from the way I *walked*.
-- Skud
Reply With Quote
Reply


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

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



All times are GMT +1. The time now is 10:41 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0