Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>organiser page></title>
- <style type="text/css">
- th,td{border:1px solid black; width: 150px;}
- </style>
- </head>
- <body>
- <h3>WELCOME TO YOUR ORGANISER PAGE</h3>
- </body>
- <?php
- //Start or resume a session
- session_start();
- //!!Debug (I dont use login.php, I use this to bypass login.php. so remove this sen)!!
- //$_SESSION['volunteermail'] = "john@hotmail.com";
- if ( !isset( $_SESSION['organisermail'] ))
- {
- header('Location: organiser.php');
- exit;
- }
- //connect to database
- $db= new mysqli('localhost','root','','assignment1');
- if (mysqli_connect_error())
- {//display the details of any connection errors
- echo 'Error connecting to database:<br/>'.mysqli_connect_error();
- exit;
- }
- //echo'testing1';
- if (isset($_POST['time_id']))
- {
- //validate that user can't add already added time slot
- $query= "SELECT time_id FROM volunteer_times WHERE time_id ='" . $_POST['time_id'] . "' AND volunteer_email='" . $_SESSION['volunteermail'] . "'";
- //echo $query."<br>";
- $results=$db->query($query);
- if ($results-> num_rows > 0)
- {
- $error_message='Your data already exist, choose another.';
- }
- $query= "INSERT INTO volunteer_times VALUE(NULL,'" . $_SESSION['organisermail'] . "','" . $_POST['time_id'] . "','0','')";
- //echo'insert query';
- $result= $db->query($query);
- if ($result)
- {
- echo'<p>User details inserted into database!</p>.';
- }else{
- echo mysqli_error($db);
- }
- }
- //echo'testing2';
- $query = "SELECT * FROM volunteer_times AS v JOIN time_slot AS t ON v.time_id = t.time_id
- JOIN tasks AS ta ON v.task_id = ta.task_id
- JOIN volunteers as vl ON v.volunteer_email = vl.email" ;
- //execute the query
- $results = $db-> query($query);
- //show how many rows the query returned
- //echo '<p>'.$results->num_rows.' users found.</p>';
- //start the table in which our user list will be shown
- echo '<table><tr>';
- echo'<th>Time Slot</th><th>Volunteer Name</th><th>Allocated Task</th><th>Details</th><th>Remove</th>';
- echo'</tr>';
- //loop through the results and display them
- while ($row=$results-> fetch_assoc())
- {
- $pos_query='SELECT * FROM time_slot WHERE time_id = '.$row['time_id'];
- $pos_results=$db->query($pos_query);
- $pos_row=$pos_results->fetch_assoc();
- echo '<td>'.$pos_row['time_slot_name'].'</td>';
- $pos_query2='SELECT * FROM tasks WHERE task_id= '.$row['task_id'];
- $pos_results2=$db->query($pos_query2);
- $pos_row2=$pos_results2->fetch_assoc();
- //$pos_query3='SELECT * FROM volunteers WHERE surname = '.$row['surname'];
- //$pos_results3=$db->query($pos_query3);
- //$pos_row3=$pos_results3->fetch_assoc();
- echo '<td>'.$row['first_name']." ".($row['surname']).'</td>';
- echo '<td>'.$pos_row2['task_name'].'</td>';
- echo '<td>'.$row['description'].'</td>';
- echo '<td><a href="Allocatet.php?vol_time_id='.$row['vol_time_id'].'">Edit</a> </td></tr>';
- //echo '<td><a href="Allocatet.php?vol_time_id">Edit</a> </td></tr>';
- }
- echo'</table>';
- //echo'testing3';
- //test the clearslot
- if(isset($_POST['Clearslot']))
- {
- $query="UPDATE volunteer_times WHERE SET description=NULL, task_id=0 WHERE vol_time_id='".$row['vol_time_id']."'";
- $result= $db->query($query);
- if ($result)
- {
- echo'<p>User details cleared</p>.';
- }
- }
- ?>
- <form name="clearslot" method="post" action="VolunteerTimeSlots.php">
- <table style="width: 200px; border: 0px;" cellspacing="1" cellpadding="1">
- <input type="submit" name="submit" value="Clearslot" /></td>
- </table>
- </form>
- <?php echo '<p><a href="logout.php">Log Out</a></p>'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement