Below is a simple HTML code.
Code: Select all
<html>
<body>
<p>Share your story of alien abduction:</p>
<form method="post" action="report.php">
<label for="firstname">First name:</label>
<input type="text" id="first_name" name="first_name" /><br />
<label for="lastname">Last name:</label>
<input type="text" id="last_name" name="last_name" /><br />
<label for="email">What is your email address?</label>
<input type="text" id="email" name="email" /><br />
<label for="whenithappened">When did it happen?</label>
<input type="text" id="when_it_happened" name="when_it_happened" /><br />
<label for="howlong">How long were you gone?</label>
<input type="text" id="how_long" name="how_long" /><br />
<label for="howmany">How many did you see?</label>
<input type="text" id="how_many" name="how_many" /><br />
<label for="aliendescription">Describe them:</label>
<input type="text" id="alien_description" name="alien_description" size="32" /><br />
<label for="whattheydid">What did they do to you?</label>
<input type="text" id="what_they_did" name="what_they_did" size="32" /><br />
<label for="fangspotted">Have you seen my dog Fang?</label>
Yes <input id="fang_spotted" name="fang_spotted" type="radio" value="yes" />
No <input id="fang_spotted" name="fang_spotted" type="radio" value="no" /><br />
<img src="fang.jpg" width="100" height="175"
alt="My abducted dog Fang." /><br />
<label for="other">Anything else you want to add?</label>
<textarea id="other" name="other"></textarea><br />
<input type="submit" value="Report Abduction" name="submit" />
</form>
</body>
</html>
Below is the PHP code which is called on submittion.
<html>
<head>
<title>Aliens Abducted Me - Report an Abduction</title>
</head>
<body>
<h2>Aliens Abducted Me - Report an Abduction</h2>
<?php
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['howlong'];
$alien_description = $_POST['description'];
$fang_spotted = $_POST['fangspotted'];
$email = $_POST['email'];
echo 'Hello Mr.' . $first_name . ' ' . $last_name . 'Thanks for submitting the form.<br />';
echo 'You say that you were abducted on ' . $when_it_happened . '<br />';
echo 'and were gone for ' . $how_long . '<br />';
echo 'There were ' . $how_many . 'aliens who looked like ' . $alien_description . '<br />';
echo 'who tried to ' . $what_they_did . 'you';
echo 'Was Fang there?' . $fang_spotted . '<br />';
echo 'You also say that:' . $other . '<br />';
echo 'Your email address is: ' . $email;
?>
</html>First name: Saumya
Last name: Purkayastha
What is your email address? smartguy1616@yahoo.co.in
When did it happen? Tuesday
How long were you gone? 3 days
How many did you see? 5
Describe them: ugly and horrible
What did they do to you? kiss and hug
Have you seen my dog Fang? No
Anything else you want to add? It was a mixed experience.
Ideally the result on submitting should be as below as I am expecting:-
Aliens Abducted Me - Report an Abduction
Hello Mr. Saumya Purkayastha. Thanks for submitting the form.
You say that you were abducted on Tuesday
and were gone for 3 days
There were 5 aliens who looked like ugly and horrible
who tried to kiss and hug you.
Was Fang there? no
You also say that: It was a mixed experience.
Your email address is: smartguy1616@yahoo.co.in
Aliens Abducted Me - Report an Abduction
Hello Mr. Thanks for submitting the form.
You say that you were abducted on
and were gone for
There were aliens who looked like
who tried to you.
Was Fang there?
You also say that:
Your email address is: smartguy1616@yahoo.co.in
Please let me know how to get the expected results. What modifications do I have to do in the code?