I want to send a number of parameters by the form to a php file to insert to the database,
<html>
<head>
<title>Self</title>
</head>
<body>
<?php
function selfcheck($DB, $TechID, $ClientID, $SiteID, $Type, $LogTime){
$dbConnection = mysql_connect($DB['server'], $DB['loginName'], $DB['password']);
if(!$dbConnection){
die('Error! ' . mysql_error());
}
mysql_select_db($DB['database'], $dbConnection);
$result = mysql_query("SELECT COUNT(*) FROM Log") or die('Error! ' . mysql_error());
while($row = mysql_fetch_array($result)){
$count = $row['COUNT(*)'];
$count = $count+1;
print $count.", ".$TechID.", ".$ClientID.", ".$SiteID.", ".$LogTime.", ".$Type."<br>";
$query = "INSERT INTO Log (LogID, TechID, ClientID, SiteID, LogTime, Type)
VALUES (".$count.", ".$TechID.", ".$ClientID.", ".$SiteID.", ".$LogTime.", ".$Type.")";
mysql_query($query);
}
}
$LogTime = date('Y/m/d H:i', mktime($_GET['Hour'], $_GET['Minute'], 0, $_GET['Month'], $_GET['Day'], $_GET['Year']));
selfcheck($DB, $_GET['TechID'], $_GET['ClientID'], $_GET['SiteID'], $_GET['Type'], $LogTime);
?>
</body>
As you can see, there are nine Get values, however, when I try to execute the codes, the server replys
"Undefined index: Minute in C:\wamp\www\NFC\self.php on line 29", and show in the URL, minute parameter has not been sent. Why does this happen? And how can I solve this problem?
Here is the code to send the request.
print "<form method='get' name='check' action='self.php'>";
$result = mysql_query("SELECT * FROM Tech") or die('Error! '.mysql_error());
print "Name<select id='tech' name='TechID'>";
while($row = mysql_fetch_array($result)){
print "<option value=".$row['TechID'].">".$row['TechName']."</option>";
}
print "</select>";
$result = mysql_query("SELECT * FROM Client") or die('Error! '.mysql_error());
print "Name<select id='client' name='ClientID'>";
while($row = mysql_fetch_array($result)){
print "<option value=".$row['ClientID'].">".$row['ClientName']."</option>";
}
print "</select>";
$result = mysql_query("SELECT * FROM Site") or die('Error! '.mysql_error());
print "Name<select id='site'name='SiteID'>";
while($row = mysql_fetch_array($result)){
print "<option value=".$row['SiteID'].">".$row['SiteName']."</option>";
}
print "</select>";
print "Type<select id='type' name='Type'>";
print "<option value='Checkin'>Check In</option>";
print "<option value='Checkout'>Check Out</option>";
print "</select><br>";
print "Year<input type='text' id='year' size='4' name='Year'/>";
print "Month<input type='text' id='month' size='2' name='Month'/>";
print "Day<input type='text' id='day' size'2' name='Day'/>";
print "Hour in 24<input type='text' id='hour' size='2' name='Hour'/>";
print "Minute<input type='text' id='minute' size'2'name='Minute'/>";
print "<input type='submit' value='Manual check' onclick='self.php'/>";
print "</form>";
it is in a PHP file as for some choices, I want to get the options from the database instead of hard code them. I have tried to send the parameters through a javascript file, but the situation cannot be solved.
You really aren’t helping yourself by constructing your markup in this way.
I suspect your answer is here:-
No space between the end of the size attribute and the beginning of the name attribute. As far as the page that picks this value up is concerned, the value ‘Minute’ does not exist.
Change it to:-