Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,170 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,295 people online right now. Registration is fast and FREE... Join Now!




Login Trouble

 
Reply to this topicStart new topic

Login Trouble

Mcbazzo
30 Aug, 2008 - 01:13 PM
Post #1

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

Ok i have this code:
CODE
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>

However when I click "Login" the page is not found.

The full code is:
CODE
<html>
<head>
<title>_-_Bliss Racing_-_</title>
</head>
<body>
<?php
echo "Welcome to _-_Bliss Racing_-_";
?>
</body>
</html>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>


and im trying to get it to go to another page call checklogin.php, the for this is as follows:
CODE
<?php
ob_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Define $myusername and $mypassword
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

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

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

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

ob_end_flush();
?>


Whats wrong?

This post has been edited by Mcbazzo: 30 Aug, 2008 - 01:36 PM
User is offlineProfile CardPM
+Quote Post

chili5
RE: Login Trouble
30 Aug, 2008 - 01:32 PM
Post #2

D.I.C Addict
****

Joined: 28 Dec, 2007
Posts: 763



Thanked: 4 times
My Contributions
What are you having problems with? Problems with a login script? If so, what error message are you getting?
User is offlineProfile CardPM
+Quote Post

Mcbazzo
RE: Login Trouble
30 Aug, 2008 - 01:38 PM
Post #3

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

How do I post print screens? if this is not possible heres all the page copied:

The page you're looking for wasn't found.
You can try searching here:
powered by Google
Brought to you by the isoHunt community toolbar
Feedback Why did I get this page?
If your community toolbar is currently active and you got to a page with the message "The page you're looking for wasn't found" next to the logo and name of your toolbar publisher, it means the following: Your community toolbar has detected that the page you were navigating to was not found, so you got to an alternative, more helpful Search page instead of the generic page usually displayed (called a 404 (http://en.wikipedia.org/wiki/404_error) or DNS error page). Your search automatically appears, so you can just click Search to try again. If you'd rather, you can type in a different search. To disable this feature, please click the Toolbar Options item in the drop-down menu under your toolbar's logo, open the Additional Settings tab, and clear the check box next to the text Fix "page not found" errors. Please note that this feature may not be available for all community toolbars. See how

©2008. Provided by Conduit.
User is offlineProfile CardPM
+Quote Post

chili5
RE: Login Trouble
30 Aug, 2008 - 01:42 PM
Post #4

D.I.C Addict
****

Joined: 28 Dec, 2007
Posts: 763



Thanked: 4 times
My Contributions
Well you should have posted your code before. The only thing I can think of is:

Your form is being submitted to something different from checklogin.php. Perhaps you have a typo in the filename for checklogin.php?

I think your sending the POST data to a page that doesn't exist.
User is offlineProfile CardPM
+Quote Post

Mcbazzo
RE: Login Trouble
30 Aug, 2008 - 01:50 PM
Post #5

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

QUOTE(chili5 @ 30 Aug, 2008 - 02:42 PM) *

Well you should have posted your code before. The only thing I can think of is:

Your form is being submitted to something different from checklogin.php. Perhaps you have a typo in the filename for checklogin.php?

I think your sending the POST data to a page that doesn't exist.

How could I solve this?

also wouldn't this send it to checklogin?
CODE
<form name="form1" method="post" action="checklogin.php">


Database:

SQL query:
SELECT *
FROM `members`
LIMIT 0 , 30
Profiling
[ Edit ] [ Explain SQL ] [ Create PHP Code ] [ Refresh ]


row(s) starting from record #
in mode and repeat headers after cells

Full Texts id username password
Edit Delete 1 Tom 1234
With selected: Check All / Uncheck All With selected: Change Delete Export


row(s) starting from record #
in mode and repeat headers after cells

Query results operations Print viewPrint view Print view (with full texts)Print view (with full texts) ExportExport CREATE VIEWCREATE VIEW
User is offlineProfile CardPM
+Quote Post

chili5
RE: Login Trouble
30 Aug, 2008 - 01:54 PM
Post #6

D.I.C Addict
****

Joined: 28 Dec, 2007
Posts: 763



Thanked: 4 times
My Contributions
Yes that does send it to checklogin, however if your getting a 404 when you submit the form, then it isn't going there. Are you sure you actually have a file called checklogin.php?

Maybe you have a typo in the page name. A "not found" error means simply that the page doesn't exist that is being requested.
User is offlineProfile CardPM
+Quote Post

Mcbazzo
RE: Login Trouble
30 Aug, 2008 - 02:24 PM
Post #7

New D.I.C Head
*

Joined: 29 Aug, 2008
Posts: 37

I have found the problem the page is .php.php therefore unable to find, i have now fixed it thankyou.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:07AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month