i have put everyting in one form, i used to have more, but the thing is when the action taken text area is submitted it gets emailed and it shouldnt, only when the email text area is filled in and submit is pressed should that get emailed off.
here is my code can anyone shed any light
<html>
<head>
</head>
<body>
<?php
require('dbconnect.php');
set_time_limit(0);
$jobId=$_GET['jobId'];
$sql = "select jobId, email, room, computers, description, date FROM requests_table
WHERE requests_table.jobId='$jobId'";
$result = mysql_query($sql);
//echo mysql_error() ;
echo "<table width=\"100%\">\n";
//echo "<table>\n";
echo " <tr>\n";
echo " <th align=\"left\"><b>JobID</b></th>\n";
echo " <th align=\"left\"><b>Email</b></th>\n";
echo " <th align=\"left\"><b>Room</b></th>\n";
echo " <th align=\"left\"><b>Computers</b></th>\n";
echo " <th align=\"left\" ><b>Description</b></th>\n";
echo " <th align=\"left\"><b>Date&time</b></th>\n";
echo " </tr>\n";
//while ($row = mysql_fetch_array($result))
$row = mysql_fetch_array($result);
echo '<td>'.$row['jobId'].'</td>';
echo '<td >'.$row['email'].'</td>';
echo '<td>'.$row['room'].'</td>';
echo ' <td>'.$row['computers'].'</td>'."\n";
echo ' <td>'.$row['description'].'</td>'."\n";
echo ' <td>'.$row['date'].'</td>'."\n";
echo '</tr>'."\n";
echo '</table>';
echo '<hr>';
?>
<br>
<?php
$color[0] = "FCFCFC";
$color[1] = " 34ADE5 ";
$jobId=$GET['jobId'];
$action_taken=$GET['action_taken'];
$Tech_initals=$_GET['Tech_intials'];
if($_POST["Submit1"]) {
$action_taken = addslashes($POST['action_taken']);
$Tech_initals = addslashes($POST['Tech_initals']);
$result = mysql_query("INSERT INTO tech_table (jobId, Tech_initals, action_taken, date)
VALUES ('$jobId', '$Tech_initals', '$action_taken', NOW())") or die("Unable to insert record: " . mysql_error());
}
//$sql = "SELECT jobId, Tech_initals, action_taken, date FROM tech_table ";
$sql = "SELECT jobId, Tech_initals, action_taken, date FROM tech_table WHERE jobId='".$_GET['jobId']."'";
$result = mysql_query($sql);
echo "<H3><b>Job History</b></H3>";
echo "<table>\n";
echo " <tr>\n";
echo " <th><b>JobID</b></th>\n";
echo " <th><b>Tech Initals</b></th>\n";
echo " <th><b>Action taken</b></th>\n";
echo " <th><b>Date</b></th>\n";
echo " <th><b>Status of Job</b></th>\n";
echo " <th><b>Date of completion</b></th>\n";
echo " </tr>\n";
while ($row = mysql_fetch_array($result)) {
//print_r($result) ;
// echo mysql_error() ;
$a = ($a+1)%2;
echo '<tr bgcolor='.$color[$a] . ">\n";
echo '<td>'.$row['jobId'].'</td>';
echo ' <td>'.$row['Tech_initals'].'</td>'."\n";
echo ' <td>'.$row['action_taken'].'</td>'."\n";
echo ' <td>'.$row['date'].'</td>'."\n";
echo ' <td>'.$row['status_of_job'].'</td>'."\n";
echo ' <td>'.$row['compdate'].'</td>'."\n";
echo '</tr>'."\n";
//echo '</table>';
}
?>
<?php
if (array_key_exists("email", $POST)) {
$sql = "SELECT email FROM requests_table WHERE jobId='".$GET['jobId']."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$to = $row['email'];
$from = "poo@ntlworld.com";
$message = $_POST['action_taken'];
mail($to, "technical services", $message,
"From: {$from}\r\n"
."Reply-To: {$from}\r\n"
."X-Mailer: PHP/" . phpversion());
}
?>
</table>
<br>
<?php
echo '<hr>';
?>
<br>
<form name="details" method="post" action= "<? echo $_SERVER['PHP_SELF'] . "?jobId=" . $jobId; ?>">
<table width="791" height="160" border="0">
<tr><input type="hidden" name="email">
<th width="61" scope="row">TechId</th>
<td width="245"><strong>Action taken </strong></td>
<td width="116"><strong>Status of job </strong></td>
<td width="120"> </td>
<td width="126"> </td>
<td width="97"> </td>
</tr>
<tr>
<th scope="row"><input name="Tech_initals" type="text" size="2" maxlength="2"></th>
<td><textarea name="action_taken" cols="30" rows="3"></textarea></td>
<td><input type="checkbox" name="comp" value="1"></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?PHP
if(isset($GET['comp'])){
//if(isset($REQUEST['comp']?1:0😉) {
$comp=$_GET['comp'];
mysql_query("INSERT INTO tech_table (status_of_job, compdate)
VALUES ('$comp', NOW())") or die("Unable to insert record: " . mysql_error());
}
?>
<tr>
<th scope="row"> </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row"> </th>
<td><strong>Email comment </strong></td>
</tr>
<tr>
<th scope="row"> </th>
<td><textarea name="email" cols="30" rows="3"></textarea></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row"> </th>
<td><input type="submit" name="Submit1" value="Submit"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<hr>
</body>
</html>