Pages are working fine on localhost but not running on the hosting server



PHP Snippet 1:

<?php
 $mail = $_POST['id'];
 $pass = $_POST['password'];
// check to make sure both fields are entered
 if ($mail == '' || $pass == '')
 {
 // generate error message
 $error = 'ERROR: Please fill in all required fields!';

 // if either field is blank, display the form again
header("Location: " .$_SERVER['HTTP_REFERER']);
 } 
else 

{
         include('dbc.php');
         $sql=mysql_query("SELECT * from member where email='$mail' and  password='$pass'")or die(mysql_error());
         $num=mysql_num_rows($sql);
         if($num>0)
     {
               $admin_data=mysql_fetch_array($sql);
           session_start();
           $_SESSION['usermatri_id']=$admin_data['mid'];

           header("Location: dashboard.php");    

        }
     else 
     {
        header('Location:' . $_SERVER['PHP_SELF']);
     }


}

?>

PHP Snippet 2:

 if ($phone == '' || $pass == '')
 {
 // generate error message
 $error = 'ERROR: Please fill in all required fields!';

 // if either field is blank, display the form again
header("Location: " .$_SERVER['HTTP_REFERER']);
 } else{
//the juice...
}

PHP Snippet 3:

$_POST['id'] = 123456;
$_POST['password'] = 123456;

PHP Snippet 4:

ini_set('display_errors',1); 
error_reporting(E_ALL);

mysql_connect("localhost","root","")or die(mysql_error('cannot connect'));
mysql_select_db("matrimony");

PHP Snippet 5:

    //index.php
<?php
$conn = mysqli_connect("localhost","root","","md5login");
session_start();

if (isset($_SESSION["Email"]))
{
    header("location:welcome.php");
}
if (isset($_POST["register"]))
{
    if (empty($_POST["Email"]) && empty($_POST["Password"]))
    {
        echo '<script>alert("Both Field Are Required")</script>';
    }
    else
        {
        $Email = mysqli_real_escape_string($conn, $_POST["Email"]);
        $Password = mysqli_real_escape_string($conn, $_POST["Password"]);
        $Password = md5($Password);
        $query = "INSERT INTO client (Email, Password) VALUES('$Email','$Password')";
        if (mysqli_query($conn, $query))
        {
            echo '<script>alert("Rgistration Done")</script>';
        }
    }
}
    if (isset($_POST["login"]))
    {
        if (empty($_POST["Email"]) && empty($_POST["Password"]))
        {
          echo '<script>alert("Both r Required")</script>';
        }
        else
        {
            $Email = mysqli_real_escape_string($conn, $_POST["Email"]);
            $Password = mysqli_real_escape_string($conn, $_POST["Password"]);
            $Password = md5($Password);

            $query = "SELECT * FROM client WHERE Email = '$Email' AND Password = '$Password'";
            $result = mysqli_query($conn, $query);

            if (mysqli_num_rows($result) > 0)
            {
                $_SESSION['Email'] = $Email;
                header("location:welcome.php");

            }
            else
            {
                echo '<script>alert("Wrong User Details")</script>';
            }
        }
    }

?>
<html>
<head>
    <title>Login And Registeration</title>
</head>
<body>
<div class="container" style="width:500px;">
<h3 align="center"> Login And Register </h3>
    <br>
    <?php
    if (isset($_GET["action"]) == "login")
    {
    ?>
    <h3 align="center">Login</h3>
    <br>
        <form method="post">
            <label>Enter Email</label>
            <input type="text" name="Email">
            <br/>
            <label>Enter Password</label>
            <input type="text" name="Password">
            <br/>
            <input type="submit" name="login" value="Login">
            <br/>
            <p align="center"><a href="index.php">Register</a></p>
        </form>
    <?php
    }
    else
    {
    ?>
        <h3 align="center">Register</h3>
        <br>
        <form method="post">
            <label>Enter Email</label>
            <input type="text" name="Email">
            <br/>
            <label>Enter Password</label>
            <input type="text" name="Password">
            <br/>
            <input type="submit" name="register" value="register">
            <br/>
            <p align="center"><a href="index.php?action=login">Login</a></p>
        </form>
    <?php
    }
    ?>


</div>
</body>
</html>

//welcome.php
<?php
session_start();
if (!isset($_SESSION["Email"]))
{
    header("location:index.php?action=login");
}
?>
<html>
<head>
    <title>Welcome Page</title>
</head>
<body>
<?php
echo '<h2>Welcome - '.$_SESSION["Email"].'</h2>';
echo '<a href="logout.php">Logout </a>';
?>

</body>
</html>

//logout.php

<?php
session_start();
session_destroy();
header("location:index.php?action=login");
?>