<?php
$con = mysqli_connect("localhost", "KyleLongrich", "Cash7144") or die('could not connect to server');
mysqli_select_db($con,"kylelongrich") or die("could not connect to database");
if(isset($_POST['Send']))
{
$Firstname = strip_tags($_POST['firstname']);
$Lastname = strip_tags($_POST['lastname']);
$Email = strip_tags($_POST['email']);
$Topic = strip_tags($_POST['topic']);
$Message = strip_tags($_POST['message']);
$sql = "INSERT INTO emailquestions (Firstname, Lastname, Email, Subject, Message) VALUES ('$Firstname','$Lastname','$Email','$Topic','$Message')";
mysqli_query($con, $sql);
echo $FirstName;
}
?>
<div class="contact-forum">
<form action="Test2.php" method="post">
<input type="text" name="firstname" placeholder="FirstName"> <br />
<input type="text" name="lastname" placeholder="LastName"> <br />
<input type="text" name="email" placeholder="E-mail"> <br />
<input type="text" name="topic" placeholder="Topic"> <br />
<input type="text" name="message"> <br />
<input type="submit" name="Send">
</form>
</div>
它给了我这个错误:
“注意:未定义的变量:第22行的C:\ xampp \ htdocs \ myfiles \ Test2.php中的FirstName”
第22行指的是“echo $ FirstName;”
我一直盯着这几个小时,任何帮助都会很棒。
答案 0 :(得分:4)
(在此插入关于SQL注入漏洞的强制性评论)
PHP区分大小写。
$Firstname
与
不同$FirstName