登陆的简单代码,不知道哪里有问题

#1 程序猿在进化

  $name =$_POST['name'];
  $password =$_POST['password'];
  if((!isset($name))||(!isset($password)))
  {
    //Visitor needs to enter a name and password
?>
   

Please Log In


   

This page is secret.


   
      

Username:


      

Password:


      


   
  }
  else if($name=="user"&&$password=="pass")
  {
    // visitor's name and password combination are correct
    echo "

Webprogramming Secret Pages

";
    echo "There is no secrets, only missing information.";
  }
  else
  {
    // visitor's name and password combination are not correct
    echo "

Invalid login/password

";
    echo "You must provide a valid login and password to enter this site.";
  }
?>

照着书demo打的代码。。
[table]
[tr][td=5,1]
( ! ) Notice: Undefined index: name in E:\wamp\www\index.php on line 2
[/td][/tr]
[tr][td=5,1]
Call Stack
[/td][/tr]
[tr][td]
[/td][td]
Time
[/td][td]
Memory
[/td][td]
Function
[/td][td]
Location
[/td][/tr]
[tr][td]
1
[/td][td]
0.0005
[/td][td]
367064
[/td][td]{main}( )[/td][td]..\index.php:0[/td][/tr]
[/table]

[table]
[tr][td=5,1]
( ! ) Notice: Undefined index: password in E:\wamp\www\index.php on line 3
[/td][/tr]
[tr][td=5,1]
Call Stack
[/td][/tr]
[tr][td]
[/td][td]
Time
[/td][td]
Memory
[/td][td]
Function
[/td][td]
Location
[/td][/tr]
[tr][td]
1
[/td][td]
0.0005
[/td][td]
367064
[/td][td]{main}( )[/td][td]..\index.php:0[/td][/tr]
[/table]
登陆界面是有了~功能也有了~但是会报这两个警告~请问怎么解决??!

2014-08-11 12:56:44

#2 程序猿在进化

第二行和第三行不是直接调用输入的name 和password吗?应该没问题啊~:dizzy:

2014-08-11 12:58:06

#3 jake

改成

$name =isset($_POST['name']) ? $_POST['name'] : '';

PS:下次建议非框架问题请发到其他社区,谢谢。

2014-08-11 13:14:22

#4 程序猿在进化

jake 发表于 2014-8-11 13:14
改成

$name =isset($_POST['name']) ? $_POST['name'] : '';
噢噢~好的~谢谢!

2014-08-11 13:41:34