Ashley Nesh
Ashley Nesh

Reputation: 95

PHP FIle not found when i submit a form

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

Upvotes: 0

Views: 3963

Answers (2)

Bhavuk
Bhavuk

Reputation: 11

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.

Upvotes: 0

Jirka Hrazdil
Jirka Hrazdil

Reputation: 4021

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

Upvotes: 2

Related Questions