I cant figure out why my php script isn't working at times it does work after deleting all data from my database table
<?php
$con = mysqli_connect("localhost","root","","db_csbn");
if(mysqli_connect_errno())
{
echo "MySQLi Connection was not established: " . mysqli_connect_error();
}
?>
...
<?php
include "connect.php";
$tor = (isset($_POST['tor']) ? "1" : "0");
$frm = (isset($_POST['frm']) ? "1" : "0");
$dp = (isset($_POST['dp']) ? "1" : "0");
$gm = (isset($_POST['gm']) ? "1" : "0");
$hd = (isset($_POST['hd']) ? "1" : "0");
$cr = (isset($_POST['cr'])? "1" : "0");
$ch = (isset($_POST['ch']) ? "1" : "0");
$snumber = $_POST['snumber'];
$documents = $tor.$frm.$dp.$gm.$hd.$cr.$ch;
echo $documents;
$date = date("Y-m-d");
if($tor || $frm || $dp || $gm || $hd || $cr || $ch)
{
$id = str_replace("-","",$date).$snumber;
$sql = "INSERT INTO `tbl_requests` (`id`, `dr`, `snumber`, `date`) VALUES('".$id."', '".$documents."', '".$snumber."', '".$date."');";
if( mysqli_query($con, $sql))
{
echo"<script>alert(Request id (Please Save):\n $id);</script>";
}
}
}
?>
i cant see any errors after running this script but no data was added to my table.