php code and website functioning on localhost but not working on server : <p>Good day, my login script which i've been building on my localhost host wamp server is working perfectly well on the localhost but has refused to function well ever since i uploaded it to the server. it reads the username and password and if correct it does nothing but if wrong it alerts me that is it wrong. if correct it is supposed to redirect me to the home page. i've been struggling with it ever since on the server. please any one that will be of help will be much appreciated. it does the same thing too for my register page. it registers but doesnt give any feedback and also does not redirect to the login page but on the localhost everything seems fine
login script
       
                        </p>

<pre><code>                    &lt;?php
                    include 'connection.php';
                    if(isset($_SESSION['use']))   // Checking whether the session is already there or not if 
                                                  // true then header redirect it to the home page directly 
                     {
                        header("Location:home.php"); 
                     }

                    if(isset($_POST['login']))   // it checks whether the user clicked login button or not 
                    {
                         $user = $_POST['code'];
                         $pass = $_POST['user'];
                             if(!filter_var($_POST['code'], FILTER_VALIDATE_EMAIL)) {
                        echo "&lt;script&gt;alert('invalid Email Address')&lt;/script&gt;" ; // Use your own error handling ;)
                    }

                        if (!preg_match("/^[a-zA-Z0-9 ]*$/",$pass)) {
                          echo "&lt;script&gt;alert('Invalid password. Only letters, numbers and white space allowed')&lt;/script&gt;" ;
                        }
                         // Secure the credentials

                        // Check the users input against the DB.
                    $user = stripslashes($user);
                    $pass = stripslashes($pass);


                    $check=mysqli_query($conn, "SELECT * FROM userregister WHERE email = '$user'  AND password = '$pass'");
                        $checkrows=mysqli_num_rows($check);
                        if($checkrows&gt;0){  
                      while( $row = mysqli_fetch_assoc($check) ){
                       $_SESSION['use']=$row['email'];  

                              header("Location:home.php");
                              //  On Successful Login redirects to home.php

                            }}

                            else
                            {
                                    echo "&lt;script&gt;alert('Incorrect Login details')&lt;/script&gt;" ;
                                    header("refresh:0");      
                            }
                    }
                     ?&gt;
                    &lt;html&gt;
                    &lt;head&gt;
                        &lt;title&gt;Prediction Home&lt;/title&gt;
                        &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
                        &lt;link rel="icon" type="image/png" href="2.png"&gt;
                      &lt;meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"&gt;
                      &lt;link rel="stylesheet" type="text/css" href="w3.css"&gt;
                    &lt;/head&gt;
                    &lt;body&gt;
                    &lt;div class="topnav" id="myTopnav"&gt;
                      &lt;a href="index.php"&gt;Prediction Home&lt;/a&gt;
                      &lt;a href="javascript:void(0);" class="icon" onclick="myFunction()"&gt;X
                      &lt;/a&gt;
                    &lt;/div&gt;
                    &lt;div&gt;
                        &lt;h4&gt;Enter your Log-In details&lt;/h4&gt;
                    &lt;/div&gt;
                    &lt;div class="form"&gt;
                      &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']);?&gt;"&gt;
                        &lt;label for="E-mail"&gt;E-mail&lt;/label&gt;
                        &lt;input type="text" id="E-mail" name="code" required="required"&gt;
                        &lt;label for=""&gt;Password&lt;/label&gt;
                        &lt;input type="password" id="" name="user" required="required"&gt;
                        &lt;input type="submit" name="login" value="Log-In"&gt;
                      &lt;/form&gt;
                      &lt;p&gt;Forgot Password? &lt;a class="button" href="forgotpass.php"&gt;&lt;span&gt;Click Me!&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
                    &lt;/div&gt;

                    &lt;script&gt;
                    function myFunction() {
                        var x = document.getElementById("myTopnav");
                        if (x.className === "topnav") {
                            x.className += " responsive";
                        } else {
                            x.className = "topnav";
                        }
                    }
                    &lt;/script&gt;

                    &lt;/body&gt;
                    &lt;/html&gt;
</code></pre>

<p>register script</p>

<pre><code>         &lt;!doctype html&gt;
                    &lt;html&gt;
                    &lt;head&gt;
                        &lt;title&gt;Prediction Home&lt;/title&gt;
                        &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
                        &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"&gt;
                      &lt;meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"&gt;
                      &lt;link rel="stylesheet" type="text/css" href="w3.css"&gt;
                        &lt;link rel="icon" type="image/png" href="2.png"&gt;
                    &lt;/head&gt;
                    &lt;body&gt;
                    &lt;div class="topnav" id="myTopnav"&gt;
                      &lt;a href="index.php"&gt;Prediction Home&lt;/a&gt;
                      &lt;a href="javascript:void(0);" class="icon" onclick="myFunction()"&gt;X
                      &lt;/a&gt;
                    &lt;/div&gt;
                    &lt;div&gt;
                        &lt;h2&gt;REGISTRATION PAGE&lt;/h2&gt;
                    &lt;/div&gt;
                    &lt;div class="form"&gt;
                      &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']);?&gt;"&gt;
                        &lt;label for="fname"&gt;FULL NAME&lt;/label&gt;
                        &lt;input type="text" name="option" required="required"&gt;
                        &lt;label for="Email"&gt;E-mail&lt;/label&gt;
                        &lt;input type="text" name="option1" required="required"&gt;
                        &lt;label for="pass"&gt;PASSWORD&lt;/label&gt;
                        &lt;input type="password"  name="password" required="required"&gt;
                        &lt;label for="pass2"&gt;RE-ENTER PASSWORD&lt;/label&gt;
                        &lt;input type="password" name="password2" required="required"&gt;
                        &lt;input type="submit" name="register" value="Register"&gt;
                      &lt;/form&gt;
                       &lt;p&gt;Already Registerd? &lt;a class="button" href="login.php"&gt;&lt;span&gt;Sign In&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
                    &lt;/div&gt;
                    &lt;div id="page"&gt;&lt;/div&gt;
                    &lt;footer style="background-color: purple "&gt;
                    &lt;div style="text-align: center"&gt;  
                    &lt;h2&gt;Quick Links&lt;/h2&gt; 
                    &lt;a style="vertical-align: middle;color: white" href="index.php"&gt;Prediction Home&lt;/a&gt;   
                    &lt;a style="vertical-align: middle;color: white" href="contact.php"&gt;Contact Us&lt;/a&gt;
                    &lt;a style="vertical-align: middle;color: white" href="Store.php"&gt;My Store&lt;/a&gt;  
                    &lt;a style="vertical-align: middle;color: white" href="basic.php"&gt;Basic&lt;/a&gt; 
                    &lt;a style="vertical-align: middle;color: white" href="regular.php"&gt;Regular&lt;/a&gt; 
                    &lt;a style="vertical-align: middle;color: white" href="weekend.php"&gt;Weekend&lt;/a&gt;   
                    &lt;a style="vertical-align: middle;color: white" href="about.PHP"&gt;About&lt;/a&gt;
                    &lt;a style="vertical-align: middle;color: white" href="conditions.PHP"&gt;Terms &amp; Conditions&lt;/a&gt;

                    &lt;/div&gt; 

                    &lt;div style="text-align: center;"&gt;  

                    &lt;h2&gt;Contacts:&lt;/h2&gt; 
                    &lt;p style="color: white;vertical-align: middle"&gt;Call Us On:08136668621 &lt;br&gt;
                     MAil:user@predicthome.com&lt;/p&gt;
                    &lt;a href="https:/twitter.com/predicthome" class="fa fa-twitter"&gt;&lt;/a&gt;
                    &lt;a href="https://www.instagram.com/predictionhome/" class="fa fa-instagram"&gt;&lt;/a&gt;
                    &lt;a href="mailto:user@predictionhome.com" class="fa fa-yahoo"&gt;&lt;/a&gt;


                    &lt;/div&gt;

                    &lt;div style="color: yellow;text-align: center;"&gt;Prediction Home &amp;copy; &lt;?php echo date("Y");?&gt;&lt;/div&gt; 
                    &lt;/footer&gt;
                    &lt;script&gt;
                    function myFunction() {
                        var x = document.getElementById("myTopnav");
                        if (x.className === "topnav") {
                            x.className += " responsive";
                        } else {
                            x.className = "topnav";
                        }
                    }
                    &lt;/script&gt;
                    &lt;?php
                    include 'connection.php';
                    if(isset($_POST['register']))   // it checks whether the user clicked login button or not 
                    {
                         $option = $_POST['option'];
                         $option1 = $_POST['option1'];
                          $password = $_POST['password'];
                         $password2 = $_POST['password2'];
                             if(!filter_var($_POST['option1'], FILTER_VALIDATE_EMAIL)) {
                        echo "&lt;script&gt;alert('invalid Email Address')&lt;/script&gt;" ; // Use your own error handling ;)
                        }
                        if (!preg_match("/^[a-zA-Z0-9 ]*$/",$option)) {
                          echo "&lt;script&gt;alert('Invalid NAME. Only letters, numbers and white space allowed')&lt;/script&gt;" ;
                        }   
                         if (!preg_match("/^[a-zA-Z0-9 ]*$/",$password)) {
                          echo "&lt;script&gt;alert('Invalid password. Only letters, numbers and white space allowed')&lt;/script&gt;" ;
                        }
                            if (!preg_match("/^[a-zA-Z0-9 ]*$/",$password2)) {
                          echo "&lt;script&gt;alert('Invalid password. Only letters, numbers and white space allowed')&lt;/script&gt;" ;
                        }
                        if ($password !=$password2) {
                           echo "&lt;script&gt;alert('Password does not match')&lt;/script&gt;" ;
                        }
                         // Secure the credentials

                      // Check the users input against the DB.

                      $insert=mysqli_query($conn,"SELECT * FROM userregister WHERE email='$option1'");
                    $insertrows=mysqli_num_rows($insert);
                    if($insertrows&gt;0 || $password !=$password2|| !preg_match("/^[a-zA-Z0-9 ]*$/",$password) || !filter_var($_POST['option1'], FILTER_VALIDATE_EMAIL) ){
                      echo "&lt;script&gt;alert('Email already exists or Invalid Email address')&lt;/script&gt;" ;
                    }
                     else {
                      $check="INSERT IGNORE INTO userregister(name,email,password) VALUES('$option','$option1','$password')";
                    if ($conn-&gt;query($check) === TRUE) {
                      header("refresh:0;url=login.php");
                       echo "&lt;script&gt;alert('registered')&lt;/script&gt;" ;


                       $to = "$option1";
                    $subject = "Account Registration Successful";
                    $body = "Hi $option, Welcome to Predict Home. Your Favourite Site to select the best of Games that wll Bring you Good money\r\nWe hope we keep in touch and hear from you more often. \r\nVisit our site regularly to view our predicted Games from our highly acclaimed analysts.\r\nOnce again you are Welcome.\r\nPredict Home Admin";
                    $lheaders= "From: &lt;user@predicthome.com&gt;";
                    mail($to, $subject, $body, $lheaders);

                    }
                    }   


                    //send email


                    }
                     ?&gt;
                    &lt;/body&gt;
                    &lt;/html&gt;
</code></pre>
