【发布时间】:2014-03-01 22:57:29
【问题描述】:
我正在尝试为我的网站实施用户登录系统。我有一个 newMember.html 文件,其格式如下:
<form method="post" action="nameValidation.php">
<p>Username:</p>
<input type="text" name"user" required>
<input name="submitButton" type="submit" value="Create account"/>
</form>
在 nameValidation 中,我检查用户名是否可用。如果不是,我想要某种方式在您输入用户名的输入字段旁边显示红色文本。我尝试了类似的方法,但出现服务器错误:
(在 nameValidation.php 内)
<?php
//connect to database, check the value of the username to see if it exists
if (username already exists) {
//keep the page that i had the way it was,
//just add a red sentence saying "username is already taken"
}
else {
//tell the user he was successful in making an account,
//and redirect him to my login page (already implemented)
}
?>
我不想使用内联 php 有两个原因。
1) 它看起来杂乱无章(至少在我看来)
2) 我在其他 stackoverflow 帖子中读到这不是一个好习惯。
如果需要,我将使用内联 php,但我们将不胜感激!
【问题讨论】:
-
“内联 php”对您意味着什么?服务器错误信息到底是什么?