Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="localhost"; // Host name
- $username="root"; // Mysql username
- $password=""; // Mysql password
- $db_name="baza"; // Database name
- $tbl_name="uporabnik"; // Table name
- // Connect to server and select databse.
- $con=mysqli_connect($host, $username, $password)or die("cannot connect");
- mysqli_select_db($con,$db_name)or die("cannot select DB");
- // username and password sent from form
- $myusername=$_POST['enaslov'];
- $mypassword=$_POST['geslo'];
- // To protect MySQL injection (more detail about MySQL injection)
- $myusername = stripslashes($myusername);
- $mypassword = stripslashes($mypassword);
- //$myusername = mysql_real_escape_string($myusername);
- //$mypassword = mysql_real_escape_string($mypassword);
- $sql="SELECT enaslov, geslo FROM uporabnik WHERE enaslov='$myusername' and geslo='$mypassword'";
- $result=mysqli_query($con,$sql);
- // Mysql_num_row is counting table row
- $count=mysqli_num_rows($result);
- // If result matched $myusername and $mypassword, table row must be 1 row
- if($count==1){
- // Register $myusername, $mypassword and redirect to file "login_success.php"
- header("Refresh:1; url=prvastran.php";
- }
- else {
- echo "Napačno uporabniško ime ali geslo";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement