FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Php form.





cr3ativ3
I was playin with some php I was making a simple php form that when filled out sends you to the next page and says what you filled in but it only does half of the process. Could someone please help me.

This is the code for me html form.
form.html
Code:
<HTML>
<HEAD>
<TITLE>HTML Form</TITLE>
</HEAD>
<BODY>
<FORM ACTION="HandleForm.php" METHOD=POST>

First Name <INPUT TYPE=TEXT
NAME="FirstName" SIZE=20><BR>

Last Name <INPUT TYPE=TEXT
NAME="LastName" SIZE=40><BR>

E-mail Address <INPUT TYPE=TEXT
NAME="Email" SIZE=60><BR>

Comments <TEXTAREA NAME="Comments"
ROWS=5 COLS=40></TEXTAREA><BR>

<INPUT TYPE=SUBMIT NAME="SUBMIT"
VALUE="Submit!">
</FORM>
</BODY>
</HTML>


This is the php file that reseves the info and lays it out for the person to see what they wrote:
HandleForm.php
Code:
<HTML>
<HEAD>
<TITLE>Form Results</TITLE>
<BODY>
<?php
/*
This page receives and handles the data generated by "form.html".
*/
print "Your first name is
   $FirstName.<BR>\n";
print "Your last name is
   $LastName.<BR>\n";
print "Your E-mail address is
   $Email.<BR>\n";
print "This is what you had to
   say: <BR>\n $Comments<BR>\n";
?>
</BODY>
</HTML>


If anyone could please figure the problem out I would be very appreciative. Here is the url to the file if you would like to try it out your self: http://www.cr3ative.frih.net/form.html

Thanks for any help you can provide.
rfwrangler
cr3ativ3 wrote:
I was playin with some php I was making a simple php form that when filled out sends you to the next page and says what you filled in but it only does half of the process. Could someone please help me.

This is the code for me html form.
form.html
Code:
<HTML>
<HEAD>
<TITLE>HTML Form</TITLE>
</HEAD>
<BODY>
<FORM ACTION="HandleForm.php" METHOD=POST>

First Name <INPUT TYPE=TEXT
NAME="FirstName" SIZE=20><BR>

Last Name <INPUT TYPE=TEXT
NAME="LastName" SIZE=40><BR>

E-mail Address <INPUT TYPE=TEXT
NAME="Email" SIZE=60><BR>

Comments <TEXTAREA NAME="Comments"
ROWS=5 COLS=40></TEXTAREA><BR>

<INPUT TYPE=SUBMIT NAME="SUBMIT"
VALUE="Submit!">
</FORM>
</BODY>
</HTML>


This is the php file that reseves the info and lays it out for the person to see what they wrote:
HandleForm.php
Code:
<HTML>
<HEAD>
<TITLE>Form Results</TITLE>
<BODY>
<?php
/*
This page receives and handles the data generated by "form.html".
*/
print "Your first name is
   $FirstName.<BR>\n";
print "Your last name is
   $LastName.<BR>\n";
print "Your E-mail address is
   $Email.<BR>\n";
print "This is what you had to
   say: <BR>\n $Comments<BR>\n";
?>
</BODY>
</HTML>


If anyone could please figure the problem out I would be very appreciative. Here is the url to the file if you would like to try it out your self: http://www.cr3ative.frih.net/form.html

Thanks for any help you can provide.


You need to access the data from the form using the $_POST array.
the lines that you need are as follows:

$FirstName=$_POST['FirstName'];
$LastName=$_POST['LastName'];
$Email=$_POST['Email'];
$Comments=$_POST['Comments'];

Put that code in the begining of you HandleForm.php file and you should be able to see the results.
cr3ativ3
Ok, Thanks you so much I don't know why this wasn't in my php book I borrowed from the library. I am glad there are people on this forum like you who can help.

Thanks again.
mathiaus
I suggest learning via the web. Not only is it usually more up to date but anything missing from one tutorial is likely found in another.

Solved
-close-
Related topics
Uplaoding images using php form :::: Help needed
PHP Form Question
800$ frih for grab, php form small correction - urgent
Form handling in php is a pain in the neck
Anyone care to help me with a simple PHP Form ?
PHP Form Sending problem
200F$ for a php form.
I need a complex php/flash form... 250FRIH$
anyone know of a good php form processer script
My php Form tutorial
Html Forms help please?
cannot add data to mysql from PHP form
PHP Form Processing Problem
Help with php email
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.