Main
 New Members

 E-mail
 FTP
 SSH
 SSL
 Herr. of Design

 To ask for aid

 

Processing a form with PHP.
Part 1
By: Falcon.

This is first of a series of lessons that Large city Internet will make its available with the intention to help him to learn to make basic tasks in the programming language PHP.

PHP is a hypertext preprocessor that, unlike, for example, Javascript, works in the servant. This means that the servant will process the code PHP that you have in his documents before sending it to the explorer of the visitor. The visitor does not see code PHP, only sees simple HTML.

This series of lessons is not only for advanced users, nevertheless, we are whereas clause that you feel comfortable with the following thing:
- Basic use of HTML.
- Use of the note publisher to program.
- Language slightly technician.
The advanced users will find this series of a little slow lessons, this is because I will try to put it of the way but easy to include possible the nonexpert users.

We go and to begin with the common task but of all and the one that, sometimes, gives to majors headaches us: To process a form Web in such a way that it sends an e-mail to us.

A basic form

We are going to suppose that it has in its website a called document HTML contactenos.html that contains a basic form:

<form method= " POST? action= " enviar_email.php " >
Name: <br><input type= " text? name= " name " ><br>
E-mail: <br><input type= " text? name= " email " ><br>
Message: <br><textarea name= " message " ></textarea><br>
<input type= " submit? value= " to send " >
</form>

This us daria a form similar to the following one:

Name:

E-mail:

Message:

Those with principles of arthritis in the fingers of as much programming HTML and understand each one of the elements of a form, can go directly to the second part.
If you this in this case do not recommend much to him that continues:

In the code that appears above there are several things that I stood out intentionally. We are going to detach them:

method= " POST? action= " enviar_email.php?
This is the method and the action. Each form must have a method to send the data. The most common methods are: GET and POST.
To explain as it works each exceeds the objective of this lesson, but we are going to mention that when we used a form, he is more common and recommendable to use the method POST since is but safe.
In the same way each form must have an action, this is; something that to do. In this case we are going to create a file that is going away to call enviar_email.php that is going to contain the code PHP that is going to us to send the mail.

NOTE: A document must have the extension .php so that the account servant “? of which in the same there is code PHP that is needed to process.
For example: documento.php

name= " name?
This is one of the important parts but. Each one of the fields in a form must have a name. This one is going away to turn into the name of the variable that is going to contain what the visitor has put in this field.

You already began with rare palabritas?

Then if. The variables are the used term but in practically any programming language. I am going to try to explain it with an example:

In the example of above the visitor it is going to fill the field “names? with his own name, for example: Juan Perez.
As we know, each person has her own name, of another way all voltearia world when calling to somebody, so we can hope that each visitor is going to fill this field with a different name. Then, as the content of this field never goes to be fixed, but she is going to vary, we can say that the field “names? is variable.

In colloquial language this expresaria thus:

name = Juan Perez

That is to say: the variable “names? has the value “Juan Perez?.

In PHP the way to define the previous thing changes a little, but this we are going it to see in:

Part 2: We begin to program! -->
Part 3: The last details -->

   

Web Hosting | Packages | Frequent questions | Contact to us | Terms and Conditions | It orders Now