2016-ICT2613-portfolio_task5.php at master · deono_2016-ICT2613-portfolio · GitHub.pdf

Inputpost practicenumber filtervalidateint name

Info icon This preview shows page 1. Sign up to view the full content.

INPUT_POST , 'practicenumber' , FILTER_VALIDATE_INT ); $name = filter_input ( INPUT_POST , 'name' ); $speciality = filter_input ( INPUT_POST , 'speciality' ); $fee = filter_input ( INPUT_POST , 'fee' , FILTER_VALIDATE_FLOAT ); $error_message = "" ; if ( isset ($_POST)) { if ($option == 'add' ) { // test if practicenumber field contains a value if ($practicenumber != "" || $practicenumber != NULL ) { // test if practice number exists $result = practicenumber($practicenumber); if ($result[ 'practicenumber' ] == $practicenumber) { $error_message = "That practice number already exists" ; } else { //insert new user data into table insert($practicenumber, $name, $speciality, $fee); // update table data $query_results = query_all(); } //endif } else { $error_message = "Please enter a practice number" ; } //endif } elseif ($option == 'update' ) { //get row with specified practice number $result = practicenumber($practicenumber); // test if practice number exists if ($practicenumber == $result[ 'practicenumber' ]) { if ($name == "" ) { $name = $result[ 'name' ]; } //endif if ($speciality == "" ) { $speciality = $result[ 'speciality' ]; } //endif if ($fee == "" ) { $fee = $result[ 'fee' ]; } //endif // update table with data from form update($practicenumber, $name, $speciality, $fee); // update table data $query_results = query_all(); } else { $error_message = "That practice number does not exist" ; } // endif } elseif ($option == 'delete' ) { // delete data from table delete ($practicenumber); // update table data $query_results = query_all(); } //endif } //endif ?> <!DOCTYPE html> < html lang = "en-GB" > < head > < title >Task 5</ title > < meta charset = "utf-8" > < link rel = "stylesheet" type = "text/css" href = "main.css" > </ head > < body > < header > <?php include 'menu.inc' ?> </ header > < main > <!-- output --> < h2 >Output</ h2 > < div class = "output" > < div class = "info_message" ><?php echo $message; ?></ div >< br > < div > <!-- table display's db query results -->
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '12
  • The Table, deono, 1 8.07 KB

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern