php - unexpected T_VARIABLE on login script -


this question has answer here:

hi learning php , having trouble writing login script, keep getting ", unexpected t_variable" error code says on line 16 can not find issue

  <?php     if(isset($_post['user'])) {       $user = $_post['user'];         $pass = md5($_post['pass']);          $con = mysql_connect ("localhost","root","");         if(!$con)          {die('could not connect: '.mysql_error());}      mysql_select_db("phplogin", $con);      if (mysql_num_rows(mysql_query("select * users username ='$user' , password = '$pass'"))      $result = mysql_query("select * users username='$user' , password='$pass'")     while($row = msql_fetch_array($result)) {     $expire = time()+60*60*24*30;//1month     $setcookie("udi", $row['uid'],$expire);     echo "logged in. <b>".$row['username']."</b>":     }     }else{//faulse information.     echo "<br> username , password incorrect>";      }     }     }     mysql_close($con);     echo $_cookie['uid'];     echo "<form methot= 'post'>      username:<input type='text' name='user'><br>     password:<input type= 'password' name='pass'>     <input type ='submit' value='login'>     </form>";       ?> 

thanks

matt

you're missing semicolon ";" @ end of line 15.

btw you're code formatting terrible. you're missing opening brace "{" after line 13 (the if statement). not sure if meant or not, don't think so. it's practice use braces.

a thing learn psrs. in particular psr-1 , psr-2, basic coding standard , coding style guide, tells standards recommended php framework interoperability group (fig).


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -