This Form and PHP script won't work

I am just learning PHP and MySQL and I have been experimenting with a login script. I am using the Apache Web Server v2.2 and have installed the latest versions of PHP and MySQL. (And I know they work cause I can put in simple code and it works.) Here is my script.

login.html (where the form is located):

Please fill out this form to login.



Username: Password:

checklogin.php:

<?php $host="localhost"; $username="root"; $password=md5(5d41402abc4b2a76b9719d911017c592); $db_name="users"; $tbl_name="users"; mysql_connect($host,$username,$password)or die("Cannot Connect" . mysql_error()); mysql_select_db("users", $con); $myusername=$_POST['$username']; $mypassword=$_POST['$password']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($sql); echo $count; if($count==1){ session_register("myusername"); session_register("mypassword"); echo "Your logged in!"; } else{ echo "Wrong Username or Password"; } ?>

Thanks!

Wolfgamezzz

Uuhm, okay? That’s nice. Shouldn’t this be in Code Snippets?

What is the problem?? What errors are you getting, any?

Sponsor our Newsletter | Privacy Policy | Terms of Service