PHP的问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 10:30:39
<form id="form1" name="form1" method="post" action="register_php.php">
<input type="text" name="username" />
<input type="submit" name="Submit" value="提交" />
</form>

<?php //registe_php.php
if(isset($_POST['submit'])&&$_POST['submit']=='提交')
{
$username=trim($_POST['username']);
if($usernme=="")
{
header ("Location:register.php?error=1");
exit;
}
?>
表单提交了后台不处理..去掉if(isset($_POST['submit'])&&$_POST['submit']=='提交')就好用了为什么呢~哪位大哥告诉下小弟
谁能帮下忙啊谢谢了.xx

把registe_php.php 中内容改成以下就好了:
<?php //registe_php.php
if(isset($_POST['Submit'])&&$_POST['Submit']=='提交')
{
$username=trim($_POST['username']);
if($username=="")
{
header ("Location:register.php?error=1");
exit;
}
else echo $username;
}
?>
你的源码中有以下错误:
1:在表单中按钮的名字叫:Submit,第一个字母是大写的,而你在registe_php.php中用的时候是小写的,php是区分大小写的;
2:在处理表单时,判断用户名是否为空时,你把变量名写错了,你写成了$usernme,应该是$username;

补充,语句 esle echo $username; 是我加用来测试的.