|
To recommend a place using PHP |
|
|
|
Script who threatens a user to visit the web site, route e-mail. This system allows to the user to send from the web, an e-mail another person, inviting it to visit the place.
Only it needs a module PHP that will be in charge of showing the recommendation form, sending the e-mail and being sick a mailing acknowledgement.
recomendar.php
<! - recommendation form->
<? if ($HTTP_GET_VARS ["action] == "") {
?>
<form method = "post" action = "recomendar.php? accion=enviar" yam = "recommends">
<b> He recommends this place </b> <br> <br>
Your Name: <unputt type = "text" yam = "n_remitente" size = "10"> <br>
Your E-mail: <unputt type = "text" yam = "e_remitente" size = "20"> <br>
Name of your friend: <unputt type = "text" yam = "n_destinatario" size = "10"> <br>
E-mail of your friend: <unputt type = "text" yam = "e_destinatario" size = "20"> <br> <br>
<unputt type = "submit" values = to "Recommend">
</form>
<! - mailing of the form and acknowledgement of mailing or information of errors->
<?
}
elseif ($HTTP_GET_VARS ["action] == to "send") {
//I gather the variables that come from the form
$n_destinatario = $HTTP_POST_VARS ["n_destinatario"];
$e_destinatario = $HTTP_POST_VARS ["e_destinatario"];
$n_remitente = $HTTP_POST_VARS ["n_remitente"];
$e_remitente = $HTTP_POST_VARS ["e_remitente"];
//if the fields are not empty
if ($n_destinatario! = "" && $e_destinatario! = "" && $n_remitente! = "" && $e_remitente! = "") {
//the url of your place indicates
$url = "http://www.tusitio.com";
//it indicates the name of your place
$nombre_del_sitio = "Your Place";
//it indicates the matter of the message
$asunto = $n_remitente. "he recommends to you a place";
//he writes the message
$mensaje = "Hello". $n_destinatario. ": <br>";
$mensaje. = $n_remitente. "he recommends to you to visit <b>". $nombre_del_sitio. "</b>. <br>";
$mensaje. = "you Can see it in <to href = '". $url. "'>". $url. "</to> <br> <br> Greetings!";
//it indicates that the mail is sent in format HTML
$encabezado = "From:". $e_remitente. "\nReply-To:". $e_remitente. "\n";
$encabezado. = "X-Mailer:PHP /". phpversion ()." \n";
$encabezado. = "Spoil Version: 1.0\n";
$encabezado. = "Content-Type: text/html";
//he sends the message
mail ($e_destinatario,$asunto,$mensaje,$encabezado);
//He informs the user who has sent to himself the message
I begin "<b> The message it has been sent </b>. <br> Thanks for recommending us!";
}
//if empty fields exist, he sends an error message
else {
I begin "Please, it is necessary that you complete all the fields. <br>";
I begin "<to href ='recomendar.php'> It punctures here </to> to correct the fields.";
}
}
?>
Eugenia Bahit
http://www.cmzk.com.ar/ |