Write a PHP program to accept username and password from the user. Validate it against the login table in the database. If there is a mismatch between username and password, then, display the error message as ―invalid user name and password; else display the message as ―Login successful‖ on the browser.

Userpass.html
<html>
<body>
<form method=post action="Userpass.php">
Enter UserName : <input type=text name="t1"><br><br>
Enter Password   : <input type=text name="t2"><br><br>
<input type=submit value="Log In">
</form>
</body>
</html>
Userpass.php
<?php
          $user=$_POST['t1'];
          $pass=$_POST['t2'];
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("userpass") or die(mysql_error());
         $result=mysql_query("select * from login");
while($row=mysql_fetch_array($result))
         {
           if((strcmp($user,$row['user'])==0) && (strcmp($pass,$row['pass'])==0))
echo"Login Successful";
else
echo"Invalid user";
        }
?>

Comments

Popular posts from this blog

Create an XML file which gives details of books available in “ABC Bookstore” from following categories. 1)      Technical 2)      Cooking 3)      Yoga And elements in each category are in the following format.     …….     …….     ……. Save the file as “Book.xml” Create an application that reads “Book.xml” file into simple XML object. Display attributes and elements. (Hint:- Use simple_xml_load_file() function). 

Write a PHP program to create a simple calculator that can accept two numbers and perform operations like add, subtract, multiplication and divide (using Self Processing form)

Write an Ajax program to print the content of the myfile.dat. This code asks the user to click a button, fetches data from the server using Ajax techniques and displays that data in the same web page as the button without refreshing the page