2013-08-06 3 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'] 등은 입력하지 않았으므로 POST에는 아무 것도 입력하지 않았으므로 의미가 있습니다.

관련 문제