接收变量时遇到问题,我收到的错误消息是
注意:未定义的索引:第7行的C:\ Users\PC\Documents\XAMPP\htdocs\php\addpost.php中的标题注意:未定义的索引:C:\ Users\PC\Documents\XAMPP\htdocs\php \中的文本第8行的addpost.php
// HTML文档
<div id="postdialog" title="Add Post" action="php/addpost.php">
<p>Please Fill in out member information.</p>
<form name="insertmember" action="php/addpost.php" >
<label>Title<input type="text" name="title" id="title"/></label>
<label>Text<textarea name="text"></textarea></label>
<input name="submit" type="submit" value="Submit" id="submit" />
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
// PHP文件
if ($_POST['submit'] = "submit") {
$title = $_POST['title'];
$text = $_POST['text'];
$errors = array();
if (empty($_POST['title'])) {
$errors[] = "Title is Missing";
}
else
{
$title = $_POST['title']
if (strlen($fname) > 15 ) {
$errors[] = "Title is too long";
}
}
if (empty($_POST["text"])) {
$errors[] = "Text is Missing";
}
else
{
$text = $_POST['text']
if (strlen($lname) > 30 ) {
$errors[] = "Text is too long";
}
}
if (!empty($errors)) {
print_r ($errors);
}
else
{
//DO SOMETHING ELSE
}
Run Code Online (Sandbox Code Playgroud)