<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
require_once "check_admin.php";
require_once 'database.php';
class emails extends database
{
   public function index($data)
    {
        return $this->update('email', $data);
    }
    
    public function getEmail()
    {
        return $this->fetchRow('email');
    }
}
$cat = new emails();
$msg="";
if(isset($_GET['message']))
{
    $msg=$_GET['message'];
}
if(isset($_POST['data']))
{
    $data=$_POST['data'];
    if(trim($data['email']) == '')
    {
        $msg.= "Email is required<br/>";
    }
    
    if($msg=="")
    {
         $res = $cat->index($data);
            if($res)
            {
                    header('Location:emails.php?message=Emails Updated Successfully');
            }
            else {
                $msg = 'Something Went Wrong';
            }
    }
}

$email = $cat->getEmail();


 include 'header.php';
 ?>
<div class="ordes-content">
    <div class="container midle-order">
        <div class="row">
            <?php include 'menu.php';?>
            <div class="col-md-9">
                <div class="order-wraper">
                    <div class="col-md-12">
                        <h1>Update Email</h1>
                        <?php if($msg !=''){echo '<span class="alert alert-danger pull-left">'.$msg.'</span>';}?>
                    </div>
                    <div class="clearfix"></div>
                    <div class="col-sm-12">
                        <div class="order-contact">
                            <div class="row edit-user-box">
                                <div class="col-sm-12">
                                    <div class="row">
                                    
                                    <form method="post">
                                        <div class="col-md-12">
                                            <label>Emails</label>
                                            <input type="text" name="data[email]" value="<?php echo $email['email'] ?>" />
                                        </div>
                                       
                                        <div class="col-md-12 botm-cont">
                                            <button type="submit" class="track-btn">UPDATE EMAIL</button>
                                        </div>
                                    </form>
                                    </div>
                                </div>
                            </div>                            
                        </div>
                    </div>
                </div>
               
                
            </div>
        </div>
    </div>
</div>


    <script>
    $(document).ready(function(){
        $('.activ-cat').removeClass('activ-cat');
        $('#email-menu').addClass('activ-cat');
    }); 
</script>
<?php include 'footer.php';?>