i tried to convert my sql to pdo to be more safe but i dont know why my insert sql is not working, but the code is exactly the same with the example i got, but nothing happen when i use this code, there is no also error in console so i dont know what to do now.
here is my code
include 'C:\\Users\\Ace\\Sites\\db.php';
session_start();
$result =$pdo->query("SELECT * FROM tblrv WHERE ID='" . $_GET['id'] . "'");
$row = $result->fetch(PDO::FETCH_BOTH);
if(count($_POST)>0) {
$rvno = $_POST['id'];
$c = $_POST['cash'];
if($rvno == "" && $_POST['name'] != ""){
$sql = "INSERT INTO tblrv (RVID, RVDate, Name, ContactNumber, SumInWords, RespectOf, Total, Cash, BankName, ChequeNumber, ChequeDate, CCref, BankTranRef, ChequeRef, Remarks, PreparedBy, ReceivedBy)
VALUES (:rvid, :rvdate, :name, :contactnumber, :suminwords, :respectof, :total, :cash, :bankname, :chequenumber, :chequedate, :ccref, :banktranref, :chequeref, :remarks, :preparedby, :receivedby)";
$stmt=$pdo->prepare($sql);
$data = [
':rvid' => $_POST['rvid'],
':rvdate' => $_POST['rvdate'],
':name' => $_POST['rvname'],
':contactnumber' => $_POST['contactnumber'],
':suminwords' => $_POST['suminwords'],
':respectof' => $_POST['respectof'],
':total' => $_POST['total'],
':cash' => $_POST['cash'],
':bankname' => $_POST['bankname'],
':chequenumber' => $_POST['chequenumber'],
':chequedate' => $_POST['chequedate'],
':ccref' => $_POST['ccref'],
':banktranref' => $_POST['banktranref'],
':chequeref' => $_POST['chequeref'],
':remarks' => $_POST['remarks'],
':preparedby' => $_POST['preparedby'],
':receivedby' => $_POST['receivedby']
];
$x = $stmt->execute($data);
if($x)
{
echo '<script>
alert("New Record Successfully Added");
window.location.href="form";
</script>';
exit(0);
}
else {
'<script>
alert("ERROR");
</script>'; }
Thank in advance for the help guys
FIX Thanks