<?php
session_start();
require_once('database.php');

//login admin
if(isset($_POST['login']))
{
    $email=$_POST['email'];
    $password=$_POST['password'];
    
    $query="SELECT * from admin where email='$email' && password='$password'";
    $rec=db::getRecord($query);
    
    if($rec)
    { 
        $_SESSION['user_email']=$email;
        echo "<script>location='index.php'</script>";
    }
    else
    {
       echo "<script>location='sign_up.php?status=1'</script>";
    }
}
//update profile Data

if(isset($_POST['edit_user_profile'])){
    
    if($_SESSION['user_email']){
        $current_email=$_SESSION['user_email'];
        $name=$_POST['name'];
        $number=$_POST['number'];
        $password=$_POST['password'];
        $address=$_POST['address'];
        $query="Update customers SET name='$name',phone='$number',password='$password',address='$address' WHERE email='$current_email'";
        $update=db::query($query);   
        echo "<script>location='user.php'</script>";
      
    }

}



?>