Page 1 of 1

playing with Form

Posted: Mon Jul 04, 2011 12:29 pm
by adeee
Guys am new in PHP and i was just read the book and follow the instruction of 'handling an HTML form'. but unfortunately i cant handle the form.i create two php files.
This is the data from form.php

Code: Select all

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
    <head>
        <title> </title>
        <style type="text/css">
            h1 h2 h3 h4 h5 h6 body p form legend fieldset input select option textarea{
            padding:0px;
            margin:0px;
            }
            .radio1 {
            margin:0px 0px 0px 0px;
            }
            fieldset{
            width:250px;
            }
        </style>
    </head>
<body>
    <form action=”submit.php” method=”post”> 
        <fieldset>
            <legend> Adil</legend>
             <p>Name:
                <input type="text" class="radio1" value="username" name="name" size="20" maxlength="40"  />
             </p>
             <p>Email:
                <input type="text" value="Email id" name="Email" size="20" maxlength="40"/>
             </p>
             <p>Gender:
                Male:<input type="radio" name="radio" value="M" />
                Female:<input type="radio" name="radio" value="F" />
             </p>
             <p>Age:
                <select name="age">
                    <option value="0-29">Under 30</option>
                    <option value="30-50">Under 50</option>
                    <option value="50+">Above 50</option>
                </select>
             </p>
             <p class="pera">Comments:<br/>
                 <textarea row="7" column="30"> </textarea>
             </p>
             <input type="submit" value="submit" />
        </fieldset>
    </form> 

</body>
</html> 
and this is the data from submit.php

Code: Select all

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
    <head>
        <title> </title>
        <style type="text/css">
         
        </style>
    </head>
<body>
<?php
//variables
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$comments = $_REQUEST['comments'];
/* Not used:
 $_REQUEST[‘age’]
 $_REQUEST[‘gender’]
 $_REQUEST[‘submit’]
*/

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

?>
</body>
</html>
Now my Question is, when i fill the form and submit it. it give me this error.
[text]Not Found

The requested URL /php/”submit.php” was not found on this server.

[/text]

and the output url is
[text]http://localhost/php/%C3%A2%E2%82%AC%C2 ... &age=30-50[/text]

can you tell me what just wrong. because i cant figure it out.

Re: playing with Form

Posted: Mon Jul 04, 2011 1:30 pm
by Apollo
adeee wrote:

Code: Select all

<form action=”submit.php” method=”post”>
Did you copy/paste this code from MS Word by any chance?

You're not using normal quote characters here (i.e. single quotes ' or double quotes ") but funky curved quotes. And not just in the <form> tag by the way, your code is full of it. Certain horrible applications (like Word) have the tendency of replacing normal proper quotes with the crappy ones :(

Oh, and that error you're getting is the utf-8 representation (incorrectly displayed in some other encoding) of the wrong quote characters.

Re: playing with Form

Posted: Tue Jul 05, 2011 1:29 am
by adeee
Thank you for your response.
its quote error in <form> tag. i solve it. and its now working. and i use ubuntu linux default gedit text editor.
and sorry to say here is another problem. in php book they show when they fill the form then output like this

Image

in the image Confucius is the name. and the massage in corrier font is the comment. and in last line email they get from the form.
and my output when i fill the form is looks like this.

Image

What is the problem with code. i just change the variabe. name. and string. :banghead:

Re: playing with Form

Posted: Tue Jul 05, 2011 1:59 am
by social_experiment
Apollo wrote:Certain horrible applications (like Word)
Copying from a pdf also does that

Re: playing with Form

Posted: Tue Jul 05, 2011 10:58 am
by McInfo
adeee wrote:What is the problem with code.
The comment is not submitted because the textarea has no name.

The email address is not received because input names are case-sensitive, so name="Email" does not translate to $_REQUEST['email'].

Re: playing with Form

Posted: Tue Jul 05, 2011 11:49 am
by adeee
McInfo wrote:
adeee wrote:What is the problem with code.
The comment is not submitted because the textarea has no name.

The email address is not received because input names are case-sensitive, so name="Email" does not translate to $_REQUEST['email'].
ya problem solves.Thanxs