Here is the code for my login page

<!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>Login</title>
<style type="text/css">
#apDiv1 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:1;
    left: 608px;
    top: 201px;
}
#apDiv1 form table tr td {
    font-family: "Trebuchet MS";
}
</style>
</head>

<body>

<div id="apDiv1">
<form method ="post" action="login.php">
    <table width="300" border="0">
      <tr>
        <td width="134">Username:</td>
        <td width="156"><input type="text" name='username'/></td>
      </tr>
     <tr>
        <td><p>Password:</p></td>
        <td><p>
          <input type="password" name="password"/>
        </p></td>
      </tr>
      <tr>
      <td callspan"2"><input type="submit" name="submit" value="Login"/> </td>
      </tr>
          </p>

        </table>
  </form>
  </div>
  <?php
include"config.php";

mysql_connect($dbhost, $dbusername, $dbpassword) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

if($_POST["submit"]){

$myusername = ($_POST['username']);
$mypassword = ($_POST['password']);

if((!$myusername) || (!mypassword)){
    echo "Please fill in all fields!";
    exit;
}

    $sql = "SELECT * FROM {$dbtable} WHERE username ='{$myusername}' AND password='{$mypassword}'";
    $result = mysql_query($sql);

    $count = mysql_num_rows($result);

    if($count == 1){
        $_SESSION['username'] = $myusername;
        $_SESSION['password'] = $mypassword;
        $_SESSION['userrecord'] = mysql_fetch_assoc($result);

        echo "SUCCESSFUL! Click here to <a href='account.php'>Login</a>";

    }
}

?>

</body>
</html>

My output is telling me that I have an unidentified index here:

if($_POST["submit"]){

What does this mean and how do I fix this?

Thank you.

Recommended Answers

All 3 Replies

Error in title. Undefined Index*

Use if ( isset( $_POST['submit'] ) ) {

you're a sexy boy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.