Whenever I load the following page :
<!DOCTYPE Doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
</head>
<?php
error_reporting(E_ALL); //report all errors
echo"YOU HAVE JUST ENTERED PHP...WELCOME !";
if(isset($_POST['submit_button']))
{
echo"YOU ARE NOW IN THE FIRST \"IF\" BLOCK";
$blankuser_submitted = $_POST['blankuser_submitted'];
$user_name_submitted = $_POST['user_name_submitted'];
$blanknode_submitted = $_POST['blanknode_submitted'];
$node_submitted = $_POST['node_submitted'];
$subject_submitted = $_POST['subject_submitted'];
$details_submitted = $_POST['details_submitted'];
$submit_button = $_POST['submit_button'];
if(isset($blankuser_submitted))
{
echo "<small>";
echo "PLEASE SELECT A USER FROM THE DROP DOWN MENU";
echo "IT IS A REQUIRED FEILD";
echo"</small>";
//exit;
}
if(isset($blanknode_submitted))
{
echo "<small>";
echo "PLEASE SELECT A NODE FROM THE DROP DOWN MENU";
echo "IT IS A REQUIRED FEILD";
echo"</small>";
//exit;
}
if(empty($subject_submitted))
{
echo"</small>";
echo "THE SUBJECT FEILD IS EMPTY\n";
echo "IT IS A REQUIRED FEILD";
echo"</small>";
//exit;
}
if(empty($details_submitted))
{
echo"</small>";
echo "THE DETAILS TEXT BOX IS EMPTY\n";
echo "IT IS A REQUIRED THAT IT BE FILLED IN";
echo"</small>";
//exit;
}
else
{
$DBhost =
$DBuser =
$DBpass =
$DBName =
$db = mysql_connect($DBhost,$DBuser,$DBpass) or die(mysql_error());
mysql_select_db("$DBName",$db) or die(mysql_error());
$submit_date = date("Y-m-d"); //the system's date in the following format "yyyy-mm-dd"
$submit_time = date("G:i:s"); //the system's date in the following format "HH:MM:SS"
$sqlquery_details = "INSERT INTO details (submit_date,submit_time,subject,details) VALUES ('$submit_date','$submit_time','$subject_submitted','$details_submitted')";
mysql_query($sqlquery_details) or die("SELECT Error: " . mysql_error() . " in Query: $sqlquery_details");
//split "name" into "user_fname" and "users_lname" for insertion into the "users" table
$user_Name = explode(" ",$user_name_submitted);
$user_fname = $user_Name[0]; //user first name
$user_lname = $user_Name[1]; //user last name
$sqlquery_users = "INSERT INTO users (submit_date,submit_time,user_fname,user_lname) VALUES ('$submit_date','$submit_time','$user_fname','$user_lname')";
mysql_query($sqlquery_users) or die("SELECT Error: " . mysql_error() . " in Query: $sqlquery_users");
//get node from the drop down menu
$sqlquery_nodes = "INSERT INTO nodes (submit_date,submit_time,node) VALUES ('$submit_date','$submit_time','$node_submitted')";
mysql_query($sqlquery_nodes) or die("SELECT Error: " . mysql_error() . " in Query: $sqlquery_nodes");
}
}
else
{
?>
<form method="post" name="submit_form" align="center" action="submit_BK.php">
<table border="0" align="left">
<tr>
<!--SELECT USER -->
<th align="left">
*
<small>
<acronym title="Select User from drop down menu on your right">USER</acronym>
</small>
</th>
<td>
<!-- DROP DOWN MENU FOR SELECT USER -->
<select name="user" tabindex="1">
<option value="blankuser_submitted" />--------- SELECT USER ----------
<option value="user_name_submitted">JOHN DOE
<option value="user_name_submitted">JANE DOE
</select>
</td>
</tr>
<tr>
<!-- SELECT NODE -->
<th align="left">
<br />
*
<small>
<acronym title="Select Node from the drop down menu on your right">NODE</acronym>
</small>
</th>
<td>
<!-- DROP DOWN MENU FOR NODE -->
<br />
<select name="select_node" tabindex="2">
<option value="blanknode_submitted" />--------- SELECT NODE ----------
<option value="node_submitted" />NODE1
<option value="node_submitted" />NODE2
</select>
</td>
<tr>
<th align="left">
<!-- SUBJECT -->
<!-- <br /> -->
*
<small>
<acronym title="Enter Subject" >SUBJECT</acronym>
</small>
</th>
<td> <!-- colspan="9"> -->
<!-- SUBJECT BOX -->
<br />
<input type="text" name="subject_submitted" size="40" tabindex="3" />
</td>
</tr>
<tr>
<th align="left">
<!-- DETAILS -->
<br />
*
<small>
<acronym title="Enter Details" >DETAILS</acronym>
</small>
</th>
<td colspan="2">
<!-- DETAILS TEXTBOX -->
<br />
<textarea name ="details_submitted" rows="6" cols="30" tabindex="4"></textarea>
</td>
</tr>
<tr>
<td>
</td>
<!-- SUBMIT BUTTON -->
<td align ="left">
<button type="submit" name="submit_button" value="submit_button" tabindex="5">
<acronym title="Click button to SUBMIT data to Database">
<b>
<small>
SUBMIT
</small>
</b>
</acronym>
</button>
</td>
</tr>
</table>
</form>
<?
}
?>
</html>
I get theez errors :
Notice: Undefined index: blankuser_submitted in c:\apache\htdocs\FOLDER\SUB_FOLDER\submit_bk.php on line 24
Notice: Undefined index: user_name_submitted in c:\apache\htdocs\FOLDER\SUB_FOLDER\submit_bk.php on line 25
Notice: Undefined index: blanknode_submitted in c:\apache\htdocs\FOLDER\SUB_FOLDER\submit_bk.php on line 27
Notice: Undefined index: node_submitted in c:\apache\htdocs\FOLDER\SUB_FOLDER\submit_bk.php on line 28
Notice: Undefined offset: 1 in c:\apache\htdocs\FOLDER\SUB_FOLDER\submit_bk.php on line 98
at lines 24,25,26,27 I have :
$blankuser_submitted = $_POST['blankuser_submitted'];
$user_name_submitted = $_POST['user_name_submitted'];
$blanknode_submitted = $_POST['blanknode_submitted'];
$node_submitted = $_POST['node_submitted'];
I think the "Notices" are a result of the input statements:
<select name="user" tabindex="1">
<option value="blankuser_submitted" />--------- SELECT USER ----------</option>
<option value="user_name_submitted">JOHN DOE</option>
<option value="user_name_submitted">JANE DOE</option>
</select>
and
<select name="select_node" tabindex="2">
<option value="blanknode_submitted" />--------- SELECT NODE ----------</option>
<option value="node_submitted">NODE1</option>
<option value="node_submitted">NODE2</option>
</select>
My reasoning for doing the option tags like that (ie. letting value being equal to the same thing for all of them ) is that since it's a drop down menu the user will only have one selection example node_submitted being sent to the server....is idea wrong ? And if so how would I go about correcting it ?
With regards to the following notice:
Notice: Undefined offset: 1 in c:\apache\htdocs\FOLDER\SUB_FOLDER\submit_bk.php on line 98
I really don't understand it. I wuz trying to split user_name_submitted into a user first name and last name for insertion into the corresponding DB table !
At line 98 I have:
$sqlquery_users = "INSERT INTO users (submit_date,submit_time,user_fname,user_lname) VALUES ('$submit_date','$submit_time','$user_fname','$user_lname')";
Intrestingly though info still gets inserted into the details table (correctly 🙂 ) while for the users only submit_date and submit_time get inserted and the same for the nodes table