Page 1 of 1

PHP LOGIN

Posted: Mon Sep 14, 2009 12:40 am
by brmcdani
Iam stuck on my login screen. I have no clue what the deal is. I don't know if I am not connecting to the database properly or what. Here is what I have code wise and the screen shot is what I get when I run it in my browser.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body>
<?php
$con = mysql_connect("localhost", "tutorial", "LsGQmFYsMBjUwvL4");
mysql_select_db("tutorial", $con);
$q = "SELECT * FROM `logintable` WHERE user='$usernamefield' AND pass='$passwordfield'";
$logincheck = mysql_query($q, $con) or die(mysql_error($con));
 
if(!isset($_POST['username']) || !isset($_POST['password'])){
   print "No username/password defined";}
print_r($logincheck)."<br/>";
print_r($rows);
 
$usernamefield = $_POST['username'];
$passwordfield = $_POST['password'];
 
$rows = mysql_fetch_array($logincheck);
 
if ($rows != "") {
    echo "Welcome please select your lake";
}
else {
 
?>
 
 
<form id="form1" name="form1" method="post" action="">
  <p>
    <label>
      User Name:  
      <input type="text" name="username" id="username" />
    </label>
  </p>
  <p>Password: 
    <label>
      <input type="text" name="password" id="password" />
    </label>
  </p>
  <p>
    <label>
      <input type="submit" name="submit" id="submit" value="Submit" />
    </label>
  </p>
</form>
</body>
</html>
 
Image

Re: PHP LOGIN

Posted: Mon Sep 14, 2009 3:01 am
by requinix
The PHP code isn't being executed.

The file needs a .php extension, not .html.