Login page with PHP
Before running this you have to install "PhpMyAdmin & server & mySql"or "wamp"or "xampp" in your pc. then open any browser and write in Url bar "Localhost/phpmyadmin" and here we make our Database,
Now open one more tab in browser and open "localhost/Filename". we all know the ip address of localhost is 127.0.0.1
- <?php
- mysql_connect("localhost","root","");
- mysql_select_db('database name');
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>My login</title>
- </head>
-
- <body>
- <form name="frm" id="frm" method="post" enctype="multipart/form-data">
- <table border="1" cellpadding="2" cellspacing="5" align="center" width="100%">
-
- <tr>
- <td>User Name</td>
- <td><input type="text" name="txtUser" /></td>
-
- </tr>
- <tr>
- <td>Password</td>
- <td><input type="password" name="txtPassword" /></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="btnSubmit" value="Login" /></td>
- </tr>
- </table>
- <?php
- if(isset($_POST['btnSubmit']))
- {
- echo $strQuery ="select User_Name, Password from TABLE NAME where User_Name='".$_POST['']."' && Password='".$_POST['Password']."'";
-
- echo $strRun =mysql_query($strQuery) or die("error".mysql_error());
- $count = mysql_num_rows($strRun);
- if($count==1)
- {
- ?>
- <script language="javascript">
- window.location='fetch.php';
- </script>
- <?php
- }
- else
- {
- echo"invalid user name or password!!!";
- }
- }
- ?>
-
- </form>
- </body>
- </html>