I am working on a pet project to create a website for managing shared prototype hardware.
I am trying to implement some functionality to send an email to the person currently using a specific piece of hardware.
The website user ticks a checkbox alongside the proto they need and an email should be sent to the person currently in possession of it.
The function to send the email works but it appears an “if” statement never holds true. if($submit){ We never end up in here }
Could one of you save me from beating my head against a wall!
Thanks
Chris
[code=php]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>ProtoWars – Proto Request</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<body>
<table align=”center”>
<tr>
<td>
<img src=”Pbryogtboy-goyorgylrey.gif”>
<table align=”center”>
<tr>
<td>
<form action=”request.php” method=”post”>
<input type=”text” name=”proto_lookup” value=”e.g Astro or chrankin” onFocus=”if(this.value==’e.g Astro or chrankin’)this.value=”;”>
<input name=”lookup” type=”submit” id=”lookup” value=”Proto-oogle Search”>
<!–</form>–>
</td>
</tr>
</table>
<?php
INCLUDE ‘constants.php’;
INCLUDE ‘db_connect.php’;
INCLUDE ‘2testmail.php’;
connecttodb($servername,$dbname,$dbusername,$dbpassword);
$proto_lookup=$_POST[proto_lookup];
$sql=”SELECT * FROM protos WHERE (proto_name LIKE ‘$proto_lookup%’) OR (username LIKE ‘$proto_lookup%’)”;
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<table width=”400″ border=”0″ cellspacing=”1″ cellpadding=”0″>
<tr>
<td><!–<form name=”form1″ method=”post” action=””>–>
<table align=”center” width=”400″ border=”0″ cellpadding=”3″ cellspacing=”1″ bgcolor=”#CCCCCC”>
<tr>
<td> </td>
<td colspan=”4″><strong>Select a proto to request</strong></td>
</tr>
<tr>
<td> </td>
<td align=”center”><strong>ID</strong></td>
<td align=”center”><strong>Proto Name</strong></td>
<td align=”center”><strong>Proto Owner</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){
?>
<tr>
<td align=”center”><input name=”checkbox[]” type=”checkbox” id=”checkbox[]” value=”<? echo $rows[‘proto_id’]; ?>”></td>
<td bgcolor=”#FFFFFF”><?php echo $rows[‘proto_id’]; ?></td>
<td bgcolor=”#FFFFFF”><?php echo $rows[‘proto_name’]; ?></td>
<td bgcolor=”#FFFFFF”><?php echo $rows[‘username’]; ?></td>
</tr>
<?php
}
?>
<?php
$submit=$_POST[‘submit’]; // I added this to see if it would help but it does not.
if($submit){ // This apears to never hold true ?!
echo(“Mail Sent ###############################################”);
$checkbox=$_POST[‘checkbox’];
for($i=0;$i<count($checkbox);$i++){
$proto_req_id = $checkbox[$i];
$sent =send_request_email($proto_req_id); // This function call does work when tested alone in a separate file
}
}
//if successful refresh
if($sent == true){
echo(“Mail Sent ###############################################”);
echo “<meta http-equiv=”refresh” content=”0;URL=request.php”>”;
}
mysql_close();
?>
<tr>
<td><input name=”submit” type=”submit” id=”submit” value=”submit”></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>