Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

INSTRUCTIONS : Write a function named \"validate\" that accepts 1 parameter. The

ID: 3548041 • Letter: I

Question

INSTRUCTIONS:


Write a function named "validate" that accepts 1 parameter. The one parameter is the value of a customerID.


In validate() call customerLookup() and return what customerLookup() returns.

customerLookup() is the first function. Here is my customerLookup function:


function customerLookup($parameter1){

     $customerID=$parameter1;

     $mysqli=mysqli_connect("localhost", "test" , "test" , "test") or die(mysql_error());

     $sql="select * from customers where customerID=$parameter1";

     $recordSet=mysqli_query($mysqli,$sql);

     if($record=mysqli_fetch_array($recordSet, MYSQLI_ASSOC)){

          $password=$record['password'];

          return $password;          

     }else{

          return 'NOTFOUND';

     };

     mysqli_free_result($recordSet);

     mysqli_close($mysqli);

};


This is what I did with my validate() function:


function validate($parameter1){

     // start session to connect

     session_start();

     // pull $password from session variable

     $password=$_SESSION['password'];

     // display the $password

     echo $password;

};


Explanation / Answer

Your validate function should be as below:


function validate($parameter1){

// Get the password from customerLookup function

$password = customerLookup($parameter1);

// display the $password

echo $password;

}


Let me know if you need more help.

Plz dont forget to rate.

Thanks

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote