Sunday, September 15, 2013

LOGIN (PART-1)

Example: 1


<?php

$username = $_POST['username'];
$password = $_POST['password'];

if($username && $password)
{

$connect = mysql_connect("localhost","root","") or die("Couldn't connect!");
mysql_select_db("phplogin") or die("Couldn't find db");

}


?>



Example: 2


<?php

$username = $_POST['username'];
$password = $_POST['password'];

if($username && $password)
{

$connect = mysql_connect("localhost","root","admin") or die("Couldn't connect!");
mysql_select_db("phplogin") or die("Couldn't find db");

}
else
   die("Please enter  username and Password!");

?>



Example 3



<html>

<form action='login.php' method='POST'>
<input type='text' name='username'><br>
<input type='password' name='password'><br>
<input type='submit' name='Log in'>
</form>

</html>




Example 4



<html>

<form action='login2.php' method='POST'>
Username: <input type='text' name='username'><br>
Password: <input type='password' name='password'><br>
<input type='submit' name='Log in'>
</form>

</html>





No comments: