Thursday, 30 August 2018
Subscribe to:
Post Comments (Atom)
<html>
<form action='checklogin.php' method='POST'
<strong>username:</strong><br />
<input name="myusername" type="text" id="myusername"><br />
<strong>password:</strong><br />
<input name="mypassword" type="password" id="mypassword"><br />
<input type="submit" name="Submit" value="Login">
</form>
</html>
<?php
$host="localhost";
$username="++++++";
$password="++++++";
$db_name="++++++";
$tbl_name="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
echo "hey, " . $myusername . ", you are correctly signed in."
?>
mysql_connect()
returns a connection resource that you need to pass to a call to mysql_query()
, along with a SQL query to determine if the credentials match a user in the database.$con = mysql_connect($server, $dbuser, $dbpass);
mysql_select_db($db_name)
$myusername
exists, and that the password for $myusername
equals $mypassword
. You mentioned the table name was members.$user = mysql_query("select password from members where username = '" .
mysql_real_escape_string($_POST['myusername']) . "'", $con);
if(mysql_num_rows($user) == 0) {
// Username not found
}
$user = mysql_fetch_assoc($user);
if($_POST['password'] != $user['password']) {
// Password does not match
}
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment