My page has a form with a textarea and a dropdown menu.
report_pubaccess is the name of the textarea
pub_access is the name of the dropdown menu
When the form is submitted the data is added to a database.
The page then directs to a redirect page, in order to stop the page re-submitting on refresh.
Before redirecting back to the original page the form data is sent out via an email.
Now back on the original page the form data is extracted from the database and displayed bellow the form.
I have added in the absolute URL
$action = 'http://www.online.org.uk/tutor/public/computers/report_confirm_pub.php?pub_access=' . urlencode($id) . '&report_pubaccess=' . urlencode($_soft_id);
However sanitizing the subject header (I would need to be shown where to apply it in my code)
Although the data in the subject field is taken from the drop down menu pub_access, the content of which is already predetermined.
Hopefully you can understand what I am trying to do!
This is the code from the main page.
The code from the redirect and email page is in my previous post
$abe = mysql_pconnect($hostname_abe, $username_abe, $password_abe) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_abe, $abe);
$query_pub_access = "SELECT * FROM pub_access ORDER BY id ASC";
$pub_access = mysql_query($query_pub_access, $abe) or die(mysql_error());
$row_pub_access = mysql_fetch_assoc($pub_access);
$totalRows_pub_access = mysql_num_rows($pub_access);
$resolved_result = 'No';
if (isset($_GET['submit'])) {
$name = $_GET['pub_access'];
$report = str_replace("\r\n", " ", trim($_GET['report_pubaccess']));
$resolved = $_GET['resolved'];
$output = false;
if (empty($name) || empty($report)) {
echo 'Please fill out all of the email information.<br />';
$output = true;
}
if (!empty($name) && !empty($report)) {
$dbc = mysqli_connect('127.0.0.1', 'root', 'root', 'abe')
or die('Error connecting to MySQL server.');
date_default_timezone_set('Europe/London');
$date = date('Y'-'m'-'d');
$query = mysql_query("INSERT INTO reportspub (name, report, date, resolved)
VALUES ('$name', '$report', null, 0)") or die(mysql_error());
mysqli_query($dbc, $query);
mysqli_close($dbc);
}
$_def_soft_id = 1;
$_def_id = 9876;
$_id = (int) $_id;
$_soft_id = (int) $_soft_id;
$_soft_id = isset($_GET['report_pubaccess']) ? $_GET['report_pubaccess'] : $_def_soft_id;
$_id = isset($_GET['pub_access']) ? $_GET['pub_access'] : $_def_id;
$_action = 'http://www.online.org.uk/tutor/public/computers/report_confirm_pub.php?pub_access=' . urlencode($_id)
. '&report_pubaccess=' . urlencode($_soft_id);
ini_set('display_errors', 1);
error_reporting(E_ALL);
$_action = str_replace( ' +', '%20', $_action );
header('Location:' . $_action);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Computer faults - Public Access</title>
</head>
<body>
<table width="60%" border="0" align="center" cellpadding="0" id="round_corners_table">
<tr>
<td width="155" height="80" align="right"></td>
<td width="166" align="left" bgcolor="#FFFFFF"><a href="../../index.php"><img src="../../images/Res_home.png" border="0" /></a></td>
<td width="62" align="right" bgcolor="#FFFFFF"> </td>
<td width="160" bgcolor="#FFFFFF"><a href="computers.php"><img src="../../images/list.png" width="54" height="69" border="0" /></a></td>
<td width="232" bgcolor="#FFFFFF"><a href="<?php echo $logoutAction2 ?>"><img src="../../images/log_out2.png" width="73" height="71" border="0" /></a></td>
<td width="31" align="left"></td>
</tr>
</table>
<div class="whitediv">
To report a Public Access Computer<br />
please choose its name from the drop down menu <br />
and complete the form.</div>
<form method="get" action=""><br /><div class="forms">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><img src="../../images/Public.png" alt="" border="0" /></td>
<td> </td>
</tr>
<tr><td align="center" valign="top"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="bottom"><label for="pub_access"></label><select name="pub_access" id="pub_access">
<?php
do {
?>
<option value="<?php echo $row_pub_access['name']?>"><?php echo $row_pub_access['name']?></option>
<?php
} while ($row_pub_access = mysql_fetch_assoc($pub_access));
$rows = mysql_num_rows($pub_access);
if($rows > 0) {
mysql_data_seek($pub_access, 0);
$row_pub_access = mysql_fetch_assoc($pub_access);
}
?>
</select> </td>
</tr>
</table>
</td>
<td><label for="report_pubaccess"></label>
<span id="sprytextarea1">
<textarea name="report_pubaccess" id="report_pubaccess" cols="50" rows="8" value=""></textarea>
<span class="textareaRequiredMsg">A value is required.</span></span><br />
<input name="resolved" type="hidden" value="<?php echo $resolved_result ?>" />
</td>
</tr>
<tr>
<td></td>
<td colspan="2" align="left"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr></table></div>
</form><br />
<?php
$dbc = mysqli_connect('127.0.0.1', 'root', 'root', 'abe')
or die('Error connecting to MySQL server.');
$query = "SELECT * FROM reportspub ORDER BY date DESC";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
while( $row = mysqli_fetch_assoc($result)){
$id = $row['id'];
$name = $row['name'];
$report = nl2br($row['report']);
$date = $row['date'];
$resolved = $row['resolved'];
echo "<table align='center' border='0' width='95%' class='tablebg' cellspacing='0' cellpadding='3'>
<tr class='formlabels' height='40px' ><td class='tl' width='35%'>
<img src='../../images/Publicsmall.png' width='24' height='24' align='absmiddle' />
$name</td><td align='left' width='45%'>
<img src='../../images/vcalendarsmall.png' width='34' height='34' align='absmiddle' />
$date</td><td class='tr' width='20%'><strong>Resolved</strong> $resolved</td></tr>
<tr><td colspan='3' class='paddcell'>$report</td></tr><tr bgcolor='FFFFFF' height='10px'><td colspan='3'></td></tr></table>";
}