Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,672 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,177 people online right now. Registration is fast and FREE... Join Now!




Using a form created in xhtml with Php

 
Reply to this topicStart new topic

Using a form created in xhtml with Php

dagaydos
post 23 Jul, 2007 - 02:28 PM
Post #1


New D.I.C Head

*
Joined: 13 Apr, 2007
Posts: 7


My Contributions


I am taking an xhtml class. Beginners. The lab I have now is to create a form and see if it works using PHP.
There is nothing in the book about how to use this, just a brief instrucion from the instructior.
The instructions are to create the form and to use FormMail.PhP to see if it works.
Donload the file and save it using the .php
Create four hidden fields, recipient, redirect, subject, and email. Use the post form method.

Here is my form and the PHP file.

What am I doing wrong?


Attached File(s)
Attached File  ddcontact.htm ( 3.36k ) Number of downloads: 33
Attached File  thnks.htm ( 922bytes ) Number of downloads: 37
Attached File  labml.php ( 10.56k ) Number of downloads: 33
User is offlineProfile CardPM

Go to the top of the page

snoj
post 23 Jul, 2007 - 08:02 PM
Post #2


$Null

Group Icon
Joined: 31 Mar, 2003
Posts: 3,304



Thanked 5 times

Dream Kudos: 700
My Contributions


Well there's a number of things you could be doing wrong. However since you're not telling us what is going wrong, I nor anyone else can help you.
User is offlineProfile CardPM

Go to the top of the page

spullen
post 3 Aug, 2007 - 07:13 PM
Post #3


D.I.C Regular

Group Icon
Joined: 22 Mar, 2007
Posts: 330



Dream Kudos: 50
My Contributions


Ok so processing forms is simple in php:
say you have the form:
CODE

<form action="check.php" method="post" >
       <label>Enter Some Text:</label>
       <input type="text" name="some_text" /><br />
       <input type="submit" value="Process" />
</form>


Couple of things to take note here, action is where the information is going to be sent, and what action will be done, and method is how that information will be transfered, in this case it is post, and we will use the $_POST global array, and finally name in the input field is the value of the data that is going to get passed in the $_POST array.
So now that we have a form let's create some php to process that form. So when you hit the submit button it will go to check.php which is a file, and here is a simple thing you can do.
CODE

<?php
    $text_info = $_POST['some_text'];
    print $text_info;
?>

This little bit of code should print out whatever you put into your text field on the form. Notice how the name of the text field was the reference in the $_POST array. Also another handy function to know about when working with forms (and arrays in general) is the print_r() function, this takes in an array and prints out the contents of the array. I say this is useful because sometimes you can have big forms and you might mistype something, so it helps figuring that stuff out. So if you put that in the code:
CODE

<?php
    print_r($_POST);
    $text_info = $_POST['some_text'];
    print $text_info;
?>

It should print out the contents of $_POST, also to get a better look at what print_r does you can view the page source, and it will be formatted better.
Hope this helps.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:13AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month