2013-08-06 19 views
0

我有错误抑制忽略,未定义指数

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Login Page</title> 
<style type="text/css"> 
h2 {letter-spacing: 10px; font-size: .2in; background-color: #33CC00; color: #000000; text-transform:uppercase; width:260px} 
span {color: #FF00CC} 
legend {font-variant: small-caps; font-weight: bold} 
fieldset {width: 260px; font-family: "Times New Roman", Times, serif; background-color: #CCCCCC; color: #000000} 
label {display:block;} 
.placeButtons {position: relative; left: 0px; width: 70px; margin: 5px; 0px;} 
</style> 
</head> 

<body> 
<h2>Login Page</h2> 
<form name="loginform" action='successfullogin.php' method='POST'> 
<fieldset> 
<legend>Form</legend> 
    <label>Username: <input type="text" name="username"/><span>*</span></label> <br/> 
    <label>Password: <input type="password" name="pass"/><span>*</span></label> 
    <input class="placeButtons" type="reset" value='Reset'/> 
    <input class="placeButtons" type="submit" value='Login'/> 
    <a href='register.php'>Register</a> 
</fieldset> 
</form> 
</body> 
</html> 

,也是我的register.php页面

<?php 
echo "Register"; 
$submit = $_POST['submit']; 
$fullname = strip_tags($_POST['fullname']); 
$username = strip_tags($_POST['username']); 
$password = strip_tags($_POST['password']); 
$repeatpassword = strip_tags($_POST['repeatpassword']); 
$date = date("Y-m-d"); 
?> 
<html> 
<p> 
<form action='register.php' method='POST'> 
<table> 
    <tr> 
     <td> 
     Your full name: 
     </td> 
     <td> 
     <input type='text' name='fullname' value='<?php echo $fullname ?>'> 
     </td> 
    </tr> 
    <tr> 
     <td> 
     Choose a username: 
     </td> 
     <td> 
     <input type='text' name='username' value='<?php echo $username ?>'> 
     </td> 
    </tr> 
    <tr> 
     <td> 
     Choose a password: 
     </td> 
     <td> 
     <input type='password' name='password'> 
     </td> 
    </tr> 
    <tr> 
     <td> 
     Repeat your password: 
     </td> 
     <td> 
     <input type='password' name='repeatpassword'> 
     </td> 
    </tr> 
</table> 
<p> 
<input type='submit' name='submit' value='Register'> 
</p> 
</form> 
</html> 

但login.php中页面,当我点击登录页面我有注册错误

Notice: Undefined index: submit in C:\wamp\www\.... on line 3 
Notice: Undefined index: fullname in C:\wamp\www\.... on line 4 
Notice: Undefined index: username in C:\wamp\www\.... on line 5 
Notice: Undefined index: password in C:\wamp\www\.... on line 6 
Notice: Undefined index: repeatpassword in C:\wamp\www\.... on line 7 

我的问题首先是我失踪,其次是什么是这个错误的含义。因为我已经看过很多次了。

+0

在使用任何变量之前,您可以使用isset()函数进行非常有趣的工作。 – Sanchit

回答

0

首先检查表单是否被提交然后处理它。

<?php 
if(isset($_POST)){ 
$submit = $_POST['submit']; 
$fullname = strip_tags($_POST['fullname']); 
$username = strip_tags($_POST['username']); 
$password = strip_tags($_POST['password']); 
$repeatpassword = strip_tags($_POST['repeatpassword']); 
$date = date("Y-m-d"); 
} 
?> 
3

这不是一个错误,这是一个通知。这是告诉你$_POST['submit']等没有填写,这是有道理的,因为你没有发布任何东西给他们。