pdo mysql insert doesnt work from post form

Codes here !

Moderators: egami, macek, gesf

Post Reply
rapsodi
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Nov 17, 2017 2:10 am

Fri Nov 17, 2017 2:13 am

I am write a search code in to the below line, can u help me? What is wrong. I didnt get a error message or warning

if($_POST)
{


$kategori_adi = $_POST["kategoriler"];
echo $kategori_adi;
echo ("<br>");

$cicek_adi = $_POST["cicek_adi"];
echo $cicek_adi;
echo ("<br>");

$cicek_icerik = $_POST["cicek_icerik"];
echo $cicek_icerik;
echo ("<br>");

$cicek_cicekler = $_POST["cicek_cicekler"];
echo $cicek_cicekler;
echo ("<br>");

$cicek_saksi_turu = $_POST["cicek_saksi_turu"];
echo $cicek_saksi_turu;
echo ("<br>");

$alt_kategoriler = $_POST["alt_kategoriler"];
foreach ($alt_kategoriler as $altkategoriler)
if (isset($altkategoriler))
{
{
echo $altkategoriler;
}
}

echo ("<br>");

$cicek_renkler = $_POST["cicek_renkler"];
echo $cicek_renkler;

$urunekle = $db->prepare("insert into cicekler set cicek_kategori=?, cicek_adi=?, cicek_icerik=?, cicek_cicekler=?, cicek_saksi_turu=?, cicek_renkler=?");
$urunekle->execute(array($kategori_adi,$cicek_adi,$cicek_icerik,$cicek_cicekler,$cicek_saksi_turu,$cicek_renkler));

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 719
Joined: Mon Feb 22, 2016 5:52 pm

Fri Nov 17, 2017 8:32 am

You do have errors in your code, so either look at your error log or switch display errors on.

Apart from the errors that need to be fixed, I don't see any connection being made to the database.

Code: Select all

if($_POST)
is bad practice: if ($_POST) what? Getting the first part right is fundamental to security when dealing with user input.

If you post code, use the code </> button, and make some comments in it so that we can see what you think is going on.

User avatar
benanamen
New php-forum User
New php-forum User
Posts: 53
Joined: Mon Oct 16, 2017 1:06 pm

Sat Nov 18, 2017 9:46 am

Do not create variables for nothing. You already have variables, just use them.
The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

Post Reply