Menu

(Solved) : Created Html Form Need Connect Database Update Phone Number Employee Table Html Update Emp Q37505610 . . .

I have created an HTML form. I need to connect this to adatabase to update the phone number in the employee table

HTML:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01Transitional//EN”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html;
charset=windows-1252″>
</head>
<body link=”#0000EE” vlink=”#551A8B” text=”#000000″bgcolor=”#566573″
alink=”#EE0000″ background=”../DOC/brushed-alum.png”>
<form method=”post” action=”phonenumbers.php”>
<h1>Update Employee Phone Number Form</h1>
<br>
<br>
<h3>Enter the employee’s ID number.</h3>
<br>
<br>
Employee ID Number: <input name=”EmployeeNumber” type=”text”><br>
<br>
<h3>Enter the new phone number</h3>
Phone Number: <input name=”OfficePhone” type=”text”><br>
<br>
<input name=”submit” value=”Update” type=”submit”></form>
<p><a href=”forms.html”>Back to FormsPage</a></p>
<p>
</p>
</body>
</html>

PHP:

<?php

if(isset($_POST[‘submit’])){ //check if form has beensubmitted

   //if form has been submitted

}

//values from the form will be pulled and set as the variablesbelow

$employeeNumber = filter_input(INPUT_POST,’EmployeeNumber’);

$officePhone = filter_input(INPUT_POST,’OfficePhone’);

//function to validate EmployeeNumber field input

function validId($id_raw){

   $Id = stripcslashes(trim($id_raw));

   //removes all slashes and trims spaces frominput

   if(is_numeric($Id)==false){

       //checks to see if Employeenumber only contains numbers

       echo “<p>You must enter avalid Employee Number that only contain numbers.</p>”;

       //if not returns thismessage

       return false;

   }

   return $Id; //if it only contains numbers it willreturn the EmployeeNumber

}

//function to validate Phone Number field input

function validPhoneNum($phone_raw){

   $phone = stripcslashes(trim($phone_raw));

   //removes all slashes and trims spaces frominput

   if(strlen($phone) !== 10){

       //gets the length of the phonenumber and checks if it’s length is 10

       echo “<p>please enter avalid 10 digit phone number.</p>”;

       //if not displays message

       return false;

   }

   if(is_numeric($phone)==false){

       //if the length is 10 the inputis then checked for only containing numbers

       echo “<p>phone number mustonly contain numbers.</p>”;

       //if input does not contain onlynumbers this message is displayed

       return false;

   }

   return $phone;

   //if all requirements are met returns the phonenumber

}

$validId = validID($employeeNumber);

$validPhone = validPhoneNum($officePhone);

if ($validId && $validPhone)

//checks if phone number and employee number is valid

echo “<p>Thank you. Employee $validId’s number has beenupdated to $validPhone</p>”;

else{

   echo “<p>Please use the “Back” button tore-enter the data.</p>”;

}

?>

Expert Answer


Answer to Created Html Form Need Connect Database Update Phone Number Employee Table Html Update Emp Q37505610 . . .

OR