Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can anyone help with this web programming assignment!? ========== PyInfo.htm =========== Topics Input Output Form tag String Concatenation Multiple Line String Multiple Line String with

can anyone help with this web programming assignment!?

========== PyInfo.htm ===========

Topics

Input

Output

Form tag

String Concatenation

Multiple Line String

Multiple Line String with format method

Description

Create a script that will input the user data including first name, last name, email and phone. It will then display back to the user the data entered by the user. It will display the data three times using the following three methods:

Using individual print statement

Using string concatenation

Using multiple line string with format methoe

For code example, see Sample Code section.

For input/output test data, see Testing section.

Implementation

Create a python file start.py that will display the form. Create a python file info.py that will process the form input and display the values back to the user.

Sample Code

Displaying Form for User Input

python file: start.py

In python, a form can be displayed using an html form tag with a multiple line print as shown below:

print ('''

"info.php">

First Name "text" name="fname" />

Last Name "text" name="lname" />

Email "text" name="email" />

Phone "text" name="phone" />

"submit" name="submit" value="Submit" />

''')

Extracting Input Values

python Script: info.py

The sample code below shows how the first name and last name entered by the user are extracted and stored into variables fname and lname.

import cgi

f = cgi.FieldStorage ( )

fname = f.getvalue ("fname", default="" )

lname = f.getvalue ("lname", default="" )

Printing using individual prints

print ("First Name: ")

print (fname)

print ("
")

print ("Last Name: ")

print (lname)

print ("
")

Printing using string concatenation

out = "First Name: " + fname + " "

out = out + "Last Name: " + lname + " "

print (out)

Printing using multiple line string with format method

out = '''

First Name: { }

Last Name: { }

'''.format (fname, lname)

print (out)

Test Date

Input (user input in bold)

First Name John Last Name Doe Email jdoe@m.net Phone 555-1212

Output (It should appear as below)

Using Individual Prints:

First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212 Using String Concatenation:

First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212

Using Multiple Line String with Format Method:

First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212

====== info.htm=========

Topics

Input

Output

Form tag

Individual Prints

String Concatenation

String Interpolation

Multiple Line Print

Description

Create a php script that will input the users first name, last name, email and phone. It will then display the data entered by the user. It will display the user data four times using the following four different methods.

1. Individual Prints

2. String Concatenation

3. String Interpolation

4. Multiple Line Print

See Picture section for input/output example.

See Sample Code section for code example.

Implementation

Create an html file info.html that will display the form. Create a php file info.php that will process the form input and display the output.

Sample Code

Displaying Form for User Input

/*

html file: info.html

A form can be displayed using an html form tag.

The sample html below shows a form tag that displays a form inputting first name, last name etc.

*/

"info.php">

First Name "text" name="fname" />

Last Name "text" name="lname" />

Email "text" name="email" />

Phone "text" name="phone" />

"submit" name="submit" value="Submit" />

Extracting Input Values in PHP

/*

php Script: info.php

The sample code below shows how the first name and last name entered by the user are extracted from the super global array $_REQUEST and stored into variable $fname and $lname.

*/

$fname=$_REQUEST ['fname'];

$lname=$_REQUEST ['lname'];

Printing Multi-line String in PHP in Four Different Ways

/*

php Script: info.php

The sample code below shows how the first name and last name extracted above can be displayed in four different ways,.

*/

/Individual Prints

print "First Name: ";

print $fname;

print "
";

print "Last Name: ";

print $lname;

print "
";

//String Concatenation

print "First Name: " . $fname . " ";

print "Last Name: " . $lname . " ";

//String Interpolation

print "First Name: $fname ";

print "Last Name: $lname ";

//Multiple Line Print

print <<< Here

First Name: $fname

Last Name: $lname

Here;

Picture

Input

First Name Last Name Email Phone

Output

Using Individual Prints: First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212 Using String Concatenation: First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212 Using String Interpolation: First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212 Using Multiple Line Print First Name: John Last Name: Doe Email: jdoe@m.net Phone: 555-1212

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

Step: 3

blur-text-image

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

How are polymers classified on the basis of structure?

Answered: 1 week ago

Question

Question What is the advantage of a voluntary DBO plan?

Answered: 1 week ago