confused about forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gammaman
Forum Commoner
Posts: 45
Joined: Tue Feb 12, 2008 9:22 am

confused about forms

Post by gammaman »

I have the following code, but when I click submit, I am confused as to where the information is being sent, and how I go about getting it to display it.

Code: Select all

 
<html>
<body>
<FORM action="E:\Senior Project\comment.html" method="post">
 
First Name:
<input type ="text" name="firstname"/>
&nbsp
Last Name:
<input type ="text" name="lastname"/>
<br/>
<br/><dd/>
Comments orSuggestions:
<br/><dd/>
<textarea name="comment" rows="10" cols="50"></textarea>
</textarea>
<input type = "submit" value="submit">
</form>
 
<?php
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$comment=$_POST['comment'];
 
echo $firstname.'&nbsp;'.$lastname.':'.'&nbsp'.$comment;
?>
</body>
</html>
 
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: confused about forms

Post by RobertGonzalez »

Right now your form is being sent to E:\Senior Project\comment.html. That file, unless your server is setup to parse HTML files as server side code files, will not do anything at all for you.
gammaman
Forum Commoner
Posts: 45
Joined: Tue Feb 12, 2008 9:22 am

Re: confused about forms

Post by gammaman »

I need a way for this information to be submitted and then be viewable by the user via a
"view comments link" on that same page where they submitted the data.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: confused about forms

Post by RobertGonzalez »

Then you are going to need a server side program (PHP perhaps? Or even Perl/.NET/ColdFusion/JSP/the list goes on) to receive the posted form data, process it and show it.
Post Reply