Jump to content

almystersv

Members
  • Posts

    105
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

almystersv's Achievements

Member

Member (2/5)

0

Reputation

  1. Oh ok, any chance in showing me how to tidy up my code while we are here!? Ok, so what happens is the user selects a student from student.php and clicks on their surname which then passes the studentID to the newAssessment.php page (shown above) using <a href="newAssessment.php?studentID=<?php echo $row['studentID']?>"><?php echo $row['studentID']?> I have validation in place that if the user clicks submit when there is a textbox that is empty an error message appears but in order for better usability it passes the values already in the textboxes back into the textboxes so they do not need to re-enter all the info. Unfortunately as I am already asking the page to carry over the studentId when the user submits the info with an empty textbox i get this error message... Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Hope this helps. Thanks
  2. What happens is it wont let me pass the values back into the textboxes aswell as the studentID through the URL. If i comment out the pagemode code or the passing of the studentID throught the URL it allows it but with both of them in there it doesn't like it. Any suggestions? PLEASE ???
  3. Hi Guys, I hope your all well. I have this page of code that I am trying to create that wil allow the user to enter scores into the SQL database. I have inplace a series of error messages that use the pagemode function that runs the validation after the submit button is clicked. This works fine on other pages, however... on this page I am also passing the studentID through the URL (from a previous page where the user selects the student they wish to enter the scores for) this therefore crashes the page as it doesn't like me passing two values through the URL. Any help would be brilliant. Here is my code minus the html. <?php session_start(); if(isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require ("connect.php"); $studentID = $_GET['studentID']; $query = "SELECT * FROM student WHERE studentID = ".$studentID; $result = mysql_query($query, $connection) or die ("Error: " . mysql_error()); $row= mysql_fetch_array($result); $page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : ''; if ($page_mode == 'newAssessment') { // ** POSTS THE VARIABLES BACK INTO THE TEXTBOXES ** $Q1p1 = $_POST['Q1p1']; $Q1p2 = $_POST['Q1p2']; $Q1p3 = $_POST['Q1p3']; $Q1p4 = $_POST['Q1p4']; $Q1p5 = $_POST['Q1p5']; $Q2p1 = $_POST['Q2p1']; $Q2p2 = $_POST['Q2p2']; $Q2p3 = $_POST['Q2p3']; $Q2p4 = $_POST['Q2p4']; $Q2p5 = $_POST['Q2p5']; $Q3p1 = $_POST['Q3p1']; $Q3p2 = $_POST['Q3p2']; $Q3p3 = $_POST['Q3p3']; $Q3p4 = $_POST['Q3p4']; $Q3p5 = $_POST['Q3p5']; $Q4p1 = $_POST['Q4p1']; $Q4p2 = $_POST['Q4p2']; $Q4p3 = $_POST['Q4p3']; $Q4p4 = $_POST['Q4p4']; $Q4p5 = $_POST['Q4p5']; $Q5p1 = $_POST['Q5p1']; $Q5p2 = $_POST['Q5p2']; $Q5p3 = $_POST['Q5p3']; $Q5p4 = $_POST['Q5p4']; $Q5p5 = $_POST['Q5p5']; $total = $_POST['total']; $assSurname = $_POST['assSurname']; $assYrGroup = $_POST['assYrGroup']; $assBooklet = $_POST['assBooklet']; $assessment = $_POST['assessment']; // ** VALIDATION CHECKS ON TEXTBOXES ** if($Q1p1 == "") { $message11 = "* Please enter the student's score"; } if($Q1p2 == "") { $message12 = "* Please enter the student's score"; } if($Q1p3 == "") { $message13 = "* Please enter the student's score"; } if($Q1p4 == "") { $message14 = "* Please enter the student's score"; } if($Q1p5 == "") { $message15 = "* Please enter the student's score"; } if($Q2p1 == "") { $message21 = "* Please enter the student's score"; } if($Q2p2 == "") { $message22 = "* Please enter the student's score"; } if($Q2p3 == "") { $message23 = "* Please enter the student's score"; } if($Q2p4 == "") { $message24 = "* Please enter the student's score"; } if($Q2p5 == "") { $message25 = "* Please enter the student's score"; } if($Q3p1 == "") { $message31 = "* Please enter the student's score"; } if($Q3p2 == "") { $message32 = "* Please enter the student's score"; } if($Q3p3 == "") { $message33 = "* Please enter the student's score"; } if($Q3p4 == "") { $message34 = "* Please enter the student's score"; } if($Q3p5 == "") { $message35 = "* Please enter the student's score"; } if($Q4p1 == "") { $message41 = "* Please enter the student's score"; } if($Q4p2 == "") { $message42 = "* Please enter the student's score"; } if($Q4p3 == "") { $message43 = "* Please enter the student's score"; } if($Q4p4 == "") { $message44 = "* Please enter the student's score"; } if($Q4p5 == "") { $message45 = "* Please enter the student's score"; } if($Q5p1 == "") { $message51 = "* Please enter the student's score"; } if($Q5p2 == "") { $message52 = "* Please enter the student's score"; } if($Q5p3 == "") { $message53 = "* Please enter the student's score"; } if($Q5p4 == "") { $message54 = "* Please enter the student's score"; } if($Q5p5 == "") { $message55 = "* Please enter the student's score"; } if($assYrGroup == "[select Year Group]") { $message6 = "* Please select a Year Group"; } if($assessment == "[select Assessment]") { $message7 = "* Please select the Assessment"; } if($assBooklet == "[select Booklet]") { $message8 = "* Please select the Booklet"; } else { //** RUNS A COUNT TO SEE IF THE PRODUCT ALREADY EXISTS ON THE SYSTEM ** $query2 = "SELECT COUNT(*) FROM assessment WHERE assSurname='" . mysql_real_escape_string($assSurname) . "' AND assYrGroup='" . mysql_real_escape_string($assYrGroup) . "' AND assessment='" . mysql_real_escape_string($assessment) . "'"; $result2 = mysql_query($query2, $connection) or die ("Unable to perform query<br>$query2"); $row2= mysql_fetch_row($result2); $count = $row2[0]; if($count) { $message11 .= 'That student already has a completed score for that assessment.<br>'; } else { //** RUNS THE INSERT QUERY ** $query = "insert into assessment values ('','".$Q1p1."','".$Q1p2."','".$Q1p3."','".$Q1p4."','".$Q1p5."','".$Q2p1."','".$Q2p2."','".$Q2p3."','".$Q2p4."','".$Q2p5."','".$Q3p1."','".$Q3p2."','".$Q3p3."','".$Q3p4."','".$Q3p5."','".$Q4p1."','".$Q4p2."','".$Q4p3."','".$Q4p4."','".$Q4p5."','".$Q5p1."','".$Q5p2."','".$Q5p3."','".$Q5p4."','".$Q5p5."','".$assessment."','".$assYrGroup."','".$assBooklet."','".$assSurname."')"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $message9 = "Scores submitted successfully. "; $Q1p2 = ""; $Q1p3 = ""; $Q1p4 = ""; $Q1p5 = ""; $Q2p1 = ""; $Q2p2 = ""; $Q2p3 = ""; $Q2p4 = ""; $Q2p5 = ""; $Q3p1 = ""; $Q3p2 = ""; $Q3p3 = ""; $Q3p4 = ""; $Q3p5 = ""; $Q4p1 = ""; $Q4p2 = ""; $Q4p3 = ""; $Q4p4 = ""; $Q4p5 = ""; $Q5p1 = ""; $Q5p2 = ""; $Q5p3 = ""; $Q5p4 = ""; $Q5p5 = ""; } } } ?> Many thanks
  4. surely what you want is nothing like the example epsom page you gave.
  5. You can make a text box read only using form functions in php.
  6. I would prefer it if they had seperate logins. How do I go about implementing the variables so they do not overwrite?!
  7. Login Check for main system <?php session_start(); require "connect.php"; $username = $_POST['username']; $password = $_POST['password']; $query = "select * from employee WHERE active ='y' AND username='".$username."' AND password='".$password."'"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $row=mysql_fetch_array($result); if($row!=null) { $_SESSION['username'] = $row['username']; $_SESSION['password'] = $row['password']; $_SESSION['type'] = $row['type']; $_SESSION['empID'] = $row['empID']; $_SESSION['fName'] = $row['fName']; $_SESSION['sName'] = $row['sName']; header('Location: welcome.php?var=msgDate'); exit(); } else if($username == "") { $message2 = "Please enter your Username"; header("Location: login.php?message2=$message2"); exit(); } else if($password == "") { $message3 = "Please enter your Password"; header("Location: login.php?message3=$message3"); exit(); } /*else if(active = "n") { $message4 = "Sorry, this users account has been de-activated. Please contact the system administrator." header("Location: login.php?message4=$message4"); exit(); }*/ else { $message = "Invalid user name or password, please try again"; header("Location: login.php?message=$message"); exit(); } ?> Login Check for external area <?php session_start(); require "connect.php"; $fileUsername = $_POST['fileUsername']; $filePassword = $_POST['filePassword']; $query = "select * from fileshare WHERE active ='y' AND fileUsername='".$fileUsername."' AND filePassword='".$filePassword."'"; $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); $row=mysql_fetch_array($result); if($row!=null) { $_SESSION['fileUsername'] = $row['fileUsername']; $_SESSION['filePassword'] = $row['filePassword']; $_SESSION['type'] = $row['type']; $_SESSION['access'] = $row['access']; header('Location: fileshare.php'); exit(); } else if($fileUsername == "") { $message2 = "Please enter your Username"; header("Location: fileLogin.php?message2=$message2"); exit(); } else if($filePassword == "") { $message3 = "Please enter your Password"; header("Location: fileLogin.php?message3=$message3"); exit(); } /*else if(active = "n") { $message4 = "Sorry, this users account has been de-activated. Please contact the system administrator." header("Location: login.php?message4=$message4"); exit(); }*/ else { $message = "Invalid user name or password, please try again"; header("Location: fileLogin.php?message=$message"); exit(); } ?>
  8. Its all on local host at the moment? The user logs into the main system (Session starts) Then logs into external area (Session starts) Finishes in the external area and goes back to Main page of system. There muxt still be some sort of session running otherwise they would be refused access back into the main system completely. Will it work if I change the session names or anything like that?!
  9. Hi, Yeah it is all in the same domain. I have tried it so that they just go back to the main page of the system when they leave the external area but it does not keep their old session variables as the headers/footers etc are determined by the users access levels. When they go back to the main system no headers or footers are called at all!?
  10. Hello Everyone. I have a simple login working that allows people access to the system. With that I have sessions successfully working too. There are two areas to the system, the main area that people have to log into, and a second external area. This external area requires the users to login to it, and u can access it through the main system. Now my question is, Is it possible to keep the existing session open, including all its variables, even when they log into the external area so that when they leave the external area to go back into the main system they dont need to login and it has kept all their session variables!? if further info is needed just ask. Thanks
  11. You can use a form for the uploads and set the type to 'file' which will give u all the browse options etc.. The query to insert the location and to move the file into the destination file is a little harder but have a look at the link above and if your still stuck let me know.
  12. Hi Guys, Im not entirely sure what im doing :-\ I have a basic internal system that needs an administrator to allocate tasks to members of staff. I successfully have the loop working that displays all the tasks to the screen and allows a drop down menu with all the employees in it so each task can have an employee selected for it but now i just need to write it all to the database. I understand that I'll need some form of array and a loop to run through it writing each one to the table but I dont really know hoe exactly to do it. Your advice would truly help. Thanks Here is my code <table width="860" > <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 //Build Select Menu $employee_list = '<select name="empID"><option>Select an Employee</option>'; while ($row2 = mysql_fetch_array($result2)) $employee_list .= '<option value='.$row2['empID'].'>'.$row2['fName'].' '.$row2['sName'].'</option>'; $employee_list .= '</select>'; 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><form action="taskAdminQuery.php" method="post"><?php echo $employee_list; ?></td> </tr> <?php } ?></td> </tr> </table> <input name="Save" type="submit" value="Allocate Tasks" /> </form> <form action="TaskClear.php"> <input name="Clear" type="submit" value="Clear Tasks" /> </form> </div> <?php require "connect.php"; //$empName = $_GET['empName']; //$empID = $_GET['empID']; //$taskID = $_GET['taskID']; $task = array(); $task['empID'] = $_POST['empID']; $task['taskID'] = $_POST['taskID']; foreach($task as $key => $anothertask) { $query = "insert into emptask (taskID, empID, emptaskweekDay, complete) values ('".$taskID."','".$empID."','Monday','N')"; $result = @mysql_query($query, $connection) or die ("Error:".mysql_error()); } $message1 = "Tasks Allocated Successfully."; header("Location: TaskAdmin.php?message1=$message1"); exit(); //} ?>
  13. Hi Guys, Can you let me know what I need to change in this piece of code that will only change the users password if they enter their current password correctly. <?php require "connect.php"; $empID = $_GET['empID']; $password = $_GET['password']; $password2 = $_GET['password2']; $password3 = $_GET['password3']; if(($password == $password2) || ($password3 == $_SESSION['password'])) { $query = "update employee set password = '".$password2."' where empID = ".$empID; $result = @mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); header("Location: changePasswordForm.php"); exit(); } else { $message1 = "Unable to update Password"; header("Location: changePasswordForm.php?message1=$message1"); exit(); } ?> Here is the form it is reading from <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require "connect.php"; $empID = $_SESSION['empID']; $query = "select * from employee where empID = " .$empID; $result = @mysql_query($query, $connection) or die ("Unable to perform query<br>$query".mysql_error()); $row= mysql_fetch_array($result); ?> <!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>Update Password</title> <link rel="stylesheet" type="text/css" href="mystylelogin.css" /> </head> <body> <!-- BIS Portal LOGO --> <table width="100%" border="0"> <tr> <td><img src="images/BISPortal2.gif"></td> </tr> </table> <div id="passForm"> <p>Change Password</p> </div> <form action="changePassword.php" method="get"> <table width="64%" border="0"> <tr> <td width="11%"> </td> <td width="21%"> </td> <td width="32%"></td> <td width="36%"><input name="empID" type="hidden" value=" <?php echo $row['empID']?>" size="3" readonly="true" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td>Current Password: </td> <td><input name="password3" type="password" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td>New Password: </td> <td><input name="password" type="password" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td>Verify New Password: </td> <td><input name="password2" type="password" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><?php if(isset($_GET['message1'])) { echo $_GET['message1']; }?></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><div align="center"> <input name="Save" type="submit" value="Update" /> </div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> Thanks
  14. Hi Guys, I would like for my system to send emails automatically when a button is clicked. I was jsut wondering how difficult this whole process is and if its worth me forgetting the idea and adopting a different approach. What is required for an email to be sent using php script?? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.