我看不出這個代碼有什麼問題?提交按鈕 - 形式到MySQL
HTML
<form id="msform" method="post" type="submit" name="submit" action="oddaj.php">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Kontaktne informacije</li>
<li>Podatki o vozilu</li>
<li>Cena vozila</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Oddaj vozilo v prodajo</h2>
<h3 class="fs-subtitle">Kontaktne informacije</h3>
<input type="text" name="ime" pattern="[a-žA-ž0-9]+" placeholder="Ime in priimek" required />
<input type="text" name="telefonska" pattern="^\d{3}-\d{3}-\d{3}$" placeholder="Telefonska številka" />
<input type="email" name="email" required placeholder="Email naslov" required />
<input type="button" name="next" class="next action-button" value="Nadaljuj" />
</fieldset>
<fieldset>
<h2 class="fs-title">Podatki o vozilu</h2>
<h3 class="fs-subtitle">Natančno posredujte podatke!</h3>
<input type="text" name="twitter" placeholder="Naslov, kjer se nahaja vozilo" />
<input type="text" name="facebook" placeholder="Minimalna cena vozila" />
<input type="text" name="gplus" placeholder="Izberite trajanje dražbe" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" form="msform" name="submit" class="submit action-button" value="Submit" />
</fieldset>
</form>
PHP
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("host", "username", "password", "database");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$ime = mysqli_real_escape_string($link, $_POST['ime']);
$telefonska = mysqli_real_escape_string($link, $_POST['telefonska']);
$email = mysqli_real_escape_string($link, $_POST['email']);
$slika = mysqli_real_escape_string($link, $_POST['slika']);
// attempt insert query execution
$sql = "INSERT INTO oddaja (ime, telefonska, email) VALUES ('$ime', '$telefonska', '$email', '$slika')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
I`ve所做的一切。試着在同一頁上提交(action =「」),POST,GET。 GET甚至沒有改變URI。如果我訪問PHP文件(用於提交),它將記錄保存到數據庫,但值爲空。
此一件事'<形式類型= 「提交」 名稱= 「提交」'和使用上的POST方法GET陣列。編輯:啊,你編輯。Nice Stealth ;-) –
然後3列和4值 –
你會得到什麼錯誤? – Jaylen