mysql - Guidence in PHP login script -


this question has answer here:

i started learning little php , sessions (using xampp run php scripts).

i watching few vidoes , reading few books before started.

the thing have here video saw php , sessions me going. have little problem here person in video did not have.

this login.php code:

<?php session_start();      // starting session $error = '';          // variable store error message  if (isset($_post['submit'])) {     if (empty($_post['username']) || empty($_post['password'])) {         $error = "brukernavn eller passord er ugyldig!";     } else {          // define $username , $password         $username = $_post['username'];         $password = $_post['password'];          // establishing connection server passing server_name, user_id , password parameter         $connection = mysql_connect("localhost", "root", "");          // protect mysql injection security purpose         $username = stripslashes($username);         $password = stripslashes($password);         $username = mysql_real_escape_string($username);         $password = mysql_real_escape_string($password);          // selecting database         $db = mysql_select_db("logintest", $connection);          // sql query fetch information of registerd users , finds user match.         $query = mysql_query("select * users password='$password' , username='$username'", $connection);          $rows = mysql_num_rows($query);         if ($rows == 1) {             $_session['login_user']=$username; // initializing session             header("location: profile.php"); // redirecting other page         } else {             $error = "brukernavn eller passord er ugyldig!";         }         mysql_close($connection); // closing connection     } } ?> 

when try log in , right username error:

fatal error: uncaught error: call undefined function mysql_connect() in
c:\xampp\htdocs\gauldaldesign\login.php:14 stack trace: #0
c:\xampp\htdocs\gauldaldesign\index.php(2): include() #1 {main} thrown in
c:\xampp\htdocs\gauldaldesign\login.php on line 14

anyone can explain means , maybe problem can be? maybe not answer, @ least point me in right direction can learn mistakes.

you're using php 7 , & in videos watched php 5 used.

switch php 5 in xampp , or better use mysqli_* functions , or better, use pdo & prepared statements.

see: http://php.net/manual/en/mysqlinfo.api.choosing.php


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -