47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
include "db.php";
|
|
|
|
if($_SERVER["REQUEST_METHOD"]=="POST")
|
|
{
|
|
$name=$_POST['name'];
|
|
$email=$_POST['email'];
|
|
$phone=$_POST['phone'];
|
|
$category=$_POST['category'];
|
|
$status=$_POST['status'];
|
|
$description=$_POST['description'];
|
|
|
|
$sql = "INSERT INTO `records`(`name`,`email`,`phone`,`category`,`status`,`description`)
|
|
VALUES ('$name','$email','$phone','$category','$status','$description')";
|
|
|
|
if(mysqli_query($conn , $sql))
|
|
{
|
|
$record_id = mysqli_insert_id($conn);
|
|
|
|
if(!empty($_POST['row']))
|
|
{
|
|
foreach($_POST['row'] as $field)
|
|
{
|
|
if(!empty($field))
|
|
{
|
|
$field = mysqli_real_escape_string($conn,$field);
|
|
|
|
$query= "INSERT INTO `additional_fields`(`record_id`,`field_value`)
|
|
VALUES ('$record_id','$field')";
|
|
|
|
mysqli_query($conn , $query);
|
|
}
|
|
}
|
|
}
|
|
|
|
echo "<script>
|
|
alert('Record Saved Successfully');
|
|
window.location='record.php';
|
|
</script>";
|
|
}
|
|
else
|
|
{
|
|
echo "Error: " . mysqli_error($conn);
|
|
}
|
|
}
|
|
?>
|