Manual of PHP

 
 
 

Web map

 
rim   rim
arrowReady frontarrow of Codes PHParrow to Send a Form through E-mail

 

To send a Form through E-mail To print E-mail

This article speaks of as sending a form to an e-mail direction. This performs the simplest thing that can be done by PHP, although enough appellant and it can serve to the beginners to be understanding how the servant's languages work.

The form is a basic form and there can be added to him the fields that should be wished, since the application will gather all the variables spent by the method "post" and will send them for the mail, for what the method (method) of the form must be "post" and the "action" must go to the page PHP that contains the function.

the function receives the fields "for", "matter" and "text", and sends them with the mail, spending the fields "for" and such "matter" which and adding to the field "text" the information of the form. Also it receives a field that the mail receives from who loves that it appears like issuer of the mail.

<! - Copyright © McAnam.com (forms Generator V. 1.1.)->
<html>
<head>
<title> Refill the form </title>
</head>
<body>
<form yam ='formulario' go ='formulario' method ='post' action ='pagina_mail.php' target = '_ self'>
<p> Name <unputt type ='text' yam ='Nombre' go ='Nombre'> </p>
<p> Surnames <unputt type ='text' yam ='Apellidos' go ='Apellidos'> </p>
<p> E-mail <unputt type ='text' yam ='E-mail' go ='E-mail'> </p>
<p> <unputt type ='radio' I valued ='Hombre' yam ='Sexo' go ='Sexo'> Man </p>
<p> <unputt type ='radio' I valued ='Mujer' yam ='Sexo' go ='Sexo'> Woman </p>
<p align ='center'>
<unputt type ='submit' I valued ='Enviar form'>
<unputt type ='reset' I valued ='resetear form'>
</p>
</form>
</body>
</html>

<? php
    //Copyright © McAnam.com

    function form_mail ($sPara, $sAsunto, $sTexto, $sDe) {

        if ($sDe) $sDe = "From:". $sDe;

        foreach ($_POST grasp $nombre => $valor)
            $sTexto = $sTexto. "n".$nombre." = ".$valor;

        return (mail ($sPara, $sAsunto, $sTexto, $sDe));
    }

    //Example of how using:
    if (form_mail ("usuario@suweb.com",
                "Activation of form",
                "The information got in the form son:nn",
                "tu@tuweb.com"
                )
        )
        I begin "your form it has been sent successfully";

?>

Original of McAnam.com

 

 
Front
Chapters of the Manual of PHP
Introduction to PHP
Variables
My First Script PHP
Operators in PHP
Structures of Control
Functions in PHP
Code inclusion
Counterfoils (array)
Chains of Characters
Classes
Dates
Entry and Exit
Operations with Files
The language SQL and PHP
Connection with MySQL
Meetings
Forms with PHP
To practise in line
List of practices in line
FAQ
Frequent questions
Codes PHP
List of Codes PHP
Forums
Forums PHP
Other Manuals
Manuals of other languages
 
   
 
 
MySpaceScripts.info - Sitemap - Contact us - Sitemap - Contact us - Sitemap - Contact us

Motorization hobby , cars , auto.moto-point.co.uk , debt consolidation , auschwitz tour , used cars , Paid to Read Blog