Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysqli_connect('localhost','root','','polo');
- function login($email,$pass) {
- // function cannot access variable that is out of function scope, so you would need to use global
- global $con;
- $email = mysqli_real_escape_string($con,$email);
- $pass = mysqli_real_escape_string($con,$pass);
- $query = "SELECT * FROM customer WHERE email='".$email."' AND password='".$pass."'";
- // connection failure
- if (!$result = mysqli_query($con,$query)) {
- echo 'Error :' . mysqli_error($con);
- return false;
- }
- // no matching record
- if (mysqli_num_rows($result) == 0) {
- echo 'Warning: Invalid Login';
- return false;
- }
- return true;
- }
- if (ISSET($_POST['login'])) {
- $email=$_POST['email'];
- $pass=$_POST['pass'];
- if (login($email,$pass)) {
- echo 'Login Successful';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement