Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <title>Update Phone Nr.</title>
- </head>
- <body><?php
- $employeeNumber = filter_input(INPUT_POST, 'EmployeeNumber');
- $officePhone = filter_input(INPUT_POST, 'OfficePhone');
- if (!isset($_POST['Find'])) { //check if form has been submitted
- header("Location: index.php"); // if not, redirect to index.php
- die();
- }
- $errorCount = 0;
- $validId = validID($employeeNumber);
- $validPhone = validPhoneNum($officePhone);
- if ($validId && $validPhone) {
- echo "<p>Thank you. Employee $validId's number has been updated to $validPhone</p>";
- } else {
- echo "<p>Please use the \"Back\" button to re-enter the data.</p>";
- }
- ?></body>
- </html><?php
- function validPhoneNum($phone_raw) {
- $phone = stripcslashes(trim($phone_raw));
- if (strlen($phone) !== 10) {
- echo "<p>please enter a valid 10 digit phone number</p>";
- return false;
- } else if (is_numeric($phone) == false) {
- echo "<p>phone number must only contain numbers</p>";
- return false;
- }
- return $phone;
- }
- function validID($id_raw) {
- $id = stripcslashes(trim($id_raw));
- if (empty($id)) { //check if Employee Number field is blank
- echo "<p>You must enter an employee Number</p>"; //if blank display message
- return false;
- }
- return $id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement