Simple form can't submit to database with php

Hello Frndz,

I am trying to connect a simple form to database but it can’t and fail without any error. Details given as below.

Pls give me further views to resolve issue.

There is an error, but I doubt you have error reporting on to see it.

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

I am not able to see your code. Please use following code to connect database.

<?php
$servername = "localhost";
$username = "username";
$password = "password";

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

// Check connection
if ($conn->connect_error){
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

This is for establishing connection to database. Now to connect form to database make form with one submit button as :<form method=”post”> <input type=”submit”></form>. Now you can check $_POST to get you submit value and use sql query to insert form data in database table.

Sponsor our Newsletter | Privacy Policy | Terms of Service