Insert OR Save Data File in PHP

 <?php


$stu_name = $_POST["sname"];
$stu_address = $_POST["saddress"];
$stu_class = $_POST["class"];
$stu_phone = $_POST["sphone"];

$conn = new mysqli("localhost", "root", "", "crud");

if ($conn->connect_error) {
    die("Connection Failed : " . $conn->connect_error);
}
$sql = "INSERT INTO student(sname,saddress,sclass,sphone) VALUES('{$stu_name}','{$stu_address}','{$stu_class}','{$stu_phone}')";

if ($conn->query($sql) == TRUE) {
    header("Location: http://localhost/crud/index.php");
    echo "New record created successfully";
} else {
    echo "Error : " . $sql . "<br>" . $conn->error;
}

$conn->close();

Comments

Popular posts from this blog

Update Record File in PHP

Index File in PHP

Edit OR Update Data File in PHP