PDA

View Full Version : Trouble with php login code....please help



TTS Prez
10-06-2008, 12:40 AM
:confused:
I'm testing the Login script tutorial because I'd like to add this feature to certain pages of my site. I've created the pages in a folder on my server and have been playing with them, but can't seem to get them to work correctly.

It seems the page http://www.thetitlestor.com/Test%20Login%20Web/index.htm allows you to input info on a form that sends this info to http://www.thetitlestor.com/Test%20Login%20Web/fpdb/index.csv. I can open up this index.csv file and see the data there. However, the tutorial says to create a database using mysqldatabase and I have done that as well. The checklogin.php I believe has all the correct info for this database named thetitl1_thetitl and table named members

Now, I know my basic problem is that the form on /Test Login Web/index.htm is not sending the submitted data to this database named thetitl1_thetitl and table named members, it's sending it to the /Test Login Web/fpdb/index.csv file. And I know that the checklogin.php file is not checking the index.csv file it trying to check the thetitl1_thetitl database with the table members and therefore I'm recieving this error message

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/thetitl1/public_html/Test Login Web/checklogin.php on line 39
Wrong Username or Password"

This is the code from the index.htm page where the info is being submitted:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Border" content="l">
</head>

<body>
<p><font face="Arial Unicode MS" style="font-size: 11pt">This is a test site for
processing login info and access only.&nbsp; Should you have reached this site
or pages in error, please return back to the original pages of operations and we
apologize for any inconvenience.</font></p>

I know on this page my problem lies right here somewhere

<form method="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
<!--webbot bot="SaveResults" u-file="fpdb/index.csv" s-format="TEXT/CSV" s-label-fields="TRUE" b-reverse-chronology="FALSE" u-file="_private/form_results.csv" s-format="HTML/BR" s-label-fields="TRUE" b-reverse-chronology="FALSE" s-date-format="%m/%d/%Y" s-time-format="%I:%M:%S %p" s-builtin-fields="REMOTE_NAME REMOTE_USER HTTP_USER_AGENT Date Time" u-confirmation-url="Registration Successful.htm" u-validation-error-url="Registration Failed.htm" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" endspan i-checksum="43374" -->

<p align="justify">
<font face="Arial Unicode MS" style="font-size: 11pt">Information for
eliminating your vehicle title headaches and worries is just a few clicks
away.</font></p>
<p align="justify"><font face="Arial Unicode MS" style="font-size: 11pt">
Registration is free and is used for News Release and Advertising of our
services only.&nbsp; Please register and use our site info for free knowing
that your information, like all other information we obtain, is held in the
utmost of confidence and will never be sold to any outside party.</font></p>
<p align="justify">
<!--webbot bot="Validation" s-display-name="User Email" s-data-type="String" b-value-required="TRUE" --><input type="text" name="Useremail" size="39" value="Enter a valid email address"></p>
<p align="justify">
<!--webbot bot="Validation" s-display-name="User Name" s-data-type="String" b-value-required="TRUE" --><input type="text" name="Username" size="39" value="Enter your full name"></p>
<p align="justify" style="margin-top: 0; margin-bottom: 0">
<font face="Arial Unicode MS" style="font-size: 11pt">Enter a unique password
below, something easy to remember yet difficult for someone else to duplicate.</font></p>
<p align="justify" style="margin-top: 0; margin-bottom: 0">
<!--webbot bot="Validation" s-display-name="Password" b-value-required="TRUE" --><input type="password" name="Password" size="18"></p>
<p align="justify">
<!--webbot bot="Validation" s-display-name="Today's Date" b-value-required="TRUE" --><input type="text" name="Date" size="20" value="Enter today's date"></p>
<p align="justify">
<font face="Arial Unicode MS">By hitting submit you have read and agree with
the our Privacy Policies.&nbsp; You also understand that any miss use or
copyright infringements of this site will be prosecuted to the fullest extent
of the law.</font></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>
This is the code for the checklogin.php page where the info is being checked against the thetitl1_test database with the members table and the username thetitl1_thetitl:

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

And on this page I know it has something to do with this here

<body>
<?php
$host="localhost"; // Host name
$username="thetitl1_thetitl"; // Mysql username
$password="test"; // Mysql password
$db_name="thetitl1_test"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select databse.
mysql_connect("localhost", "thetitl1_thetitl", "test")or die("cannot connect");
mysql_select_db("thetitl1_test")or die("cannot select DB");




// useremail, username and password sent from form
$useremail=$_POST['useremail'];
$username=$_POST['username'];
$password=$_POST['password'];

// To protect MySQL injection (more detail about MySQL injection)
$useremail = stripslashes($useremail);
$username = stripslashes($username);
$password = stripslashes($password);
$useremail = mysql_real_escape_string($useremail);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$sql="SELECT * FROM $tbl_name WHERE useremail='$useremail' username='$username' and password='$password'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $useremail, $username and $password, table row must be 1 row

if($count==1){
// Register $useremail, $username, $password and redirect to file "login_success.php"
session_register("useremail");
session_register("username");
session_register("password");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>

</body>

I know what needs to be done I just don't know how or what to do with the script to make it happen. I've been playing with it for days but can't seem to get it right. I'd be truly greatful if some one could help with this matter.

If I have not mentioned I'm using windows frontpage on the rest of my site, I don't know if that make a diffence but I know the more info you have the better.

desperatly looking for help......TTS Prez

_________________
Owner of
thetitlstor.com
therealjuanvillareal.com
flooringandwindows.com
hurricanereadyplus.com

Author of Lost Title, Bonded Title & Duplicate Title How to e-Guide available @ http://www.thetitlestor.com/Lost%20Title%20e-Guide.htm