RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1133 | Replies: 3
Reply
Join Date: Mar 2006
Posts: 14
Reputation: bbb777b7 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bbb777b7 bbb777b7 is offline Offline
Newbie Poster

sign-in to checklogin help

  #1  
Apr 20th, 2006
I need to make a login thing. I got some codes from another person, but it doesn't work for me. I double and tripled check to see if my apache server and mysql were set up correctly and they were. help?

sign-in:

[html]<html>
<head>

<title>无标题文档</title>
</head>

<body>
<form action="checklogin.php" method="post">

<br>
<table border="0" cellpadding="2" cellspacing="2" width="42%">
<tbody><tr>
<td width="14%">Name</td><td width="86%">
<input style="background-color: rgb(255, 255, 160);" name="username" class="textbox" type="text"><br>
</td>
</tr>
<tr>
<td width="14%">Password</td>
<td width="86%">
<input name="password" class="textbox" type="password">
</td>
</tr>
<tr>
<td colspan="2">
<input name="Submit" value="Submit" type="submit">
</td>
</tr>
</tbody></table></form>

</body>
</html>[/html]

============================================

checklogin:

[php]<?php

session_start();
$name = trim(addslashes($_POST["username"]));
$pass = trim(addslashes($_POST["password"]));
// you may also wish to perform extra security checks here, make sure the input is valid. adding slashes would be a good start
mysql_connect("localhost", "test_user", "password_123") or die("Couldn't Connect to Server " . mysql_error());
mysql_select_db("blog") or die("Database not found " . mysql_error());
$result = mysql_query("SELECT * FROM users WHERE username ='". $name . "' AND password='". sha1($pass) . "' ");
while ($row = mysql_fetch_array($result)){
if(mysql_num_rows($result) == 1){
print ("<h2>Login Details Verified, You May Click Below to Proceed</h2><BR>");
print ("<a href=\"blog.php\"Continue"</a>");
// You may want to assign a session variable here. This variable can then be checked on later pages that require the user to be logged in.
$_SESSION[ legal ] =1;
}

else {
Print "<h2>Invalid Username/Password</h2><BR>";
print "<a href=\"javascript:history.back(-1)\">Go Back, to try again.</a>";

}
}


?>[/php]


plz see watz wrong. thx
Last edited by cscgal : May 3rd, 2006 at 11:36 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: sign-in to checklogin help

  #2  
Apr 20th, 2006
You may want to check the following:

1. Do you get any error message for database connectivity?
2. Do you already have the table 'users' and all fields ready?
3. Have you stored password is sha1 encrpted? You may need to sha1($pass) as a separate line before query to database
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Mar 2006
Posts: 14
Reputation: bbb777b7 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bbb777b7 bbb777b7 is offline Offline
Newbie Poster

Re: sign-in to checklogin help

  #3  
Apr 23rd, 2006
There is not error message for the database

I have all the tables and fields in the sql.

I think the problem is that my browser can't get through the lines:
$name = trim(addslashes($_POST["username"]));
$pass = trim(addslashes($_POST["password"]));

When i put the lines there, the page just goes blank
Reply With Quote  
Join Date: Mar 2006
Posts: 14
Reputation: bbb777b7 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bbb777b7 bbb777b7 is offline Offline
Newbie Poster

Re: sign-in to checklogin help

  #4  
Apr 23rd, 2006
btw, how do u make sure that it is SHA ecripted?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:52 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC