0

Good Day. So, i have, after testing on a local WAMP server, deployed my site on a server and after i fill in my form and submit it, i get the "File not found" warning as well as blank page on the referred php file. i am not sure what could cause this. as i have extensively tested this on my local server without any hitches.

                    <form  action = "submit.php"  method="Post" >
                    <div class="row form-group">
                        <div class="col-md-12">
                            <!-- <label for="email">Email</label> -->
                            <input type="text" id="email" autocomplete="off"  name="email" class="form-control" placeholder="Your Email">
                        </div>
                    </div>

                    <div class="row form-group">
                        <div class="col-md-12">
                            <!-- <label for="subject">Subject</label> -->
                            <input type="text" autocomplete="off" id="password"  name="password" class="form-control" placeholder="Your Password">
                        </div>
                    </div>

                    <div class="form-group">
                        <input type="submit" value="Login" class="btn btn-primary">
                    </div>

                </form>     

And here is the submit.php

<?php
session_start();
require_once('connect.php');
if(isset($_POST) & !empty($_POST)){
    $useremail = mysqli_real_escape_string($connection,$_POST['email']);
    $userpassword = mysqli_real_escape_string($connection, $_POST['password']); 
    if (empty($useremail) || empty($userpassword)){
        header("Location: customerportal.php?login=empty");
        exit();
    }
    else{       
                $sql = "SELECT * FROM `USERS` where EMAIL = '$useremail';";
                $currenttime = date("Y-m-d H:i:s");
                $sqllastlogin = "UPDATE `users` SET `LASTLOGIN` = '$currenttime' where EMAIL = '$useremail';";
                $lastlogin = mysqli_query($connection,$sqllastlogin);
                $emailresult = mysqli_query($connection, $sql);
                $emailresultcheck = mysqli_num_rows($emailresult);
                //check if email exists


                if($emailresultcheck == 0){
                    header("Location: customerportal.php?login=invalidEmail");
                }
                else {                  
                    if($row = mysqli_fetch_assoc($emailresult)){

                        //dehash the password
                        $hashedPWDCheck = password_verify($userpassword,$row['ENCRYPTEDPWD']);
                        $isAdmin = $row['DHCADMIN'];
                        if($hashedPWDCheck == false){
                            header("Location: customerportal.php?login=passwordincorrect");
                            exit();
                        }
                        elseif($hashedPWDCheck == true){
                            $_SESSION['email'] = $useremail;
                            $_SESSION['username'] = $row['username'];
                            $_SESSION['entityname'] = $row['COMMERCIALTNITY_ID'];
                            $_SESSION['isAdmin'] = $isAdmin;

                            if($isAdmin == 1){
                                header("Location: admin.php");
                                exit();
                            }
                            elseif($isAdmin == 0){
                              header("Location: landingpage.php");
                              exit();
                            }

                        }
                }

                else{
                    header("Location: customerportal.php?login=invalid");   
                    exit(); 
                    }
                }               
    }   
}   
?>

Can you guys please assist. Here is the fodler structure of the server. enter image description here

5
  • 1
    share your folder structure, where is html page and where is php file submit.php Commented Jun 18, 2018 at 6:21
  • Can you provide a simple representation of your folder structure? I believe the browser is unable to locate the submit.php's location. This means that the location you provided at the form is not correct. if it is on the root you may need to add a forward slash '/' Commented Jun 18, 2018 at 6:26
  • Your above code will look for submit.php in the same directory as that of the form's directory. Are they both in the same directory? Commented Jun 18, 2018 at 6:26
  • Good day, Correct, all the files are deployed in the same root folder, thus no specified locations in the ACTION element. Commented Jun 18, 2018 at 6:32
  • Then try adding a forward slash in action = "/submit.php" . This is to assume that the files are in root folder. See this question to get the idea of slash and how it will affect stackoverflow.com/questions/17772692/… Commented Jun 18, 2018 at 6:34

2 Answers 2

2

Rename Submit.php to submit.php or change the letter case in your HTML form. File name case matters.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you.This worked. seems this wasnt an issue locally and became an issue once in the server.
Perhaps your local environment runs on Windows, which usually works in case-insensitive manner, while the server runs on Linux, which is case-sensitive.
0

Ensure that the file not found is in the same directory as the form HTML. Also, check that the pages you are redirecting to are also available in the same directory. It's important to check which page is it that is unavailable, to ensure it's not one of the pages you are redirecting to. Do inform in case of any progress!

Update: Make sure that the name of the file is exactly same as the file in the action in HTML.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.