Mysqli code will not be sent to the database

I searched here tirlessly and did not see to find a solution in order to make my code work, I try to create a simple registration system for a member to join my site, but I could not see how to get my PHP code to be sent to The database that I installed, here is the code.

<?php require 'lpgamers/connections/connect.php'; ?>
<?php

    if(isset($_POST['Register'])) {

        session_start();
        $FName = $_POST['First_Name'];
        $LName = $_POST['Last_Name'];
        $Email = $_POST['Email'];
        $PW = $_POST['Password'];

        $sql = $con->query("INSERT INTO lpg-user-db (Fname, Lname, Email, Password)Values('{$FName}', '{$LName}', '{$Email}', '{$PW}')");
    }
?>
        <div class="rightbody">
          <form id="registerform" name="registerform" method="post">
            <div class="formelement">
                <input name="First_Name" type="text" required class="tfield" id="First_Name" placeholder="First Name">
            </div>
            <div class="formelement">
                <input name="Last_Name" type="text" required class="tfield" id="Last_Name" placeholder="Last Name">
            </div>
            <div class="formelement">
                <input name="Email" type="email" required class="tfield" id="Email" placeholder="Email">
            </div>
            <div class="formelement">
                <input name="Password" type="password" required class="tfield" id="Password" placeholder="Password">
            </div>
            <div class="formelement">
                <input name="Register" type="submit" class="button" id="Register" value="Register">
            </div>
          </form>

I also have a connection file that is required and I have this setting and this is related to my database

<?php

$con = mysqli_connect("localhost", "root", "", "lpgamers-user-db");

if (mysqli_connect_errno()) {
  printf('Connect failed: %s\n', mysqli_connect_error());
  exit();
}

?>

Am I doing something wrong here, or is it just a database problem, am I using the Wamp server at the moment for testing?

Thanks in advance Rob.

+4
source share
1 answer

mysqli_error($con) , .

lpg-user-db

INSERT INTO lpg-user-db

, MySQL lpg MINUS user MINUS db, , , .

:

INSERT INTO `lpg-user-db`

, :

INSERT INTO lpg_user_db

:

Sidenote: - , mysqli_error($con) .

, , , MySQL , , John Bar & Grill, ; -, .

$FName = mysqli_real_escape_string($con, $_POST['First_Name']);

POST.

SQL-, .


, . .

:

:

+4

Source: https://habr.com/ru/post/1619121/


All Articles