+2 votes
23 views

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

<?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 "alert('invalid Email Address')" ; // Use your own error handling ;)
                    }

                        if (!preg_match("/^[a-zA-Z0-9 ]*$/",$pass)) {
                          echo "alert('Invalid password. Only letters, numbers and white space allowed')" ;
                        }
                         // 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>0){  
                      while( $row = mysqli_fetch_assoc($check) ){
                       $_SESSION['use']=$row['email'];  

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

                            }}

                            else
                            {
                                    echo "alert('Incorrect Login details')" ;
                                    header("refresh:0");      
                            }
                    }
                     ?>
                    <html>
                    <head>
                        <title>Prediction Home</title>
                        <link rel="stylesheet" type="text/css" href="style.css">
                        <link rel="icon" type="image/png" href="2.png">
                      <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
                      <link rel="stylesheet" type="text/css" href="w3.css">
                    </head>
                    <body>

 Prediction Home
                      X
   Enter your Log-In details





                      ">
                        E-mail

                        Password
   Forgot Password? CLICK ME!


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


                    </body>
by (1.7k points)   | 23 views

Please log in or register to answer this question.

Related questions

0 votes
0 answers
+3 votes
0 answers
asked Mar 20 by Rehan | 40 views
+2 votes
0 answers
+4 votes
1 answer
asked Mar 29 by admin (1.3k points) | 43 views
+4 votes
1 answer
asked Mar 20 by Ron | 43 views
+3 votes
1 answer
+1 vote
0 answers




Welcome to Meansflow - Where Developers and Students Learn, Share, & Build Careers, where you can ask questions and receive answers from other members of the community.
117 questions
88 answers
42 comments
106 users