Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1) Answer the following questions with true or false: 1. the following code is bug free: 2. the following is an example of an indexed

Q1) Answer the following questions with true or false:

1. the following code is bug free:

For($i; i < 5; $i++) {

Echo "Hello world!";

}

?>

2. the following is an example of an indexed array:

$age = array("Product_01"=>"Orange", "Product_02"=>"Apple, "Prouduct_03"=>"Mango");

3. We can use loops to print array content.
4. There is no need to declare variable type in PHP.

5. The following code is bug free:

$var = "test";

echo "

$Var

";

6. String in PHP can be between " or '

Q2) Write a basic HTML and PHP code, where the first name and last name are taken from then user. Stores in variables and printed as HTML paragraphs.

Q3) In the following code (4 Marks)

a. Write a method that prints the classs details.

b. Create an object of this class.

c. Set its name account and id (Note: you are free to assign any value).

d. Print its details.

class BankAccount{

public $name;

public $accoumtNo;

private $id;

private $accountBalance;

public function setName($name){

$this->name = $name;

}

public function setAccount($accoumtNo){

$this->accoumtNo = $accoumtNo;

}

public function setId($id){

$this->id = $id;

}

}

?>

Q4) Answer the following question:

Q4.1: Select the best answer (2 Marks)

1. is used to add new rows to the database:

a. INSERT.

b. UPDATE.

c. SELECT.

d. None of the above.

2. UPDATE table_01 SET col_02='$user_name' WHERE col_01 = 4:

a. Will update all rows.

b. Will update one row.

c. Will update one row that has col_01 value 4.

d. All the above.

Q5) Write the code to do what has been specified in the comments.

Note: Table 01 shows the table user_account in the database:

Table 01: user_account Table

uid username email password
Int(PK, AI) Varchar(20) varchar(255), Unique varchar(20)

$db_host = "127.0.0.1";

$db_user = "pma";

$db_password = " ";

$db_name = "Library";

$conn = mysqli_connect($db_host, $db_user, $db_password, $db_name);

if(!$conn) {

echo "Debugging errno: " . mysqli_connect_errno();

echo " ";

echo "Debugging error: " . mysqli_connect_error();

exit;

}

$u_id = $_POST['uid'];

//write the query here.

$result = mysqli_query($con, $query);

if($result){

//check if there is a result:

// if there is a result, write a code to dp display the result in a table.

// if there is no result, print: No result has been found. Using proper HTML. } else { //print the following an error has occurred. Using proper HTML.

} else {

//print the following an error has occurred. Using proper HTML.

}

mysqli_close($conn);

?>

Q6) Discuss Session Management.

a. What is it?

b. How to create sessions.

c. How to store data and retrieve data from sessions.

Q7) Discuss Security in terms of:

1. Database safety.

2. User safety.

3. Types of attacks

Q8) When we validate a form, which is better to use JS or PHP? Explain?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

Students also viewed these Databases questions

Question

=+40-2 Discuss how social networking influences us.

Answered: 1 week ago