初学PHP,遇到问题请教
初学PHP,我的代码如下:
<html>
<head>
<title>This is the title</title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
<input type="hidden" name="hidden" value="true">
<?php
if($_POST['hidden']=="true" && $_POST['name']=="") {
print "Please enter your name<br>";
}
?>
<input type="text" name="name" value="<?php echo $_POST['name'];?>" size="30">
<input type="submit" name="submit" value="send the form">
</form>
</body>
</html>
我的目的是这样的:如果form当中的name字段没有输入,那么submit的时候,仍然回到原来的页面,并提示用户输入name,我测试过了,基本上能实现我上述的要求,但是唯一一个问题是在第一磁带开这个页面的时候,首先画面提示“Notice: Undefined index: hidden in E:\htdocs\test.php on line 9”,其次name字段当中有一个莫名其妙的“<br />”,希望能够得到指点,谢谢。