我怎样才能运行我的html登录页面已经连接到mysql数据库没有得到下面的服务器错误;

1mrurvl1  于 2022-12-10  发布在  Mysql
关注(0)|答案(1)|浏览(200)

This page isn’t working right nowIf the problem continues, contact the site owner. HTTP ERROR 405.
i have properly connected my database with php by using the code below and it prints out registration successfuly.

<?php
    $u_name = $_POST['username'];
    $u_password = $_POST['password'];

    $servername = "localhost";
    $username = "root";
    $password = "***";
    $dbName = "test";

    //create connection
    $conn = new mysqli($servername, $username, $password, $dbName);

    //check connection
    if($conn->connect_error){
        die("Connection Failed: " . $conn->connect_error);
    }
    else{
        $stmt = $conn->prepare("insert into login(username, password) values(?, ?)");
        $stmt->bind_param("ss", $u_name,$u_password);
        $stmt->execute();
        echo("Registration Successfully...");
        $stmt->close();
        $conn->close();
    }
    
?>

but once i add method="post", action="name of my php file", on my form in html code, and run the server, i can clearly enter the information in the login form but once i submit, i get the error message: This page isn’t working right nowIf the problem continues, contact the site owner. HTTP ERROR 405. in cmd i get: Closed without sending a request; it was probably just an unused speculative preconnection
i'm expecting that on submit button click the entered information registers in my database table and i can query it. But instead i get the error and it the entered information doesn't enters in my database table

sr4lhrrt

sr4lhrrt1#

Your echo("Registration Successfully..."); does not check if it was really successful or not.
Try to add this code:

if($conn->query($stmt) === TRUE){
 echo "Registered Successfully";
}else{
 echo "LMAO, Something went wrong: ".$conn->error;
}

I assume that you are using a local server so it should show you some errors to give you idea of what went wrong.

相关问题