I have a page that users can view information on tickets they have logged. I have placed a button at the bottom of the page that the users can click if they want an update. When they click on this button, I want an E-mail to be sent to the administrator notifying that the user wants to be contacted. Can someone tell me why my code isn't working?
Here is my code:
.....
$number = $_REQUEST["ticketnumber"];
$updatereq = $REQUEST["updatereq"];
//Query the table based on the number the user entered.
$query = "SELECT * FROM tblIssues WHERE IssueNumber LIKE '$number'";
$result = mssql_query( $query ) or die ("Query failed");
//Get the number of rows in the resulting query and if it is not equal to zero, print it.
//If it is equal to zero, print a no records message.
$myrows = mssql_num_rows( $result );
if ($myrows == 0)
{
echo "<br><br><center><b>Sorry, no records were found!</b></center>";
}
else
{
?>
<B>Ticket Search</B>
<?PHP
print("<TABLE BORDER='3' CELLSPACING='1' CELLPADDING='2'>");
print("<tr><td>Ticket</td><td>First Name</td><td>Last
Name</td><td>Phone</td><td>E-mail</td><td>Type</td><td>Subject</td><td>Ticket Details</td><td>Date Submitted</td><td>Assigned
To</td></tr>");
for ($i = 0; $i < mssql_num_rows( $result ); ++$i)
{
$line = mssql_fetch_row($result);
print("<tr>");
print( "<td>$line[0] </td>");
print( "<td>$line[1] </td>");
print( "<td>$line[2] </td>");
print( "<td>$line[3] </td>");
print( "<td>$line[4] </td>");
print( "<td>$line[5] </td>");
print( "<td>$line[6] </td>");
print( "<td>$line[7] </td>");
print( "<td>$line[10] </td>");
print( "<td>$line[11] </td>");
print("</tr>");
}
print("</TABLE>");
?>
<BR>
<B>Work Log Details</B><BR>
<textarea name="logdetails" rows="20" cols="70" wrap="virtual" onFocus=this.blur()><?php echo $line[13] ?></textarea>
<?PHP
if ($updatereq)
{
$to = "admin@mail.com";
$email_subject = "User Requests Update";
$message = "The user would like an update on ticket $MaxNumber. Contact the user to let them know what is
happening with the ticket.\n\n";
$message .= "Logged by: $firstname $lastname\n\nTime: $time\n\n";
$message .= "Phone: $phone\n\nE-mail: $email\n\n";
$message .= "Subject: $subject\n\n";
$message .= "Description: $comment\n";
$from = "FROM: dbaccount@mail.com";
mail ($to, $email_subject, $message, $from);
}
}
?>
<INPUT type="submit" name="updatereq" value="Request Update">
</BODY>
</HTML>