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

Create an XHTML form that collects a name, address, phone number, and zip code.

ID: 3557295 • Letter: C

Question

Create an XHTML form that collects a name, address, phone number, and zip code. The phone number must be input in the format of ddd-ddd-dddd and the zip code must be in the format of ddddd-dddd. Write a PHP script that checks the submitted information and verifies the format of the phone number and zip code. If the information correctly matches the format, display the information contained in the submitted form. If the data does not match the required format, return an error message exampling the format problem.

Explanation / Answer

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML-XForms 1.0//EN"
"http://www.w3.org/TR/xhtml-forms1/DTD/xhtml-xforms1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Purchase Order</title>   

<xform xmlns="http://www.w3.org/2000/xforms"
action="http://www.my.com/cgi-bin/receiver.pl"
method="postXML"
id="po_xform">
<model>
<group name="purchaseOrder">
<group name="shipTo">
<string name="name"/>
<string name="street"/>
<string name="city"/>
<string name="state"/>
<string name="zip">
<mask>ddddd</mask>
</string>
</group>
</group>
</model>
<instance>
<purchaseOrder>
<shipTo>
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<state>CA</state>
<zip>90952</zip>
</shipTo>
</purchaseOrder>
</instance>
</xform>
</head>

<body>
<h1>Shipping Information</h1>

<form name="po_xform">

Name: <input name="purchaseOrder.shipTo.name"/><br/>
Street: <input name="purchaseOrder.shipTo.street"/><br/>
City: <input name="purchaseOrder.shipTo.city"/><br/>
State: <input name="purchaseOrder.shipTo.state"/><br/>
Zip: <input name="purchaseOrder.shipTo.zip"/><br/>

<button>Submit</button>

</form>
</body>
</html>

<html>
<head> ...</head>
<body>
<form action="error.php" method="post">
<table>
<tr>
<td>Your name:</td>
<td><input type="text" name="your_name"></td>
</tr>
<tr>
<td>Your phone:</td>
<td><input type="text" name="your_phone"></td>
</tr>
<tr>
<td>Zip code:</td>
<td><input type="text" name="your_zip"></td>
</tr>
</table><br>
<input type="submit">
</form>
</body>
</html>

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