I'm trying to figure out what went wrong to my codes, basically, I'm just trying to create an "insert data" modal to my PHP homework. I have a database name sampleDB and these data are supposed to go to the table named "con_tab".
I'm using XAMPP for my homework.
The database:
<?php
$conn = mysqli_connect("localhost","root","","sampleDB");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
The modal's header where I catch errors:
<?php
require('../config/Database.php');
$query = "SELECT * FROM con_tab";
$status = "";
if(isset($_POST['new']) && $_POST['new']==1)
{
$contitle = $_REQUEST['con_title'];
$conauth = $_REQUEST['con_auth'];
$condstart = $_REQUEST['con_dstart'];
$condcomp = $_REQUEST['con_dcomp'];
$conabs = $_REQUEST['con_abs'];
$concol = $_REQUEST['con_col'];
$constat = $_REQUEST['con_stat'];
$moddate = date("Y-m-d H:i:s");
$ins_query="INSERT INTO con_tab (con_title,con_auth,con_dstart,con_dcomp,con_abs,con_col,con_stat) VALUES ('$contitle', '$conauth', '$condstart', '$condcomp', '$conabs', '$concol', '$constat', '$moddate')";
mysqli_query($conn,$ins_query) or die(mysql_error());
$status = "New data successfully added.</br></br></a>";
}
?>
Here's the error messages:
Notice: Undefined index: con_title in C:\xampp..\con-modal.php on line 9
Notice: Undefined index: con_auth in C:\xampp..\con-modal.php on line 10
Notice: Undefined index: con_dstart in C:\xampp..\con-modal.php on line 11
Notice: Undefined index: con_dcomp in C:\xampp..\con-modal.php on line 12
Notice: Undefined index: con_abs in C:\xampp..\con-modal.php on line 13
Notice: Undefined index: con_col in C:\xampp..\con-modal.php on line 14
Notice: Undefined index: con_stat in C:\xampp..\con-modal.php on line 15
In which the lines 9-15 starts at $contitle to $con_stat. This post was tagged as duplicate but the link given didn't solve the problem I have, the issues are different.