How can I write this user loggin php / mysql in latest php5 / mysqli

Basically trying to learn php from the web though I keep coming across different versions of php and i'm not entirely sure what version this is, though I'm sure it is out of date as they do not use mysqli.anyways if someone can show me how to write this code though using MySQLi / php 5 ( or latest versions 5.5) that would be extremely helpful and appreciated \[code\] <?php$host = "localhost";$username="root";$password="password";$db_name="test";$tbl_name="members"; //don't forget to add the INSERT INTO as they did it somwhere elsemysql_connect("$host", "$username", "$password") or die ("cannot connect to MYSQLdatabase");mysql_select_db ("$db_name") or die ("Cannot select database Members");$myusername =$_POST['username'];$mypassword =$_POST['mypassword'];$username = stripslashes($myusername);$mypassword =stripslashes($mypassword);$myusername = mysql_real_escape_string($myusername);$mypassword = mysql_real_escape_string($mypassword);$sql="SELECT* FROM $tbl_name WHERE username='$myusername' and password ='$mypassword'";$result=mysql_query($sql);$count=mysql_num_rows($reslt);if($count==1){session_register("myusername");session_register("mypassword");header("location:login_success.php")}else {echo"wrong username or password";}?>\[/code\]
 
Back
Top