troubleshooting Question

Use of undefined constant

Avatar of 7704300
7704300 asked on
PHP
9 Comments1 Solution794 ViewsLast Modified:
Hi

When tryin to create my first php login page(it connects to a mySQL db) I get the following errors.  Can anyone help?
Thank you

Warning: Use of undefined constant Num_Login_Details_ID - assumed 'Num_Login_Details_ID' in c:\phpdev\www\helpdesk\userlogin.php on line 3

Warning: Undefined variable: _POST in c:\phpdev\www\helpdesk\userlogin.php on line 3

Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\helpdesk\userlogin.php:3) in c:\phpdev\www\helpdesk\userlogin.php on line 4


************************************************************************************

Also here is my code!

<?php
//check for required fields from the form
if ((!$_POST[Num_Login_Details_ID]) || (!$_POST[String_Login_Details_Pswd])) {
      header("Location: userlogin.html");
      exit;
}

//connect to server and select database
$conn = mysql_connect("localhost", "", "") or die(mysql_error());
mysql_select_db("project_client_db",$conn) or die(mysql_error());

//create and issue the query
$sql = "select Num_Login_Details_ID from login_details
 where Num_Login_Details_ID = '$_POST[Num_Login_Details_ID]' AND String_Login_Details_Pswd = password('$_POST[String_Login_Details_Pswd]')";
$result = mysql_query($sql,$conn) or die(mysql_error());

//get the number of rows in the result set; should be 1 if a match
if (mysql_num_rows($result) == 1) {

      //if authorized, get the values of Num_Login_Details_ID
      $f_name = mysql_result($result, 0, 'Num_Login_Details_ID');
      

      //create display string
      $display_block = "<P>$Num_Login_Details_ID is authorized!</p>
      <P>Authorized Users' Menu:
      <ul>
      <li><a href=\"secretpage.php\">secret page</a>
      </ul>";

} else {

      //redirect back to login form if not authorized
      header("Location: userlogin.html");
      exit;
}
?>
<HTML>
<HEAD>
<TITLE>User Login</TITLE>
</HEAD>
<BODY>
<? echo "$display_block"; ?>
</BODY>
</HTML>

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros