下面的表格显示了点击提交按钮,如果我们只输入和submit.The错误显示的名称是一个错误
致命错误:调用在C未定义功能test_input():\ WAMP \ WWW \上线11网络\ new9.php
任何人都可以找到下面的代码的问题。
<?php
// define variables and set to empty values
$name1Err = $email1Err = "";
$name1 = $email1 = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["input_1"]))
{$name1Err = "Your name is required. Just the first will do. ";}
else
{$name1 = test_input($_POST["input_1"]);
if (!preg_match("/^[a-zA-Z ]*$/",$name1))
{ $name1Err = "Only letters and white space allowed"; }
}
if (empty($_POST["input_12"]))
{$email1= "";}
else
{$email1 = test_input($_POST["input_12"]);
// check if e-mail address syntax is valid
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email1))
{ $emailErr = "Invalid email format"; }
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
}
?>
<form method='post' enctype='multipart/form-data' action=''>
name<input name='input_1' type='text' value='<?php echo $name1;?>' tabindex='1' />
<div class="validation_message"><?php echo $name1Err ?></div>
email<input name='input_12' type='email' value='<?php echo $email1;?>'/><br/>
<textarea name='input_5' tabindex='9' rows='10' cols='50'></textarea>
<input type='submit' value='Submit' tabindex='25' />
</form>
<?php
echo "<h2>Your Input:</h2>";
echo "Name:".$name1;
echo "<br>";
echo "Email:".$email1;
echo "<br>";
?>