phpMyAdmin records into table are not seen

How to use phpmyadmin.... phpmyadmin related arguments. Even phpMyAdmin issues

Moderators: egami, macek, gesf

Post Reply
amanea4
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Sep 29, 2021 4:35 am

Wed Sep 29, 2021 4:52 am

Hello everyone,

I am new to this forum and also into php:)

I have a problem sending data from a html form to MariaDB using PHP. I have connection established and right now I am just able to see records ( id ) and not values I entered.

My html code is simple :

Code: Select all

<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
And after this I am using the php to send data to MariaDB, the records are not visible unfortunately :

Code: Select all

<?php
$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);
}

$sql = "INSERT INTO Form (name, email)
VALUES ('$_POST[post_name]', '$_POST[post_email]')";

if ($conn->query($sql) === TRUE) {
  echo "New record created successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
You can see in the attachments the problem(test.png && db.png). I enter records and the I can not see them in phpmyadmin on the db.
I am using CentOS 7, PHP version: 7.2.34, nginx/1.21.3, and phpmyadmin 4.4.15.10, 5.5.68-MariaDB Server and database structure is the following ( attachments db.png)


Thank you in advance and sorry if someone posted already this topic.
Alex
Attachments
db.PNG
db.PNG (94.87 KiB) Viewed 183 times
test.PNG
test.PNG (4.11 KiB) Viewed 183 times
php.PNG
php.PNG (41.38 KiB) Viewed 183 times
User avatar
Strider64
php-forum GURU
php-forum GURU
Posts: 429
Joined: Sat Mar 23, 2013 8:24 am
Location: Livonia, MI
Contact:

Wed Sep 29, 2021 6:27 am

I haven't used mysqli in a long time, so I won't be able to help you out. However, I would recommend using PDO as it would be easier. Here's a good link that I still use from time to time - https://phpdelusions.net/pdo

From the looks of the screenshots that is the structure of the database table and not the data. You created the table, but it isn't working when you try to add values to it. The id has to be auto incremented and a primary key.
Life is a fig newton of your imagination! https://www.phototechguru.com/
simonbrahan
php-forum Super User
php-forum Super User
Posts: 153
Joined: Mon Jun 08, 2020 2:00 am
Contact:

Thu Sep 30, 2021 5:39 am

Your code references $_POST[post_name] and $_POST[post_email]'), but these names aren't on your form; you've called the inputs "name" and "email". Change your parameter names to $_POST['name'] and $_POST['email'] and it should work.

As an aside, PHP can tell you about things like this if you let it. Look into enabling error reporting on your environment.
Post Reply