phpanon Posted March 16, 2008 Share Posted March 16, 2008 Hello I have a page that allocates tasks to users on the systems. I want it so that they tasks are only saved once all the tasks have an employee allocated to them... Here is the page where the administrator allocates the tasks <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } if (($_SESSION['type']) == 'user') { header("Location: AccessDenied.php"); exit(); } if (($_SESSION['type']) == 'manager') { header("Location: AccessDenied.php"); exit(); } require "connect.php"; ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Task Allocation</title> <link rel="stylesheet" type="text/css" href="mystylelogin.css" /> <style type="text/css"> <!-- .style2 {font-size: 14} --> </style> </head> <body> <?php include ("headerAdmin.php"); include ("TasksHeaderAdmin.php"); ?> <div id="Adminheader">Monday Task Allocation</div> <div id="TaskTable"> <table width="100%" > <hr /> <tr> <th width="142"><div align="left" class="style2">Task Name</div></th> <th width="262"><div align="left" class="style2">Description</div></th> <th width="140"><div align="left" class="style2">Weekday</div></th> <th width="140"><div align="left" class="style2">Assign</div></th> </tr> <?php $query = "SELECT * FROM task WHERE weekday = 'Monday' OR weekday = 'Everyday' ORDER BY taskID"; $result = mysql_query($query) or die(mysql_error()); echo "<form action=\"taskAdminQuery.php\" method=\"post\">\n"; while($row = mysql_fetch_array($result)){ ?> <tr> <td height="27"><?php echo $row['taskName']; ?></td> <td><?php echo $row['taskDescription']; ?></td> <td><?php echo $row['weekday']; ?></td> <td> <select name="<?php echo $row['taskID']; ?>"> <option selected>--Select an Employee--</option> <?php $query2 = "SELECT empID, fName, sName FROM employee WHERE active = 'y'"; $result2 = mysql_query($query2) or die(mysql_error()); while ($row2 = mysql_fetch_array($result2)){ echo " <option value=\"".$row2['empID']."\">".$row2['fName']." ".$row2['sName']."</option>\n"; } ?> </select> </td> </tr> <?php } ?> </table> <table width="100%" border="0"> <tr> <td> <input name="Save" type="submit" value="Allocate Tasks" /> </form> </td> <td> <?php if(isset($_GET['message1'])) { echo $_GET['message1']; } ?> </td> </tr> </table> </div> </body> </html> and here is the page that runs the query <?php require "connect.php"; $task = array(); $task['empID'] = $_POST['empID']; $task['taskID'] = $_POST['taskID']; foreach($_POST as $taskID => $empID) { // don't want to run query on the submit button if($taskID != "Save") { $query = "insert into emptask (taskID, empID, emptaskweekDay, complete) values ('".$taskID."','".$empID."','Monday','N')"; $result = @mysql_query($query, $connection) or die ("Error:".mysql_error()); } } $message1 = "All of Mondays tasks were allocated successfully."; header("Location: TaskAdmin.php?message1=$message1"); exit(); //} ?> ...So if any of the select drop down menu equal '--Select an Employee--' then dont run the insert query Link to comment https://forums.phpfreaks.com/topic/96335-error-messages/ Share on other sites More sharing options...
phpanon Posted March 16, 2008 Author Share Posted March 16, 2008 any ideas anyone?? :-\ Link to comment https://forums.phpfreaks.com/topic/96335-error-messages/#findComment-493301 Share on other sites More sharing options...
wildteen88 Posted March 16, 2008 Share Posted March 16, 2008 I asumme change this line: if($taskID != "Save") to if($taskID != "Save" && $empID != '--Select an Employee--') Only guessin Link to comment https://forums.phpfreaks.com/topic/96335-error-messages/#findComment-493335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.