why do i keep getting use of undefined constant... errors

A

Anonymous

Guest
all i have is a simple form

Code:
<html>

<head>
<title>I.P tutor >> Admin >> Messaging</title>
</head>

<body>


<form action="sendmessage.php" method="post">
     <input type="hidden" name="redirect" value="<?php echo $redirect; ?>">
     <h3>Username: <input type="text" name="username" size="20"></h3>
     <h3>Message: <input type="text" name="message" size="84"></h3>
     <input type="Submit" name="submit" value="Send">
     <input type="Button" value="Cancel" name="cancel" onclick="history.go(-1)"></form>
</body>

</html>

and the the following on the next page to send to the sql db

Code:
<?php

include "auth_admin.inc.php";
include "conn.inc.php";

$username = $_POST[username];
$adminmessage = $_POST[message];

$sqlstatement = "UPDATE user_info SET adminmessage = '$adminmessage' WHERE username = '$username'";

$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error()); 

?>

why do i keep getting these? even though the data is entered fine?

Notice: Use of undefined constant username - assumed 'username' in C:\Program Files\Apache Group\Apache2\htdocs\admin\sendmessage.php on line 6

Notice: Use of undefined constant message - assumed 'message' in C:\Program Files\Apache Group\Apache2\htdocs\admin\sendmessage.php on line 7

cheers for any help
 
Change line 7 and 8 to this:

Code:
$username = $_POST["username"];
$adminmessage = $_POST["message"];

Coditor
 
further you must initialize all the variables before using them.
This is the requirement for E_ALL setting.
 
Back
Top