prototype Posted February 4, 2018 Share Posted February 4, 2018 (edited) Hayırlı akşamlar arkadaşlar. Sorun yaşadığım bir problem için size danışmak istedim. Hazırlamakta olduğum sayfada 2 tane form var bu formları kendi butonlarıyla post ediyorum ancak ben 2 formuda tek butonla post etmek istiyorum yardımcı olabilirseniz çok sevinirim. <?php if (isset($_POST['uye_adi'], $_POST['adisoyadi'], $_POST['uye_eposta'])) { $adi = trim(filter_input(INPUT_POST, 'uye_adi', FILTER_SANITIZE_STRING)); $soyadi = trim(filter_input(INPUT_POST, 'adisoyadi', FILTER_SANITIZE_STRING)); $eposta = trim(filter_input(INPUT_POST, 'uye_eposta', FILTER_SANITIZE_EMAIL)); if (empty($adi) || empty($soyadi) || empty($eposta)) { die("<p>Lütfen formu eksiksiz doldurun!</p>"); } if (!filter_var($eposta, FILTER_VALIDATE_EMAIL)) { die("<p>Lütfen geçerli bir e-posta adresin girin!</p>"); } try { $baglanti = new PDO("mysql:host=localhost;dbname=bkt_data", "root", ""); $baglanti->exec("SET NAMES utf8"); $baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sorgu = $baglanti->prepare("INSERT INTO uyeler(uye_adi, adisoyadi, uye_eposta) VALUES(?, ?, ?)"); $sorgu->bindParam(1, $adi, PDO::PARAM_STR); $sorgu->bindParam(2, $soyadi, PDO::PARAM_STR); $sorgu->bindParam(3, $eposta, PDO::PARAM_STR); $sorgu->execute(); echo "<p>Bilgiler başarılı bir şekilde kaydedildi.</p>"; } catch (PDOException $e) { die($e->getMessage()); } $baglanti = null; } ?> <?php if (isset($_POST['urunadi'], $_POST['alisfiyati'], $_POST['satisfiyati'])) { $uadi = trim(filter_input(INPUT_POST, 'urunadi', FILTER_SANITIZE_STRING)); $afiyati = trim(filter_input(INPUT_POST, 'alisfiyati', FILTER_SANITIZE_STRING)); $sfiyati = trim(filter_input(INPUT_POST, 'satisfiyati', FILTER_SANITIZE_EMAIL)); if (empty($uadi) || empty($sfiyati) || empty($afiyati)) { die("<p>Lütfen formu eksiksiz doldurun!</p>"); } if (!filter_var($sfiyati, FILTER_VALIDATE_EMAIL)) { die("<p>Lütfen geçerli bir e-posta adresin girin!</p>"); } try { $baglanti = new PDO("mysql:host=localhost;dbname=bkt_data", "root", ""); $baglanti->exec("SET NAMES utf8"); $baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sorgu = $baglanti->prepare("INSERT INTO urunler(urunadi, alisfiyati, satisfiyati) VALUES(?, ?, ?)"); $sorgu->bindParam(1, $uadi, PDO::PARAM_STR); $sorgu->bindParam(2, $afiyati, PDO::PARAM_STR); $sorgu->bindParam(3, $sfiyati, PDO::PARAM_STR); $sorgu->execute(); echo "<p>Bilgiler başarılı bir şekilde kaydedildi.</p>"; } catch (PDOException $e) { die($e->getMessage()); } $baglanti = null; } ?> <form method="post" id="1"> Adınız:<br /> <input name="uye_adi" type="text" value="1" required="required" /> <br /> Soyadınız:<br /> <input name="adisoyadi" type="text" value="2" required="required" /><br /> E-posta Adresiniz:<br /> <input name="uye_eposta" type="email" value="[email protected]" required="required" /> <input type="submit" name="ekle1" id="ekle1" value="Kaydet" /> </form><br /><br /> <form method="post" id="2"> Ürün adı<br /> <input name="urunadi" type="text" value="4" required="required" /> <br /> alış:<br /> <input name="alisfiyati" type="text" value="5" required="required" /><br /> satış:<br /> <input name="satisfiyati" type="email" value="[email protected]" required="required" /> <input type="submit" name="ekle2" id="ekle2" value="Kaydet" /> </form> Edited February 4, 2018 by prototype Quote Link to comment Share on other sites More sharing options...
Administrator sk8er_boi Posted February 4, 2018 Administrator Share Posted February 4, 2018 jQuery'nin post özelliğiyle iki formu ayrı ayrı gönderebilir ardından da javascript ile istediğin sayfaya yönlendirebilirsin. Please register to see this content. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.