<script>
function testinput(value) {
value = trim(value);
value = stripslashes(value);
value = htmlspecialchars(value);
}
</script>
<?php
$servername ="localhost";
$username = "k";
$password = "password";
$dbname = "password";
$connect1 = new mysqli($servername, $username, $password, $dbname);
if($connect1->connect_error) {
die("Connection failed: " . $connnect1->connect_error);
}
if (isset($_POST['btnreg'])) {
$klantVoornaam = $_POST["txtVoornaam"];
$klantAchternaam = $_POST["txtAchternaam"];
$klantMail = $_POST["txtEmail"];
$klantWachtwoord = $_POST["txtWw"];
(line48)$klantVoornaam = testinput($klantVoornaam);
$klantAchternaam = testinput($klantAchternaam);
$klantMail = testinput($klantMail);
$klantWachtwoord = testinput($klantWachtwoord);
$sql = "INSERT INTO `klanten` (KlantID, Voornaam, Achternaam, Wachtwoord, Email, Klantreg, KlantActief)
VALUES(NULL,'".$klantVoornaam."','".$klantAchternaam."', '".md5($klantWachtwoord)."','".$klantMail."',". regCode() ."','0')";
$qresult = mysql_query($sql);
if($connect1 ->query($qresult)){
echo "Registered successfully!";
echo "Voornaam: " . $klantVoornaam;
echo "Achternaam" . $klantAchternaam;
echo "E-mail" . $klantMail;
echo "Wachtwoord" . $klantWachtwoord;
}
}
?>
基本上我上面提到的函数testinput()
是undefined
,但我似乎没有看到错误。
脚本设置在我的身体中,其余部分使用testinput()
来删除任何奇怪的字符,因为它是用户名。
答案 0 :(得分:1)
您在javascript中定义testinput
,您无法通过PHP调用它。相反,您应该在PHP中定义它:
<?php
function testinput($value) {
$value = trim($value);
$value = stripslashes($value);
$value = htmlspecialchars($value);
return $value;
}
// Rest of your PHP code
顺便说一句:这个功能并没有真正测试你的输入,它会对它进行消毒。您可能应该给它一个不同的名称来更好地描述它的作用。
答案 1 :(得分:0)
很多!我愚蠢的错误,老师告诉我使用这些装饰/条带,所以我认为我坚持使用它