The PHP input data is no show in the PHPMYADMIN(mySQL)

Hi guys , my coonection to mySQL


is successfully but it is not show in the PHPMYADMIN(mySQL)
Then, below is my code:

<?php

require 'Connection.php';

if(isset($_POST['submit']))

{

    $name = $_POST["username"];

    $email = $_POST["email"];

    $password = $_POST["password"];

    $query = "INSERT INTO `register`{name, email, password) VALUES ('$name', '$email', '$password')";

    mysqli_query($conn, $query);

}

?>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>SignUP</title>

   

    <! -- front awesome cdn link -->

    <link rel ="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">

    <!-- custom css file link -->

    <link rel = "stylesheet" href="style.css">

</header>

<body>

<div class = "wrapper">

    <span class ="icon-close"><ion-icon name="arrow-back-outline"></ion-icon></span>

    <div class="form-box login">

        <h2>Sign up</h2>

        <form action="#"  method="post" autocomplete ="off" >

        <div class = "input-box">

            <span class = "icon"><ion-icon name="Person"></ion-icon></span>

            <input type="text" name="username" required >

            <label>Username</label>

            <div class="input-box">

            <span class = "icon"><ion-icon name="mail-outline"></ion-icon></span>

            <input type="email" name="email"required >

            <label>Email Address</label>

                   

        <div class="input-box">

            <span class = "icon"><ion-icon name="lock-closed-outline"></ion-icon></span>

            <input type="password" name="password"required>

            <label>Password</label>

       

        <button type= "submit" class = "btn">Sign UP</button>

        <div class= "login-register">

        <p>Already have an account?<a href="#" class = "login-link">Login</a></p>

        </div>

        </form>

       

        <script src ="script.js" ></script>

        <script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>

        <script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>

       

   

</body>

</html>

Then,below is my connection code:

<?php

$servername = "localhost";

$username = "root";

$password = "";

$database = "register";

// Create connection

$conn = new mysqli($servername, $username, $password,$database,3306 );

?>

can help me to solve this problem? Thank you very much.

There’s no form field named ‘submit’, so that conditional statement is always false.

You can see what the form data is by adding the following line of code near the top of your php script -

echo '<pre>'; print_r($_POST); echo '</pre>';

You shouldn’t attempt to detect if the submit button is set, anyways. There are real cases where it won’t be. You should instead detect if a post method form was submitted -

if($_SERVER['REQUEST_METHOD'] === 'POST')

You should NOT put external, unknown, dynamic values directly into an sql query statement, where sql special characters in a value can break the sql query syntax, which is how sql injection is accomplished. You should use a prepared query instead. If it seems like using the mysqli extension is overly complicated, especially when dealing with prepared queries, it is. This would be a good time to switch to the much simpler and more modern PDO extension.

You should also validate your resulting web pages at validator.w3.org There are a number of errors in the markup that should be corrected.

Thank you for helping me to solve problem! Thank you very much :pleading_face:

my login page face problem again, can you help me ?
Below is my code:

<?php

include 'Connection.php';

try {

    if ($_SERVER['REQUEST_METHOD'] === 'POST') {

        $email = $_POST["email"];

        $password = $_POST["password"];

        // Create a PDO instance

        $pdo = new PDO("mysql:host=$servername;dbname=$database", $username, "");

        // Prepare an INSERT statement

        $stmt = $pdo->prepare("INSERT INTO `login` (email, password) VALUES (?, ?)");

       

        // Execute the statement with the data

        if ($stmt->execute([$email, $password])) {

            echo "Login Successfully!";

        } else {

            $errorInfo = $stmt->errorInfo();

            echo "Error: " . implode(" - ", $errorInfo);

        }

    }

} catch (PDOException $e) {

    echo "Error: " . $e->getMessage();

}

 

?>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Login</title>

   

    <!--- front awesome cdn link -->

    <link rel ="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">

    <!-- custom css file link -->

    <link rel = "stylesheet" href="style.css">

</header>

<body>

<div class = "wrapper">

    <span class ="icon-close"><ion-icon name="arrow-back-outline"></ion-icon></span>

    <div class="form-box login">

        <h2>Login</h2>

        <form action="#"

        <div class = "input-box">

            <span class = "icon"><ion-icon name="mail-outline"></ion-icon></span>

            <input type="email"required>

            <label>Email Address</label>

       

        <div class="input-box">

            <span class = "icon"><ion-icon name="lock-closed-outline"></ion-icon></span>

            <input type="password"required>

            <label>Password</label>

       

        <button type= "submit" class = "btn" style="margin-top: 3em;">Login</button>

        <div class= "login-register">

            <p>Don't have an account?<a href="#" class = "register-link">Sign-Up</a></p>

        </div>

        </form>

       

        <script src ="script.js" ></script>

        <script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>

        <script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>

       

   

</body>

</html>
Sponsor our Newsletter | Privacy Policy | Terms of Service