undefined index error. PHP version : 5.4.7 -
i want login page. when enter details, issue appeared.
login.php
<?php session_unset (); ?> <html> <head> </head> <body> <form action="movie1.php" method="post"> <p>enter username: <input type="text" name="user"/> </p> <p>enter password: <input type="password" name "pass"/></p> <p> <input type="submit" name="submit" value="submit" /></p> </form> </body> </html>
movie1.php
<?php session_start(); $_session['username'] = $_post['user']; $_session['userpass'] = $_post['pass']; $_session['authuser'] = 0; if (($_session['username'] == 'joe') , ($_session['userpass'] == '12345')) { $_session ['authuser']=1; } else { echo 'you can not enter here.'; exit (); } ?> <html> <?php $myfavmovie = urlencode ('life of brain'); echo "<a href=\"moviesite.php?favmovie=$myfavmovie\">"; echo "click here more information"; echo "</a>"; ?> </html>
when try login user name: joe , password: 12345. error. notice: undefined index: pass in c:\xampp\htdocs\book\book\movie1.php on line 4 php version 5.4.7.
moviesite.php
<?php session_start(); if ($_session['authuser'] != 1) {echo "you don't enter here."; exit(); } ?> <html> <head > <title > movie site - <?php echo $_get['favmovie']; ?> </title> </head > <?php echo "welcome our website, " ; echo $_session['username']; echo "."."<br>"; echo "my favorite film "; echo $_get['favmovie']; echo "<br>"; $movierate= 5; echo "my point is"." ".$movierate; ?> </html>
change,
<input type="password" name "pass"/></p>
to
<input type="password" name="pass"/></p>
because of invalid html markup (missing =), php won't see input "pass". won't appear in $_post array, it's giving undefined index error because you're trying reference doesn't exist.
Comments
Post a Comment