PHP link two search bars to different results - php

I want to have two identical search bars but which lead to different results. However the problem and that the result of a search is then displayed during a search on the second search bar, the second result erases the first. I do not understand how this can be possible, if there is a way to display the results at the same time on the same page, I am interested. thank you in advance
Code one
<?php
include_once ('searcht.php');
?></br><?php
include_once ('searche.php');
?>
Code for search bar one "searcht.php"
<div class="t"><form method="post" enctype="multipart/form-data">
<label>Search</label>
<input type="text" name="searcht">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
$hostt = "localhost";
$db_namet = "photos";
$usernamet = "root";
$passwordt = "";
try{
$cont = new PDO("mysql:host={$hostt};dbname={$db_namet}", $usernamet, $passwordt);
}
catch(PDOException $exceptiont){
//to handle connection error
echo "Connection error: " . $exceptiont->getMessage();
}
if (isset($_POST["submit"])) {
$strt = $_POST["searcht"];
$stht = $cont->prepare("SELECT image, image_nom, image_text FROM images WHERE image_nom =
'$strt'");
$stht->setFetchMode(PDO:: FETCH_OBJ);
$stht -> execute();
if($rowt = $stht->fetch())
{
?>
<br><br><br>
<table>
<tr>
<th>Image</th>
<th>Nom</th>
<th>Fiche</th>
</tr>
<tr>
<td class='image'><?php print "<img src='images/$rowt->image'>";?></td>
<td><?php print $rowt->image_nom; ?></td>
<td><?php print $rowt->image_text;?></td>
</tr>
</table>
<?php
}else{
echo "Aucune personne s'apelle comme çà";
}
}
?>
</div>
Code for search bar two "searche.php"
<div class="e"><form method="post" enctype="multipart/form-data">
<label>Search</label>
<input type="text" name="searche">
<input type="submit" name="submite">
</form>
</body>
</html>
<?php
$host = "localhost";
$db_name = "photos";
$username = "root";
$password = "";
try{
$cone = new PDO("mysql:host={$host};dbname={$db_name}", $username, $password);
}
catch(PDOException $exception){
//to handle connection error
echo "Connection error: " . $exception->getMessage();
}
if (isset($_POST["submite"])) {
$stre = $_POST["searche"];
$sthe = $cone->prepare("SELECT image, image_nom, image_text FROM images WHERE image_nom =
'$stre'");
$sthe->setFetchMode(PDO:: FETCH_OBJ);
$sthe -> execute();
if($rowe = $sthe->fetch())
{
?>
<br><br><br>
<table>
<tr>
<th>Image</th>
<th>Nom</th>
<th>Fiche</th>
</tr>
<tr>
<td><?php echo $rowe->image_text;?></td>
<td><?php echo $rowe->image_nom; ?></td>
<td class='image'><?php echo "<img src='images/$rowe->image'>";?></td>
</tr>
</table>
<?php
}else{
echo "Aucune personne s'apelle comme çà";
}
}
?>
</div>

I am not really sure what was the difference in searcht.php and searche.php. Anyway, you can just use two buttons to separate the request. And, you can use if(isset($_POST['submitt'])) for the submitt submission and if(isset($_POST['submite'])) for the submite submission.
<div class="t">
<form method="post" enctype="multipart/form-data">
<label>Search</label>
<input type="submit" name="submitt" value="Submit T">
<input type="submit" name="submite" value="Submit E">
</form>
<?php
if(isset($_POST["submitt"])) {
$hostt = "localhost";
$db_namet = "photos";
$usernamet = "root";
$passwordt = "";
try{
$cont = new PDO("mysql:host={$hostt};dbname={$db_namet}", $usernamet, $passwordt);
}
catch(PDOException $exceptiont){
echo "Connection error: " . $exceptiont->getMessage();
}
$stht = $cont->prepare("SELECT image, image_nom, image_text FROM images WHERE image_nom = '$strt'");
$stht->setFetchMode(PDO:: FETCH_OBJ);
$stht->execute();
} else if(isset($_POST["submite"])) {
$hostt = "localhost";
$db_namet = "photos";
$usernamet = "root";
$passwordt = "";
try{
$cont = new PDO("mysql:host={$hostt};dbname={$db_namet}", $usernamet, $passwordt);
}
catch(PDOException $exceptiont){
echo "Connection error: " . $exceptiont->getMessage();
}
$stht = $cont->prepare("SELECT image, image_nom, image_text FROM images WHERE image_nom = '$strt'");
$stht->setFetchMode(PDO:: FETCH_OBJ);
$stht->execute();
}
if(isset($stht)){
if($row = $stht->fetch()){
?>
<br><br><br>
<table>
<tr>
<th>Image</th>
<th>Nom</th>
<th>Fiche</th>
</tr>
<tr>
<td class='image'><?php print "<img src='images/$row->image'>";?></td>
<td><?php print $row->image_nom; ?></td>
<td><?php print $row->image_text;?></td>
</tr>
</table>
<?php
}else{
echo "Aucune personne s'apelle comme çà";
}
}
?>
</div>

Related

How to insert multiple row data from a table into another table in MySQL using checkboxes

I trying to insert my data from table_request into table_list by clicking the approve/reject button under the table.
Users will click the checkboxes to select all or select a specific row. After approve, the data in the table_request insert into table_list and deleted from table_request.
The current problem is about the foreach and inserts statement is wrong.
After I click approve, it can only insert table_request id into table_list.
This is my table_request.php
<form name="bulk_action_form" action="action.php" method="post" onSubmit="return approve_confirm();"/>
<table class="bordered">
<tr>
<th><input type="checkbox" name="select_all" id="select_all" value=""/></th>
<th>Name</th>
<th>Remark</th>
</tr>
<?php
$query = "select * from `table_request`;";
if(count(fetchAll($query))>0){
foreach(fetchAll($query) as $row){
?>
<tr>
<td><input type="checkbox" name="checked_id[]" class="checkbox" value="<?php echo $row['id']; ?>"/></td>
<td><?php echo $row['Name'] ?></td>
<td><?php echo $row['Remark'] ?></td>
</tr>
<?php } }else{ ?>
<tr><td colspan="5">No records found.</td></tr>
<?php } ?>
</table>
<input type="submit" name="approve_btn" value="Approve"/>
</form>
This is my action.php
<?php
session_start();
include_once('connection.php');
if(isset($_POST['approve_btn']))
{
$idArr = $_POST['checked_id'];
$Name = $_POST['Name'];
$Remark = $_POST['Remark'];
foreach($idArr as $key => $value)
{
$save = "INSERT INTO table_list(id,Name,Remark) VALUES ('".$value."','".$Name[$key]."','".$Remark[$key]."')";
$query = mysqli_query($conn,$save);
}
$query .= "DELETE FROM `table_request` WHERE `table_request`.`id` = '$id';";
header("Location:table_request.php");
}
?>
connection.php file
<?php
$server_name = "localhost";
$user_name = "username";
$password = "password";
$db_name = 'database';
// Create connection
$conn = mysqli_connect($server_name, $user_name, $password, $db_name);
// Check connection
if (mysqli_connect_errno()) {
die("Connection failed: ");
}
table_request.php file
<?php include_once('connection.php'); ?>
<form name="bulk_action_form" action="action.php" method="post" onSubmit="return approve_confirm();"/>
<table class="bordered">
<tr>
<th>Select</th>
<th>Name</th>
<th>Remark</th>
</tr>
<?php
$query = mysqli_query($conn, "SELECT * FROM table_request");
if (mysqli_num_rows($query) > 0) : foreach($query as $row) : ?>
<tr>
<td><input type="checkbox" name="checked_id[]" class="checkbox" value="
<?php echo $row['id']; ?>"/></td>
<td><?php echo $row['Name']; ?></td>
<td><?php echo $row['Remark']; ?></td>
</tr>
<?php endforeach; else : ?>
<tr><td colspan="5">No records found.</td></tr>
<?php endif; ?>
</table>
<input type="submit" name="approve_btn" value="Approve"/>
</form>
action.php file
<?php
include_once('connection.php');
if(isset($_POST['approve_btn'])) {
foreach ($_POST['checked_id'] as $id) {
$query = mysqli_query($conn, "SELECT * FROM table_request WHERE id = $id");
$result = $query->fetch_object();
$save = "INSERT INTO table_list(id, Name, Remark) VALUES ('".$result->id."','".$result->Name."','".$result->Remark."')";
// For save data
mysqli_query($conn, $save);
// For delete data
mysqli_query($conn, "DELETE FROM table_request WHERE id = $id");
}
header('Location:table_request.php');
}

HTML table multiple data save in mysql data

I have created php program to order food items. User has been given table. That html table has 4 columns food item,quantity,price,order. User can only give input to order column.
When user give inputs in HTML table and click order button it should be saved in MySQL order table. But I am not able to do that work successfully. I want to do this using only PHP. Without using JavaScript. Help me to solve this.
HTML code
<form action="order2.php" method="POST">
<table border="1">
<tr>
<th>Food Item</th>
<th>Quantity available</th>
<th>Item Price</th>
<th>Order</th>
</tr>
<?php
while ($row = mysqli_fetch_assoc($result1)) {
?>
<tr>
<td><?php echo $row['fitem']; ?></td>
<td><?php echo $row['qty']; ?></td>
<td><?php echo $row['price']; ?></td>
<td><input type="text" name="order"></td>
</tr>
<?php
}
?>
<tr>
<td>
<input type="submit" value="order" align="right">
</td>
</tr>
</table>
</form>
php code
<?php
session_start();
$order = $_POST['order'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mid";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
} else {
while ($row = mysqli_fetch_assoc($result1)) {
$sql = "insert into order (fname,order) values('$row['fitem']',$order)";
if (mysqli_query($conn, $sql)) {
echo "New order created successfully";
} else {
echo mysqli_error($conn);
}
}
}
?>

Submit buttons render under table data. I want only one submit button for the form

My problem is a submit button renders under each row of table data. I have searched all over the web to find out, how I can code to use only one submit for the entire form. As it is I can only submit $_POST for one row whereas I need to submit the entire form for processing.
Here is my Code:
<?php
require("config.inc.php");
session_start();
$usrname = $_POST["uname"]; //variable passed from validateuser.html
global $usrname;
//echo $usrname;
// initial query
$query = "SELECT * FROM dfd_usr_profiles WHERE username= '".$usrname."'";
/*$query2 = "UPDATE dfd_usr_profiles SET filters = :fltrs,
regions = :regns
WHERE $usrname = :username"; */
//execute query
try {
$stmt = $db->prepare($query);
$result = $stmt->execute();
}
catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error!";
die(json_encode($response));
}
$rows = $stmt->fetchAll();
if ($rows) {
$response["success"] = 1;
$response["message"] = "Profile Information Available!";
$response["posts"] = array();
foreach ($rows as $row) {
$post = array();
$post["userID"] = $row["userID"];
$post["username"] = $row["username"];
$post["filters"] = $row["filters"];
$post["regions"] = $row["regions"];
//update our repsonse JSON data
array_push($response["posts"], $post);
$endi = count($post);
//echo $endi;
?>
<!DOCTYPE html>
<html>
<script type="text/javascript">
function getRow(n) {
var row = n.parentNode.parentNode;
var cols = row.getElementsByTagName("td");
var i=0;
while (i < cols.length) {
alert(cols[i].textContent);
i++;
}
}
</script>
<body>
<form name="updatefilters" action="update_action.php" method="post" enctype="multipart/form-data>" id="update">
<!-- <input type="submit" name="submit" id="update" value="Update" /> -->
<fieldset>
<table border="1" >
<legend>Update Filters and Regions</legend>
<tr>
<td><input type="checkbox" name="pID[]" value="<?php echo $post['userID']; ?>" onclick="getRow(this)" /></td>
<td><input type="input" name="uname" value="<?php echo $usrname;?>" /></td>
<td><?php echo $post['filters']; ?></td>
<td><label valign="top" for="" id="mfiltervals">Select Deal Type(s) you want:</label></p></td>
<td><?php require("dtypelist.php");?></td>
<td><?php echo $post['regions']; ?></td>
<td><label valign="top" for="" id="mregionvals">Select Region(s) you want:</label></td>
<td><?php require("regionslist.php");?></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
<?php
echo '<button type="submit" name="submitupdate" form="update">Update</button>';
}
// echoing JSON response
// echo json_encode($response); // Commented out: Displays profile unformatted data. TC 070516.
} else {
$response["success"] = 0;
$response["message"] = "No information for this Username is available!";
die(json_encode($response));
}
// session_start(); place-holder
?>
Please help.
You need to move the foreach and the submit button that you have in the code below. All the other code is not relevant for this change. I have marked the 3 parts that need to be moved with // **** Move:
// **** Move this block to just before the `<tr>` tag
foreach ($rows as $row) {
$post = array();
$post["userID"] = $row["userID"];
$post["username"] = $row["username"];
$post["filters"] = $row["filters"];
$post["regions"] = $row["regions"];
//update our repsonse JSON data
array_push($response["posts"], $post);
$endi = count($post);
//echo $endi;
?>
<!DOCTYPE html>
<html>
<script type="text/javascript">
function getRow(n) {
var row = n.parentNode.parentNode;
var cols = row.getElementsByTagName("td");
var i=0;
while (i < cols.length) {
alert(cols[i].textContent);
i++;
}
}
</script>
<body>
<form name="updatefilters" action="update_action.php" method="post" enctype="multipart/form-data>" id="update">
<!-- <input type="submit" name="submit" id="update" value="Update" /> -->
<fieldset>
<table border="1" >
<legend>Update Filters and Regions</legend>
<tr>
<td><input type="checkbox" name="pID[]" value="<?php echo $post['userID']; ?>" onclick="getRow(this)" /></td>
<td><input type="input" name="uname" value="<?php echo $usrname;?>" /></td>
<td><?php echo $post['filters']; ?></td>
<td><label valign="top" for="" id="mfiltervals">Select Deal Type(s) you want:</label></p></td>
<td><?php require("dtypelist.php");?></td>
<td><?php echo $post['regions']; ?></td>
<td><label valign="top" for="" id="mregionvals">Select Region(s) you want:</label></td>
<td><?php require("regionslist.php");?></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
<?php // **** Move this up to just after the `</table>` tag
echo '<button type="submit" name="submitupdate" form="update">Update</button>';
// **** Move this closing brace just after the `</tr>` tag
}
After the 3 moves, it looks as follows -- see comments with ****MOVED****:
?>
<!DOCTYPE html>
<html>
<script type="text/javascript">
function getRow(n) {
var row = n.parentNode.parentNode;
var cols = row.getElementsByTagName("td");
var i=0;
while (i < cols.length) {
alert(cols[i].textContent);
i++;
}
}
</script>
<body>
<form name="updatefilters" action="update_action.php" method="post" enctype="multipart/form-data>" id="update">
<!-- <input type="submit" name="submit" id="update" value="Update" /> -->
<fieldset>
<table border="1" >
<legend>Update Filters and Regions</legend>
<?php // ****MOVED****
foreach ($rows as $row) {
$post = array();
$post["userID"] = $row["userID"];
$post["username"] = $row["username"];
$post["filters"] = $row["filters"];
$post["regions"] = $row["regions"];
//update our repsonse JSON data
array_push($response["posts"], $post);
$endi = count($post);
//echo $endi;
?>
<tr>
<td><input type="checkbox" name="pID[]" value="<?php echo $post['userID']; ?>" onclick="getRow(this)" /></td>
<td><input type="input" name="uname" value="<?php echo $usrname;?>" /></td>
<td><?php echo $post['filters']; ?></td>
<td><label valign="top" for="" id="mfiltervals">Select Deal Type(s) you want:</label></p></td>
<td><?php require("dtypelist.php");?></td>
<td><?php echo $post['regions']; ?></td>
<td><label valign="top" for="" id="mregionvals">Select Region(s) you want:</label></td>
<td><?php require("regionslist.php");?></td>
</tr>
<?php // ****MOVED****
}
?>
</table>
<?php // ****MOVED****
echo '<button type="submit" name="submitupdate" form="update">Update</button>';
?>
</fieldset>
</form>
</body>
</html>
<?php
Make sure to add <?php and ?> where necessary to switch correctly between PHP and normal output.

Not removing item from the cart

Below is my php code to show how I removing items from the cart. There is not error showing in webpage but also the item is not removing and cart is not updating. Edited with full code
<div class="product_box">
<form action="cart.php" method="post" enctype="multipart/data">
<table align="center" width="700" bgcolor="skyblue">
<tr>
<th>Remove</th>
<th>Product (s) </th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
<?php
$total = 0;
global $db;
$ip = getIp();
$sel_price ="select * from cart where ip_add='$ip'";
$run_price = mysqli_query($db, $sel_price);
while ($p_price=mysqli_fetch_array($run_price)) {
$pro_id = $p_price['p_id'];
$pro_price = "select * from products where product_id='$pro_id'";
$run_pro_price = mysqli_query($db, $pro_price);
while ($pp_price = mysqli_fetch_array($run_pro_price)) {
$product_price = array($pp_price ['product_price']);
$product_title = $pp_price['product_title'];
$product_image = $pp_price['product_img1'];
$single_price = $pp_price['product_price'];
$values = array_sum($product_price);
$total +=$values;
//echo "Rs ." . $total;
?>
<tr align="center">
<td><input type="checkbox" name="remove[]"></td>
<td><?php echo $product_title; ?><br>
<img src="admin_area/product_images/<?php echo $product_image;?>" width="50px" height="50px">
</td>
<td><input type="text" name="qty" size="3"></td>
<td><?php echo "Rs." . $single_price ?></td>
</tr>
<?php } } ?>
<tr align="right">
<td colspan="3">
<b> Sub Total: </b>
</td>
<td>
<?php echo "Rs." .$total; ?>
</td>
</tr>
<tr align="center">
<td colspan="1"><input type="submit" name="update_cart" value="Update Cart"></td>
<td><input type="submit" name="continue" value="Continue Shopping"></td>
<td><button>Checkout</button></td>
</tr>
</table>
</form>
<?php
$ip = getIp();
if (isset($_POST['update_cart'])) {
foreach ($_POST['remove'] as $remove_id) {
$delete_product = "delete from cart where p_id=".$remove_id." AND ip_add=".$ip;
$run_delete = mysqli_query($db, $delete_product);
if ($run_delete) {
echo "<script>window.open('cart.php','_self')</script>";
}
}
}
}
?>
</div>
</div>
I tried to check error by putting below code after if statement but not worked.
else { echo mysqli_error($db);}
Please help Thanks.
Try using writelog to check whether your mysql statements are getting values. Here is small function which will help you better in debugging.
<?php
function writelog($content) {
$file = 'log.txt';
file_put_contents($file, date("Y-m-d H:i:s")." : ".$content."\r\n", FILE_APPEND | LOCK_EX);
}
//Only display php errors to the developer...
if($_SERVER['REMOTE_ADDR'] == "put your localhost ip address")
{
error_reporting(0);
ini_set('display_errors', 'On');
$db_hostname = "localhost";
$db_database = "ecommerce";
$db_username = "root";
$db_password = "";
}
else
{
error_reporting(0);
ini_set('display_errors', 'On');
$db_hostname = "localhost";
$db_database = "ecommerce";
$db_username = "root";
$db_password = "";
}
//Establishing database connection
$db_connection = mysqli_connect($db_hostname, $db_username, $db_password, $db_database) or die(mysqli_error($db_connection));
Example how to use this function:
write_log($delete_product);
This will create a text file where you have your current php file.
Learn a complete CRUD php mysqli example from this website:
try this it will help you in understanding better
I think you should in the line with checkbox
<tr align="center">
<td><input type="checkbox" name="remove[]"></td>
<td><?php echo $product_title; ?><br>
<img src="admin_area/product_images/<?php echo $product_image;?>" width="50px" height="50px">
</td>
<td><input type="text" name="qty" size="3"></td>
<td><?php echo "Rs." . $single_price ?></td>
</tr>
You should set a value = product_id in checkbox like
<input type="checkbox" name="remove[]" id="<?=$pp_price['product_id']?>>
I got my answer i just added below value to input checkbox and it works.
<input type="checkbox" name="remove[]" value="<?php echo $pro_id; ?> ">
try this it will help you
$ip = getIp();
if (isset($_POST['update_cart'])) {
foreach ($_POST['remove'] as $remove_id) {
$delete_product = "delete from cart where p_id=".$remove_id." AND ip_add=".$ip;
$run_delete = mysqli_query($db, $delete_product);
if ($run_delete) {
echo "<script>window.open('cart.php','_self')</script>";
}
}
}

My script is updating all fields when I just edit one

my problem it's I'm trying to develop a back-end where I need to update but my problem is, when I update one field my script update all fields and all data of my mysqli database.
My code for now is:
<html>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "hotel_vaniet";
$strCustomerID = null;
if(isset($_GET["cod"]))
{
$cod = $_GET["cod"];
}
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "hotel_vaniet";
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$sql = "SELECT * FROM quartos WHERE cod=$cod";
$query = mysqli_query($conn,$sql);
$result=mysqli_fetch_array($query,MYSQLI_ASSOC);
?>
<div id="main">
<form action="editar_quartos_final.php" name="frmAdd" method="post">
<br><h1>Página de Edição</h1>
<br><hr/>
<div id="login2">
<table width="284" border="1">
<tr>
<th width="120">Tipo</th>
<td width="238"><input type="text" name="tipo" size="50" value="<?php echo $result["tipo"];?>"></td>
</tr>
<tr>
<th width="120">Capacidade</th>
<td><input type="text" name="capacidade" size="50" value="<?php echo $result["capacidade"];?>"></td>
</tr>
<tr>
<th width="120">Preço p/ Noite</th>
<td><input type="text" name="preco" size="50" value="<?php echo $result["preco"];?>"></td>
</tr>
<tr>
<th width="120">Reservado</th>
<td><input type="text" name="reservado" size="50" value="<?php echo $result["reservado"];?>"></td>
</tr>
</table>
<br><input id="submitbuttoneditar" type="submit" value=" Editar " name="submit"/><br />
</div>
</form>
<?php
mysqli_close($conn);
?>
</body>
</html>
This the first page ,this page send me to another where makes all changes. The second page :
<html>
<head>
<title>Página de Edição do Cliente</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "hotel_vaniet";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE quartos SET
tipo = '".$_POST["tipo"]."' ,
capacidade = '".$_POST["capacidade"]."' ,
preco = '".$_POST["preco"]."' ,
reservado = '".$_POST["reservado"]."'
WHERE cod=cod";
if ($conn->query($sql) === TRUE) {
echo "Dados actualizados com sucesso!";
header("Location: quartos.php");
} else {
echo "Erro na edição dos dados! " . $conn->error;
header("Location: quartos.php");
}
$conn->close();
?>
</body>
</html>
On your first page you have $cod variable which equals $_GET["cod"].
On your second page $cod variable is not defined. So your try to update
WHERE cod=cod
means - update where value of field cod is the same as value of field cod. And as it is true for all records - all your records are updated.
So, the solution is to pass your $cod value to your second script.
For example, you can do it with a hidden field from your first form:
<form action="editar_quartos_final.php" name="frmAdd" method="post">
<br><h1>Página de Edição</h1>
<br><hr/>
<input type="hidden" name="cod" value="<?php echo $cod?>" />
<div id="login2">
<table width="284" border="1">
<tr>
<th width="120">Tipo</th>
<td width="238"><input type="text" name="tipo" size="50" value="<?php echo $result["tipo"];?>"></td>
</tr>
<tr>
See this field with hidden type?
And in your second script use $_POST['cod']:
$sql = "UPDATE quartos SET
tipo = '".$_POST["tipo"]."' ,
capacidade = '".$_POST["capacidade"]."' ,
preco = '".$_POST["preco"]."' ,
reservado = '".$_POST["reservado"]."'
WHERE cod=" . $POST['cod'];
And of course, your code is vulnerable to sql injections.
So you should start using prepared statements asap.

Categories