my code partially works in ELSE
part below. What I mean partially is it doesn't INSERT INTO table but since all verification stages are correct, it redirects to thanks page.
What I normally expect is both. Insert into table AND then go to thanks page.
I thought my situation is about the prepared statement so I studied http://php.net/manual/en/mysqli.quickstart.prepared-statements.php but I couldn't solve my case. I am getting NO notice, warning or error. but my table is still empty. Can you help with my fault(s) please?
Thanks
BR
header( "HTTP/1.1 303 See Other" );
if ($_SESSION['hatalar'] != '')
{
$sonraki_sayfa = sitenin_koku.'yazılar/'.$_SESSION['spesifik_yazi_url'];
header('Location: ' . $sonraki_sayfa);
}
else //verification passed. save the comment + redirect to thanks page.
{
/* YORUMU TABLOYA YAZDIRALIM */
$sorgum = "INSERT INTO tb_yorumlar (kolon_yorumcu_isim, kolon_statu, kolon_yorum, kolon_hangi_yazara, kolon_hangi_basliga, kolon_yorum_tarihi, kolon_ip) VALUES (?, ?, ?, ?, ?, NOW(), ?)";
if ($beyan = $db_baglanti->prepare($sorgum))
{
/* give their values to parameters */
$bindparametre1 = $_POST['yf-isim'];
$bindparametre2 = 'onay';
$bindparametre3 = $_POST['yf-mesaj'];
$bindparametre4 = $_SESSION['spesifik_yazi_yazar'];
$bindparametre5 = $_SESSION['spesifik_yazi_baslik'];
$bindparametre6 = $_SERVER['REMOTE_ADDR'];
/* bind parameters */
if (!$beyan -> bind_param("ssssss", $bindparametre1, $bindparametre2, $bindparametre3, $bindparametre4, $bindparametre5, $bindparametre6))
{echo "parametre atama hatası: (" . $beyan->errno . ") " . $beyan->error;}
/* execute statement */
if (!$beyan->execute())
{echo "Gerçekleştirme hatası: (" . $beyan->errno . ") " . $beyan->error ;}
}
else {echo "Hazırlama hatası: (" . $db_baglanti->errno . ") " . $db_baglanti->error;}
/* TEŞEKKÜR SAYFASINA YÖNLENDİRELİM */
$sonraki_sayfa = sitenin_koku.'yorumunuz-için-teşekkür-ederim';
header('Location: ' . $sonraki_sayfa);
}
I would comment out the header location part (see below) and echo out the values - make sure that the values you're inserting are actually filled (not null).
if ($beyan = $db_baglanti->prepare($sorgum)) {
/* give their values to parameters */
$bindparametre1 = $_POST['yf-isim'];
$bindparametre2 = 'onay';
$bindparametre3 = $_POST['yf-mesaj'];
$bindparametre4 = $_SESSION['spesifik_yazi_yazar'];
$bindparametre5 = $_SESSION['spesifik_yazi_baslik'];
$bindparametre6 = $_SERVER['REMOTE_ADDR'];
if (!$beyan->bind_param("ssssss", $bindparametre1, $bindparametre2, $bindparametre3, $bindparametre4, $bindparametre5, $bindparametre6)) {
echo "parametre atama hatas?: (" . $beyan->errno . ") " . $beyan->error;
}
if (!$beyan->execute()) {
echo "Gerçekles,tirme hatas?: (" . $beyan->errno . ") " . $beyan->error ;
}
}
else {
echo "Haz?rlama hatas?: (" . $db_baglanti->errno . ") " . $db_baglanti->error;
}
/* TES,EKKÜR SAYFASINA YÖNLENDI.RELI.M */
$sonraki_sayfa = sitenin_koku.'yorumunuz-için-tes,ekkür-ederim';
//header('Location: ' . $sonraki_sayfa);
echo $bindparametre1 . "<br>";
echo $bindparametre2 . "<br>";
echo $bindparametre3 . "<br>";
echo $bindparametre4 . "<br>";
echo $bindparametre5 . "<br>";
echo $bindparametre6 . "<br>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.