Results 1 to 19 of 19
Thread: PHP login ?!
Hybrid View
-
16th August 2011 15:03 #1The Strat
Join Date: Aug:2010
Location:
Posts: 189
PHP login ?!
, . , . - , .
:
1. "members", user- ;
2. Index.php - ;
3. checklogin.php - ;
checklogin.php . , :
<?php
$host="localhost"; // Host name
$username="somename"; // Mysql username
$password="somepass"; // Mysql password
$db_name="somename"; // 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");
// username and password sent from form
$myusername=$_POST['someuser'];
$mypassword=$_POST['somepass'];
// 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:\design_\index.html");
}
else {
echo "Wrong Username or Password";
}
?>
. , !
!CPU: Athlon II X2 245/ MB: Asus M4A78LT-M LE/ RAM: Silicon Power 2 X 2 GB DDR3 1333MHz/ VIDEO: Integrated ATI Radeon 3000/ HDD: Hitachi Deskstar 500GB/PSU: SEASONIC S12 II Bronze-430GB/
-
16th August 2011 17:18 #2
-
16th August 2011 17:41 #3
?

- htaccess. cPanel - :
http://www.siteground.com/tutorials/...irectories.htm
- :
http://www.addedbytes.com/lab/passwo...with-htaccess/
, : if($count==1){ :
echo $sql; exit;
, , , echo-.
stripslashes , \ - .''? * *
- !
...
-
16th August 2011 18:50 #4
username password? $count.
: . : . : . : . : . : -. : -.
-
17th August 2011 10:20 #5The Strat
Join Date: Aug:2010
Location:
Posts: 189
-
17th August 2011 10:44 #6
HTML-a index.php :
Code:<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Login page</title> </head> <body> <form action="checklogin.php" method="post"> User: <input type="text" value="" name="someuser"> Pass: <input type="password" value="" name="somepass"> </form> </body> </html>
''? * *
- !
...
-
17th August 2011 11:47 #7The Strat
Join Date: Aug:2010
Location:
Posts: 189
: Wrong Username or Password
index.php
PHP Code:<body>
<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"><div align="center"><strong> !!! </strong></div></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> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
CPU: Athlon II X2 245/ MB: Asus M4A78LT-M LE/ RAM: Silicon Power 2 X 2 GB DDR3 1333MHz/ VIDEO: Integrated ATI Radeon 3000/ HDD: Hitachi Deskstar 500GB/PSU: SEASONIC S12 II Bronze-430GB/




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in