I have the following HTML file where the user will enter their username and password and click on the submit button.
<form Name ="form1" Method ="POST" ACTION = "userlogin.php" id="form1">
<div id="main_body" class="full-width">
<label>Username:</label>
<input type = "text"
id = "usernameLogin"
name="pat_username">
<label>Password:</label>
<input type = "password"
id = "passwordLogin"
name="pat_password">
<input type="submit" onclick="click_button_login()" value="Login" name="submit" id="submit"/>
</div>
</form>
The PHP file should they connect to my database and check whether the users details entered are corrent. The database connection is there as I have tested this before. Once the user clicks on the submit button this error appears: Cannot POST /http-services/emulator-webserver/ripple/userapp/x/C/xampp/htdocs/xampp/glove_project_php/www/userlogin.php
<?php
if(isset($_POST["submit"])){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
//Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$newUsername = mysqli_real_escape_string($conn, $_POST['pat_username']);
$newPassword = mysqli_real_escape_string($conn, $_POST['pat_password']);
$result = $conn->query("SELECT * FROM tablename WHERE patient_username ='$newUsername' AND patient_password='$newPassword'");
if (mysqli_num_rows($result)) {
header("Location: mainmenu.html");
}
else
{
header("Location: index.html");
}
$conn->close();
}
?>
Is there a different way of calling this PHP file to work on an emulator? This code works perfectly on localhost.