Department of computing

profileHelp assigment

SECTION B - Technical Criteria:

You are required to outline the coding for the following with suitable chosen technology:

Designing different html web pages with different elements (min 5 elements)

Answers:

A1. 1. Text headers:

       Text headers are used to set up the size of the fonts, there totally 6 elements are there, and they are denoted as <h1>, <h2>, <h3>...<h6>.

2. Paragraph Tag:

 

 Paragraph tag is used to contain the messages within the body by denoting it as <p>.

3.  Anchor tag:

   Anchor tag has been used to encapsulate a link by denoting <a>.

4. Image tag: 

    Image tag is used to insert the image by using <img>. It is a holding space for the image which has been taken from internet.

5. Divider tag:

     It is used to divide the section in html document, it contains all the elements of the document. 

Example: 

<! DOCTYPE html>

  <html> 

   <body>

 <div class = “Webpage 1”> 

<h1> Hello every one </h1>

<p> This is the Online shopping website, hope you all enjoy the products</p>

</div>

<div class = “webpage 2”>

<img src = “img.alnoor1.jpg” alt=”Black tunics” width=”500” height=”600”>

<h2> Click here to purchase </h2>

<a href= https://alnoor.com> Order now</a>

</div>

</body></html>

A2. 

1. Span tag :

             It is used to color a certain part of the text in a paragraph. <span>

2. Navigation tag :

              It defines the navigation links which is provided of the document , it is denoted by <nav>.

3. iframe tag :

                Iframe tag is inline element which is commonly used to embed another document within a current document. <iframe>

4. label tag :

                 Which is used to assign a value for the input elements. It is denoted by <label>.

5. Meta tag :

                  It defines the data about data of the html document it is denoted by <meta> 

Example :

<! DOCTYPE html>

  <html> 

   <meta name=”viewport” content=”width=device-width, initialscale=1”>

   <body>

    <div class = “Webpage 1”>

<h1> Hello every one </h1>

<iframe src =https://alnoorwebsite.com” title=”alnoor shoppings”>

</iframe>

<p> This is the Alnoor  Online shopping website <span style =”color:red”>Alnoor</span> hope you all enjoy the products</p>

</div>

<div class = “webpage 2”>

<img src = “img.alnoor1.jpg” alt=”Black tunics” width=”500” height=”600”>

<form action =”/action-page.php”>

<label for = “color”> What’s your choice;</label>

<input type= “colors” id=”color” name=”color” value=”#000000”><br>

<input type = “Buy now”>

</form>

 <h2> Click here to purchase </h2><a href= https://alnoor.com> Order now</a>

</div>

</body></html>

B. Usage of CSS (min 2 elements):

CSS – Cascading style sheets which is used to display the contents of the html document in a more proper manner.

The elements of html can be styled by using css 

There are many elements in css out of them the most commonly used elements are,

Inline css. – to apply a style to elements individually.

Internal css- to apply a style to a html page in a head section using a style elements.

External css- to apply style for different html pages by adding a link in the head section.

Examples:

<! DOCTYPE html>

  <html> 

<head>

<link rel= “stylesheet” type=”text/css” href=”Document.css”>

</head> 

<style>

 < Body >

{

background – color: yellow;

h1 {

color: red

}  

p { 

color: blue

}

    <div class = “Webpage 1”>

<h1> Hello every one </h1>

<p> This is the Online shopping website, hope you all enjoy the products</p>

</div>

<div class = “webpage 2”>

<img src = “img.alnoor1.jpg” alt=”Black tunics” width=”500” height=”600”>

<h2> Click here to purchase </h2>

<h3> What are you searching for?</h3>

<p> Availabilities – Spaghetti, tunics, crop top etc..</p>

<h2 style=”color :pink;”> Go</h2>

<a href= https://alnoor.com> Order now</a>

</div>

</body>

</html>

Document.css

Body {

Background-color : blue”;

}

H1{ margin right: 50px;

      Color : red;

}

3. Usage of JavaScript (min 2 elements):

Adding java scripts to the html documents will make the documents more responsive and dynamic.

Some elements are, 

1.ActiveElement

2.Characterset

3.baseURI

4.getElementById()

5.getElementsByTagname() etc…

Example :

<!DOCTYPE html>

<html>

<body onclick= “myFunction()”>

<h1>Hello Everyone</h1>

<div id=”webpage1”>

<p><img src = “img.alnoor1.jpg” alt=”Black tunics” width=”500” height=”600”>

<p id= “1”></p>

<h2> Click here to purchase </h2>

<input type=”text” value=”An input field”>

<button> Click here to purchase </button>

<p id=”2”></p>

<script>

Function myfunction()

{

Var x= document.activeElement.tagName;document.characterSet;

Document.getElementById(“1”).innerHTML=x;

 Var y = document.baseURI; document.getelementbyId (“1”).innerHtML=y;

}

</script>

</body>

</html>

D. Login Page Using session:

<? Php

Session_start();

$message =””;

If( isset ($_SESSION [‘details’]))

$_SESSION[‘details’]=$_SESSION[‘details’] ;

$_SESSION [user id”]=”1”;

$_SESSION [Name”]=”xxx”;

Else{

$message =”invalid details”;}}

Echo “All set”;

If (isset ($_SESSION[“id”]))

{

Header (“Location:alnoor.php”);

}

?>

<!DOCTYPE html

</html>

</head>

</body>

< form name = “user” method = “post” action=”” align =”left”>

<div class =”credentials”><?php if ($message!=””) 

{echo $message;

}

Username:<br>

<input type="text" name="user_name">

<br>

Password:<br>

<input type="password" name="password">

<br><br>

<input type="submit" name="submit" value="Submit">

<input type="reset">

</form>

</body>

</html>

Alnoor.php

<?php

session_start();

?>

<html>

<head>

<title>User Login</title>

</head>

<body>

<?php

if($_SESSION["name"]) {

?>Welcome <?php echo $_SESSION["name"]; ?>. Click here to <a href="logout.php" tite="Logout">Logout.

<?php

}else echo "<h1>Please login first .</h1>";

?>

</body>

</html>

E. Insert data to database:

After creating a table in mysql we can go to the php codes

Database.php

<?php

$servername='localhost';

$username='root';

$password='';

$dbname = "crud";

$conn=mysqli_connect($servername,$username,$password,"$dbname");

if(!$conn){

die('Could not Connect My Sql:' .mysql_error());

}

?>

Inserting data

<!DOCTYPE html>

<html>

 <body>

​<form method="post" action="process.php">

​​First name:<br>

​​<input type="text" name="first_name">

​​<br>

​​Last name:<br>

​​<input type="text" name="last_name">

​​<br>

​​City name:<br><input type="text" name="city_name">

​​<br>

​​Email Id:<br><input type="email" name="email">

​​<br><br>

​​<input type="submit" name="save" value="submit">

​</form>

 </body>

</html>

f. Delete data in database:

<?php

$servername=”localhost”;

$username=”username”;

$user id=”userid”;

$password =”password”;

$dbname=”database”;

$conn=new mysqli($Servername,$username,$password,$dbname);

If ($conn-Connect-error)

{

Die(“”no connection”.$conn-connect_error);

}

$sql= “DELETE FROM DATA WHERE id=1”;

If {$conn-query($sql)==TRUE)

{

Echo “deleted”;

}

Else

{

Echo “can’t delete”}

$conn-close();

?>

g.Update data in database:

<?php

$servername=”localhost”;

$username=”username”;

$user id=”userid”;

$password =”password”;

$dbname=”database”;

$conn=new mysqli($Servername,$username,$password,$dbname);

If ($conn-Connect-error)

{

Die(“”no connection”.$conn-connect_error);

}

sql = "UPDATE Details SET lastname='y' WHERE id=2";

If {$conn-query($sql)==TRUE)

{

Echo “deleted”;

}

Else

{

Echo “can’t delete”}

$conn-close();

?>

h.View data in database:

<?php

$servername=”localhost”;

$username=”username”;

$user id=”userid”;

$password =”password”;

$dbname=”database”;

$conn=new mysqli($Servername,$username,$password,$dbname);

If ($conn-Connect-error)

{

Die(“”no connection”.$conn-connect_error);

}

$sql = "SELECT id, firstname, lastname FROM details";

If {$conn-query($sql)==TRUE)

{

Echo “deleted”;

}

Else

{

Echo “can’t delete”}

$conn-close();

?>

I. Sorting and searching:

<?php

$servername=”localhost”;

$username=”username”;

$user id=”userid”;

$password =”password”;

$dbname=”database”;

$conn=new mysqli($Servername,$username,$password,$dbname);

Function selection_sort($data)

{

For($i=0;$i<count($data)-1;$i++)

{ $min = $i;

​for($j=$i+1; $j<count($data); $j++) {

​​if ($data[$j]<$data[$min]) {

​​​$min = $j;

​​}

​}

   $data = swap_positions($data, $i, $min);

}

return $data;

}

If ($conn-Connect-error)

{

Die(“”no connection”.$conn-connect_error);

}

If {$conn-query($sql)==TRUE)

{

Echo “deleted”;

}

Else

{

Echo “can’t delete”}

$conn-close();

?>

  • 6 years ago
  • 20
Answer(1)

Purchase the answer to view it

blurred-text
NOT RATED
  • attachment
    WebReport.docx
  • attachment
    SectionBTechnicalCriteriareport.docx