Question

You have been given the file exercise-2.php. This file contains a HTML form with various inputs. Your task is to echo out the

PHP code that is given :

<?php
// Here is where your preprocessing code goes

// An example is already given to you for the First Name

$fname = $_GET['fname'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Exercise 2 - GET Echo</title>
<style>
body {
margin:0;
padding:0;
font-family: Arial;
}

form {
margin:20px;
}

input[type="text"], input[type="password"] {
width:150px;
padding:3px;
font-size:1em;
}

input[type="submit"] {
padding:3px;
font-size:1em;
}

label {
display:inline-block;
width:150px;
}

.input-container {
padding:5px;
}

</style>
</head>
<body>
<form action="task1.php" method="GET">
<p><strong>Echo Form:</strong></p>
<div class="input-container">
<label for="fname">First Name</label>
<input type="text" name="fname" value="" placeholder="First Name" id="fname">
</div>
<div class="input-container">
<label for="lname">Last Name</label>
<input type="text" name="lname" value="" placeholder="Last Name" id="lname">
</div>
<div class="input-container">
<label for="email">Email Address</label>
<input type="text" name="email" value="" placeholder="Email" id="email">
</div>
<div class="input-container">
<label for="password">Password</label>
<input type="text" name="password" value="" placeholder="Password" id="Password">
</div>
<div class="input-container">
<input type="submit" value="Echo Values"/>
</div>
</form>
<section>
<h1>Echoed <code>GET</code> Values<h1>
<p><strong>First Name:</strong> <?php echo $fname; ?></p>
<?php
// This is where you echo your values
?>
</section>
</body>
</html>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Exercise 2 - GET Echo</title>
<style>
body {
margin:0;
padding:0;
font-family: Arial;
}

form {
margin:20px;
}

input[type="text"], input[type="password"] {
width:150px;
padding:3px;
font-size:1em;
}

input[type="submit"] {
padding:3px;
font-size:1em;
}

label {
display:inline-block;
width:150px;
}

.input-container {
padding:5px;
}

</style>
</head>
<body>
<form action="" method="GET">
<p><strong>Echo Form:</strong></p>
<div class="input-container">
<label for="fname">First Name</label>
<input type="text" name="fname" value="" placeholder="First Name" id="fname">
</div>
<div class="input-container">
<label for="lname">Last Name</label>
<input type="text" name="lname" value="" placeholder="Last Name" id="lname">
</div>
<div class="input-container">
<label for="email">Email Address</label>
<input type="text" name="email" value="" placeholder="Email" id="email">
</div>
<div class="input-container">
<label for="password">Password</label>
<input type="text" name="password" value="" placeholder="Password" id="Password">
</div>
<div class="input-container">
<input type="submit" name="submit" value="Echo Values"/>
</div>
</form>
<section>
<h1>Echoed <code>GET</code> Values<h1>

<?php
   if(isset($_GET["submit"]))
   {
       $fname=$_GET["fname"];
       $lname=$_GET["lname"];
       $email=$_GET["email"];
       $pass=$_GET["password"];
       $password="";
       for($i=0;$i<strlen($pass);$i++)
           $password=$password."#";
       echo "<p><strong>First Name:</strong>".$lname. "</p>";
       echo "<p><strong>Last Name:</strong> ".$fname. "</p>";
       echo "<p><strong>Email:</strong> ".$email."</p>";
       echo "<p><strong>Password:</strong> ". $password."</p>";
   }
  
?>
</section>
</body>
</html>

outputsC Computer Science question Che X 63 Exercise 2 - GET Echo x + - O X E → C localhost/jay/exersice-2.php Echo Form: First Name

when you click on the button =C Computer Science question Che X 23 Exercise 2 - GET Echo X + - O X f → C localhost/jay/exersice-2.php?fname=Jay&lname=Joshi

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
PHP code that is given : <?php // Here is where your preprocessing code goes //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this code below, I need to add the form information to mysql when I click...

    For this code below, I need to add the form information to mysql when I click on submit, at the same time when I click on submit I need to move to another page like Welcome.php WITH NOTE THAT THE ENTERED INFORMATION NOW ALREADY IN DATABASE how can I male that with my code below? THANKS ................................................................................................................................................   <form method="POST"> <div class="container">    <label for="fname"><b>First Name</b></label> <input type="text" placeholder="Enter First Name" name="fname" required> <label for="lname"><b>Last Name</b></label> <input type="text" placeholder="Enter Last Name"...

  • How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow...

    How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit. <form action="" method="post"> <label>Name :</label> <input type="text" name="name" required="required" placeholder="Please Enter Name"/><br /><br /> <label>Email :</label> <input type="email" name="email" required="required" /><br/><br /> <input type="submit" value=" Submit " name="submit"/><br /> </form>...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

  • HTML Coding <html> <head> <title> Contact -- Charles Robertson </title> </head> <body bgcolor="white"> <table width="700" height="500"...

    HTML Coding <html> <head> <title> Contact -- Charles Robertson </title> </head> <body bgcolor="white"> <table width="700" height="500" border="10"> <!-----row---1----logo---> <tr><td> <img src="20150516_084745" width="700" height="200"> </td></tr> <!-----row-2-navigation-----> <tr><td> <!----start-navigation-table----> <table width="700" height="100" border="5" bgcolor="lightgreen" > <tr><td><a href="HerbFarm.html"> <center> HOME </center></a></td> <td><a href="about3.html"> <center> ABOUT </center></a></td> <td><a href="contact3.html"> <center> CONTACT </center></a></td> <td><a href="gallery3.html"> <center> GALLERY </center></a></td> </tr> </table> <!------end-navigation-table----> </td></tr> <tr><td> <h1>Contact </h1> <form action="thankyou.html">    </form> <div class="row"> <div class="col-75"> <div class="container"> <form action="/action_page.php"> <div class="row"> <div class="col-50"> <h3>Billing Address</h3> <label for="fname"><i...

  • Hey Guys I am doing a project and need some help with code in HTML and...

    Hey Guys I am doing a project and need some help with code in HTML and PHP. I need a form made in HTML that can be sent to a specific email through PHP. For some reason the info is not getting sent to my email, even though it says that it was sent. I have some source code here: <?php if(isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $email = mail('MY_EMAIL', $subject, $message,...

  • <html>     <head>       <title>Sign Up page</title>   <form name="validationForm" method="post" onsubmit="return checkvalidation()">      &n

    <html>     <head>       <title>Sign Up page</title>   <form name="validationForm" method="post" onsubmit="return checkvalidation()">         <!--div class-->       <div class="formvalidation">       <label>Your first Name</label>        <span id="showname"></span>        <!--label for firstname-->       <input type="text" name="firstname" class="formsignup"  id ="firstn" placeholder="Enter your Name">      <br><br>           <!--lastname-->       <label>Your last Name</label> <span id="showlname"></span>       <input type="text" name="lastname" class="formsignup" id="lastn" placeholder="Enter your last Name">       <br><br>        <!--email-->         <label>Your Email</label>          <span id="showemail"></span>         <input type="email" name="emailid" class="formsignup" size="45" id="emailn" placeholder="Enter your Email">        <br><br> <input type="submit" value="send">     </div>           </form> <script>      function checkvalidation(){     var name = document.forms["validationForm"]["firstname"].value;     var lname...

  • Modify this code to store the form elements as variables and display them on the page...

    Modify this code to store the form elements as variables and display them on the page in an HTML table. <!DOCTYPE html> <html> <head> <script> function getValues() {     var result = ""; result += "First Name: " + document.forms["myForm"]["fname"].value + "<br>"; result += "Last Name: " + document.forms["myForm"]["lname"].value + "<br>"; result += "Address: " + document.forms["myForm"]["address"].value + "<br>"; result += "City: " + document.forms["myForm"]["city"].value + "<br>"; result += "State: " + document.forms["myForm"]["state"].value + "<br>"; document.getElementById("output").innerHTML = result; } </script>...

  • URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to...

    URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to download the uncompressed latest version of jQuery Copy the jQuery.x.x.x.js file in the folder and specified as source file. Task 2: Download and install HTML-Kit 1. Navigate to htmlkit.com. 2. Click Download HTML-Kit 292. After it downloads, launch HKSetup.exe. Choose Full installation (the default) Uncheck Yes, download and install HTML-Kit Tools Trial. 6. Click Next>Finish. Task 3: Creating a Simple jQuery Application Launch HTML-Kit....

  • PHP - Use of classes This is a further development of the previous task, the participant...

    PHP - Use of classes This is a further development of the previous task, the participant registration. You must use the following Participant class. <?php class Deltaker { private $etterNavn; private $forNavn; private $fAar; function __construct(string $fornavn, string $etternavn, string $aar) { $this->forNavn = $fornavn; $this->etterNavn = $etternavn; $this->fAar = $aar; } function hentEtterNavn() : string { return $this->etterNavn; } function hentForNavn() : string { return $this->forNavn; } function hentFAar() : string{ return $this->fAar; } //Setters function settForNavn(string $fornavn) {...

  • Hello! I am to create a .js file that allows the paragraph on the bottom of...

    Hello! I am to create a .js file that allows the paragraph on the bottom of the page to update with what the user enters. I need to modify the given HTML to recognize the javascript file that I am to make from scratch. The HTML file and other details are below: Use the given HTML to add functionality to an interactive form that generates an invitation to volunteers for an event. The file will have the following invitation message...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT