0
我在'index.php'中有一个表单,我将使用'submit.php'验证一些文本字段,如果一切正常,它应该使用'submit.php将字段插入到我的数据库中”。现在,如果“submit.php”检测到错误,应该呼应我存储在数组下,我在形式“的index.php”的错误:PHP:回声验证消息
的index.php:
<form action="submit.php" method="POST">
<input type="text" name="email" />
<input type="text" name="url" />
<input type="submit" name="Submit" value="Continue"/>
</form>
<div class="errorsgohere"><?php //WHAT TO ADD HERE? ?></div>
SUBMIT.php:
if(isset($_POST['Submit'])) {
//I validate everything... etc..
if(!empty($errors)) {
echo "<div class='errors'>";
foreach($errors as $error) {
echo $error;
}
echo "</div>";
} else { SubmitDatabase(); //If there are no errors it will proceed }
}
我怎么能重复一下我在$错误,但在我的index.php内,如果可能的话,而不刷新整个页面? 在此先感谢!
你可以在前一页显示错误,但是你可以让'submit.php'看起来像'index.php',但是有错误,或者只是在$ _SERVER ['PHP_SELF']'的同一页面上验证。不刷新你需要AJAX。 – elclanrs 2013-04-28 23:35:13