Question

I am trying to make a contact form to give input on another browser window. I...

I am trying to make a contact form to give input on another browser window. I am only getting the php code. I am trying to figure out why it won't post. Her is my html and php files:

<!DOCTYPE html>
<html>
<head>
<title>Contact</title>
<link rel="stylesheet" href="main.css">

</head>
<body>
  
<h1>Contact Form</h1>
<nav>
<ul>

<li><a href="index.html">Home</a></li>
<li><a href="page2.html">My PodCast</a></li>
<li><a href="page3.html">Contact Me</a></li>
<li><a href="page4.html">Resources</a></li>
<li><a href="addressbook.html">Address Book</a></li>
<li>Contact Form</li>
</ul>
</nav>

<center><h2>Please fill out form</h2>
<div id='container'>
<div id='header'></div>
<center><h3>Contact</h3>
<form name="contact" method="post" action="contact.php">

<table width="450px">

<tr>

<td valign="top">

<label for="first_name">First Name *</label>

</td>

<td valign="top">

<input type="text" name="first_name" maxlength="50" size="30">

</td>

</tr>

<tr>

<td valign="top">

<label for="last_name">Last Name *</label>

</td>

<td valign="top">

<input type="text" name="last_name" maxlength="50" size="30">

</td>

</tr>

<tr>

<td valign="top">

<label for="email">Email Address *</label>

</td>

<td valign="top">

<input type="text" name="email" maxlength="80" size="30">

</td>

</tr>

<tr>

<td valign="top">

<label for="telephone">Telephone Number</label>

</td>

<td valign="top">

<input type="text" name="telephone" maxlength="30" size="30">

</td>

</tr>

<tr>

<td valign="top">

<label for="comments">Comments *</label>

</td>

<td valign="top">

<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>

</td>

</tr>

<tr>

<td colspan="2" style="text-align:center">

<input type="submit">
</td>

</tr>

</table>

</form>
</center> <div id='footer'></div>
</div>

</body>
</html>

PHP File:

<!DOCTYPE html>
<html>
<body>


<?php
echo "<h2>Your information:</h2>";
echo $_POST["first_name"];
echo "<br>";
echo $_POST["last_name"];
echo "<br>";
echo $_POST["email"];
echo "<br>";
echo $_POST["telephone"];
echo "<br>";
echo $_POST["comments"];
?>
</body>
</html>

Homework Answers

Answer #1

THe form is not getting posted because of the small mistake in the opening of form tag. The HTTP parameters are all case sensitive and will not work with proper case. In the given code the form opened as <form name="contact" method="post" action="contact.php"> and "post" is coded in small case. As per the rule, get and post should be in upper case for working. Therefore the opening tag should include "POST" (post in uppercase).

<form name="contact" method="POST" action="contact.php">

Know the answer?
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
Similar Questions
Java Script I need the code to produce these 3 output. I can only get it...
Java Script I need the code to produce these 3 output. I can only get it to produce input #3 I need it to produce the following: // Input #1: // http://www.example.com // Output // http://www.example.com // Input #2: // http://www.example.com?name=r2d2 // Output // http://www.example.com // name: r2d2 // Input #3: // http://www.example.com?name=r2d2&email=r2d2%40me.com&human=no // Output // http://www.example.com // name: r2d2 // email: [email protected] // human: no THIS IS WHAT I HAVE SO FAR: HTML <!DOCTYPE html> <html lang="en"> <head> <meta...
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>         
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>                   <script src="code.js"></script>   </head>      <body onload="setFocus();">     <div class="container">                                       <div class="main">                                                                                <form action="#" method="post" name="form_name" id="form_id" class="form_class" >                                                                           <h2>--Principal Loan Form--</h2>                                                                                                                                                      <h5>Disclaimer: This software by no mean will precisely predict your mortgage through your lender company.  This Software will only assume the four items below in order to make an educated guess or prediction to your exact mortgage interests amount and the duration of your loan from your lender. <img...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if input from user is empty -> get an error string variable if input is not empty -> use preg_match() to match the pattern $pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/"; -> if it's a matched, get a success string variable */           } ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link...
Please linked both files. For this assignment you need to create a ToDo list using Javascript,...
Please linked both files. For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link...
Create an application that will give valuable advice to future students from someone (you!) who is...
Create an application that will give valuable advice to future students from someone (you!) who is close to graduation. However, only end-users who have their credentials validated against the database (which uses encrypted passwords) are allowed entry. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- advice_ddl.sql CREATE DATABASE advice; USE advice; CREATE TABLE users ( id int primary key auto_increment, username varchar(255), password varchar(255) ); -- insert a row into the users table: -- username = foo -- password = bar INSERT INTO users (username, password) VALUES...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>All Pets Veterinary Hospital</title> <style> body { font-family: arial,...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>All Pets Veterinary Hospital</title> <style> body { font-family: arial, sans-serif; font-size: 100%; } /* outer container */    #wrapper { width: 960px; margin: 50px auto; padding: 0px; background-color: rgb(255, 255, 255); /* white */ border: 1px solid #000; /* black */ }    header h1 { text-align: center; }    nav { text-align: center; background: rgb(175, 196, 206); }    address figure { text-align: center; } </style> </head> <body> <div id="wrapper"> <!-- outer...