details entry

mail@pastecode.io avatar
unknown
php
2 years ago
941 B
2
Indexable
Never
<?php
$server_name = "localhost";
$username = "root";
$password = "";
$database_name = "database123";

$conn = mysqli_connect($server_name, $username, $password, $database_name);
//now check the connection
if (!$conn) {
    die("Connection Failed:" . mysqli_connect_error());
}

if (isset($_POST['save'])) {
    $first_name = $_POST['fname'];
    $last_name = $_POST['lname'];
    $middle_name = $_POST['mi'];
    $age = $_POST['age'];
    $phone = $_POST['cn'];
    $email = $_POST['email'];
    $address = $_POST['ads'];

    $sql_query = "INSERT INTO entry_details (first_name,last_name,gender,email,mobile)
	 VALUES ('$last_name','$first_name','$middle_name', '$age','$phone', '$email','$address')";

    if (mysqli_query($conn, $sql_query)) {
        echo "New Details Entry inserted successfully !";
    } else {
        echo "Error: " . $sql . "" . mysqli_error($conn);
    }
    mysqli_close($conn);
}