Jump to content

Handling an HTML form


sahlahmin

Recommended Posts

Not sure why the PHP variables in the code below aren't interpreting the values that they should be receiving from the HTML form.

 

HTML form

<form action="handle_form.php" method="post">

<fieldset><legend>Enter your information in the form below</legend>

<p><b>Name:</b> <input type="text" name="name" size="20" maxlength="40" /></p>
<p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="60" /></p>
<p><b>Gender:</b> <input type="radio" name="gender" value="M" /> Male <input type="radio" name="gender" value="F" /> Female</p>

<p><b>Age:</b>

<select name="age">
<option value="0-29">Under 30</option>
    <option value="30-60">Between 30 and 60</option>
    <option value="60+">Over 60</option>
</select>
</p>

<p><b>Comments:</b> <textarea name="comments" rows="3" cols="40"></textarea></p>
</fieldset>

<div align="center"><input type="submit" name="submit" value="Sumbit My Information"  /></div>
</form>

 

PHP handle_form

<?php #Script 2.2 handle_form.php

$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$comments = $_REQUEST['comments'];

echo "<p>Thank you, <b>$name</b>,
for the following comments:<br />
<tt>$comments</tt></p>
<p> We will reply to you at <i>$email</i>.</p>";

?>

 

:confused:

Link to comment
Share on other sites

The concatenated code is functionally no different from what is posted in the OP. Concatenating it like that is pointless.

 

If the code posted in the OP directly copied/pasted from the script? If so, make a new file, and put the following in it, pick a name and save it, then call it into your browser.

<?php
phpinfo();
?>

 

If it isn't a direct copy, please copy/paste the actual the code here.

Link to comment
Share on other sites

kenrbnson, I think this is the line your talking about...

 

<form action="handle_form.php" method="post">

 

its the only line in either document that links the two scripts together, other then them being in the same folder.

 

phpfreaks, I tried $_POST, same results :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.