我在下面的代碼中編寫了此代碼以將查詢插入到我的數(shù)據(jù)庫中。我已將此 PHP 代碼放在同一頁面以及 port.php 上。它也不起作用。任何想法或建議都非常感謝。這是我將數(shù)據(jù)插入數(shù)據(jù)庫的 PHP 查詢代碼:<?php//connect to DB print_r($_POST); ini_set('display_errors', 1); //<- here you can switch on and off the error reporting 0 / 1 - makes life easy ;) ini_set('display_startup_errors', 1);error_reporting(E_ALL);$debug=1; $host = "localhost"; $username = "root"; $password = "mysqlr00tpa55"; try { $myconnection = new PDO("mysql:host=$host;dbname=myDB", $username, $password); // set the PDO error mode to exception $myconnection ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if(isset($_POST['insert'])){ $vorname = $_POST['vorname']; $nachname = $_POST['nacname']; $email = $_POST['email']; $telefon = $_POST['telefon']; $created = $_POST['created']; //geburtstag $plz = $_POST['plz']; $ort = $_POST['ort']; $strasse = $_POST['strasse']; $hnr = $_POST['hnr']; $adrZus = $_POST['adrZus']; $pdoQuery = "INSERT INTO `Port_Owner`(`vorname`, `nachname`, `email`, `telefon`, `created`, `plz`, `ort`, `strasse`, `hnr`, `adrZus`) VALUES (:vorname,:nachname,:email,:telefon,:created,:plz,:ort,:strasse,:hnr,:adrZus)"; $pdoResult = $myconnection ->prepare($pdoQuery); $pdoExec = $pdoResult->execute(array( ":vorname"=>$vorname, ":nachname"=>$nachname, ":email"=>$email, ":telefon"=>$telefon, ":created"=>$created, ":plz"=>$plz, ":ort"=>$ort, ":strasse"=>$strasse, ":hnr"=>$hnr, ":adrZus"=>$adrZus)); if($pdoExec)當(dāng)我插入 vorname、nachname 和其他字段時(shí),它顯示“此頁面無效”。Somone 在這方面幫助我。提前致謝
1 回答

青春有我
TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超8個(gè)贊
name=
您表單中的屬性與您嘗試從$_POST
數(shù)組中獲取的內(nèi)容不匹配。例如:
<input id="vorname" name="vorname" type="text" class="field text fn" value="<?php echo $value['vorname']; ?>" size="8" tabindex="1" placeholder="Ihr Vorname">
name="vorname"
不匹配:
$vorname = $_POST['portO_firstN'];
其中標(biāo)識(shí)符應(yīng)與輸入的名稱相同。相反,它應(yīng)該是:
$vorname = $_POST['vorname'];
匹配給輸入的名稱。$_POST
數(shù)組中的所有變量都未定義。要查看此錯(cuò)誤,請(qǐng)?jiān)陂_始<?php
標(biāo)記后立即將錯(cuò)誤報(bào)告添加到文件頂部error_reporting(E_ALL); ini_set('display_errors', 1);
- 1 回答
- 0 關(guān)注
- 109 瀏覽
添加回答
舉報(bào)
0/150
提交
取消