[SOLVED]Help with Notice: Undefined index:
Posted: Wed Mar 24, 2004 6:31 pm
My code for the php front end of my MySql database is giving an error. Below is my php code:
This is the Error im getting :
Notice: Undefined index: op on line 7
Line 7 is:
I know its got to be a simple solution, but i've not found an answer from my sources. Any ideas?
Code: Select all
<?//start a session
session_start();
$msg = "";
$valid = "";
//check if user is coming from a form
if ($_POST['op'] == "ds") {
//check username and password
if (($_POST[username] != "admin") || ($_POST[password] != "abc123")) {
//handle bad login
$msg = "<P><font color="#FF0000 "><strong>Bad Login - Try Again</strong></font></P>";
$show_form = "yes";
} else {
//handle good login
$valid = "yes";
$_SESSION[valid] = $valid;
$show_menu = "yes";
}
} else {
//determine what to show
if ($valid == "yes") {
$show_menu = "yes";
} else {
$show_form = "yes";
}
}
//build form block
$form_block ="
<h1>Login</h1>
<form method=POST action="$_SERVER[PHP_SELF]">
$msg
<P><strong>username:</strong><br>
<input type="text" name="username" size=15 maxlength=25></P>
<P><strong>password:</strong><br>
<input type="password" name="password" size=15 maxlength=25></P>
<input type="hidden" name="op" value="ds">
<P><input type="submit" name="submit" value="login"></P>
</FORM>";
//build menu block
$menu_block ="
<h1>My Contact Administration System</h1>
<P><strong>Administration</strong>
<ul>
<li><a href="show_addcontact.php">Add a Contact</a>
<li><a href="pick_modcontact.php">Modify a Contact</a>
<li><a href="pick_delcontact.php">Delete a Contact</a>
</ul>
<P><strong>View Records</strong>
<ul>
<li><a href="show_contactsbyname.php">Show Contacts, Ordered by Name</a>
</ul>";
//assign the block to show to the $display_block variable
if ($show_form == "yes") {
$display_block = $form_block;
} else if ($show_menu == "yes"){
$display_block = $menu_block;
}
?>
<HTML>
<HEAD>
<TITLE>My Contact Management System</TITLE>
</HEAD>
<BODY>
<? echo "$display_block"; ?>
</BODY>
</HTML>Notice: Undefined index: op on line 7
Line 7 is:
Code: Select all
if ($_POST['op'] == "ds") {