0

I am trying to learn how databases and local servers work from on a linux environment, but for some reason, data is not being added to my database. I am running Ubuntu 18.04 and am using XAMPP for the SQL and PHP servers. I will put my code below. My goal was to be able to enter data through an html form and have that data be added directly into my database.

<?php

$connection = mysqli_connect("localhost", "root", "****************"); // Establishing Connection with Server
$db = mysqli_select_db($connection, 'app_login'); // Selecting Database from Server

// Fetching variables of the form which travels in URL
$ID = $_POST['ID'];
$email = $_POST['Email'];
$username = $_POST['username'];
$password = $_POST['password'];

$query = mysqli_query($connection, "INSERT INTO 'users' (id, username, password, email) VALUES ('$ID', '$username', '$password', '$email')");

mysqli_close($connection); // Closing Connection with Server

?>

I am able to test this code fine in localhost through my web browser without any error messages. Any ideas on what the problem could be?

rellaElla
  • 1
  • 1
  • please put your php code here too – Mahdi Aslami Khavari May 17 '19 at 06:51
  • Can we have server side code? what you have done in login php file? – Shashank Shah May 17 '19 at 06:51
  • had to remove my html for the sake of formatting but my html is simply 4 forms for the respective fields (ID, email, username, password) – rellaElla May 17 '19 at 06:54
  • `'users'` should either be in backticks or no quotes at all. – Nigel Ren May 17 '19 at 06:54
  • 1
    `$_POST` variable do not "travel in URL." Use `$_GET` if you are using variables sent over parameters and read up on SQL injection because you are in danger of having your entire database deleted – tshimkus May 17 '19 at 06:55
  • 1
    Consider adding some error checking to your query execution to see what specifically is failing: `if (!mysqli_query($connection, "Your Query Here")) { echo mysqli_error($connection)); }` – tshimkus May 17 '19 at 07:02

0 Answers0