作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用谷歌搜索了很多,但找不到我的问题的答案。我创建了一个表单来在我的网站上提交一些信息。问题是它只有时有效,我不知道为什么。你的帮助我会非常感激,我快要疯了。
PHP
<?php
require_once("php/verbindung.php");
$partyskill = "";
$partyskill2 = "";
$partylang = "";
$partycount = "";
$drop = "";
$error_count = "";
$error_lang = "";
$freigabe = true;
if (isset($_POST['submit'])) {
$partyskill = "$_POST[skill]";
$partyskill2 = "$_POST[skill2]";
$partylang = "$_POST[language]";
$partycount = "$_POST[count]";
if (strlen($partycount) == 0) {
$error_count = "<FONT COLOR='#d1a200'>*please select how many players you are looking for</font>";
$freigabe = false;
}
if (strlen($partylang) == 1) {
if($partylang=="1")
{$drop="gb.png";}
elseif($partylang== "2")
{$drop="de.png";}
elseif($partylang== "3")
{$drop="ru.png";}
else {
$error_lang = "<FONT COLOR='#d1a200'>*please select a language</font>";
$freigabe = false;
}
}
else {
$error_lang = "<FONT COLOR='#d1a200'>*please select a language</font>";
$freigabe = false;
}
if ($freigabe == true) {
$sql = "INSERT INTO ".$tblparty;
$sql .= " (skill, skill2, count, language)
VALUES (";
$sql .= "'".$partyskill."', ";
$sql .= "'".$partyskill2."', ";
$sql .= "'".$partycount."', ";
$sql .= "'".$drop."') ";
$query = mysql_query($sql, $verb);
}
}
?>
HTML
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="new_party" >
<h3>How many players are you searching for?</h3>
<p>
<input type="radio" name="count" value="1"> 1
<input type="radio" name="count" value="2"> 2
<input type="radio" name="count" value="3"> 3
<input type="radio" name="count" value="4"> 4
</p>
<?php echo $error_count; ?><br/>
<h3>What is you prefered language?</h3>
<p>
<input type="radio" name="language" value="1"><img src="images/flags/gb.png"/>
<input type="radio" name="language" value="2"><img src="images/flags/de.png"/>
<input type="radio" name="language" value="3"><img src="images/flags/ru.png"/>
</p>
<?php echo $error_lang; ?><br/>
<h3>What skill are you looking for?</h3>
from:
<select name="skill">
<option value="15">Eagle Master</option>
<option value="16">Legendary Eagle Master</option>
<option value="17">Supreme Master First Class</option>
<option value="18">Global Elite</option>
</select>
to:
<select name="skill2">
<option value="15">Eagle Master</option>
<option value="16">Legendary Eagle Master</option>
<option value="17">Supreme Master First Class</option>
<option value="18">Global Elite</option>
</select>
<input type="submit" value="Send" name="submit"/>
</form>
最佳答案
而不是这样做:
$sql = "INSERT INTO ".$tblparty;
$sql .= " (skill, skill2, count, language)
VALUES (";
$sql .= "'".$partyskill."', ";
$sql .= "'".$partyskill2."', ";
$sql .= "'".$partycount."', ";
$sql .= "'".$drop."') ";
将其更改为:
$sql = "INSERT INTO `$tblparty` (`skill`, `skill2`, `count`, `language`)
VALUES ('".$partyskill."', '".$partyskill2."', '".$partycount."', '".$drop."')";
然后删除您的技能
列并重新创建它。您还可以尝试重建表。
另外,我建议您切换到mysqli_*
使用 prepared statements
的函数或PDO , mysql_*
函数已弃用,并将在未来版本中删除。
关于php - 表单有时仅有效(PHP mySQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21964096/
我想知道。是否有仅将按引用传递作为评估策略的语言? 最佳答案 我不知道什么是“评估策略”,但是Perl子例程调用仅通过引用传递。 sub change { $_[0] = 10; } $x =
我是一名优秀的程序员,十分优秀!