Jump to content

User's register, and send mail with the account info...


McBlink

Recommended Posts

Hello, i'm argentian and i don't speak english very well, but well, i have a problem.

i desire send mail to the new user than he register in my web.

i have 2 codes. 1 is registra.php

that one is in charge to verify fields and to register the new user, and other that sends a mail to the user, but this I complete not where to place it within registrar.php.

 

the code of registra.php is the next:

<?
include('config.php'); //incluimos el config.php que contiene los datos de la conexión a la db
//Inicias la sesión
session_name('sesion_site');
session_start();

//Comprobamos que los campos nick, pass y pass1 se han rellenado en el form de reg.php, sino volvemos al form
if(($_POST[nick] == ' ') or ($_POST[pass] == ' ') or ($_POST[pass1] == ' ') )
{
Header("Location: reg.php"); //enviamos al form de registro que esta en reg.php
}else{

//Comprobamos que la pass y pass1 son iguales, sino, volvemos a reg.php
if($_POST[pass] != $_POST[pass1])
{
echo 'Las passwords no son iguales';
}else{

//quitamos el codigo malicioso de $_POST[nick] y $_POST[pass]
$user = stripslashes($_POST["nick"]);
$user = strip_tags($user);
$pass = stripslashes($_POST["pass"]);
$pass = strip_tags($pass);
//comprobamos que el usuario no existe en la db
$usuarios=mysql_query("SELECT nick FROM user WHERE nick='$user' ");
if($user_ok=mysql_fetch_array($usuarios))
{
echo 'El usuario ya esta registrado';
mysql_free_result($usuarios); //liberamos la memoria del query a la db
}else{
//quitamos todo el codigo malicioso de las demas variables del form de registro
$email = stripslashes($_POST["email"]);
$email = strip_tags($email);
$pj = stripslashes($_POST["pj"]);
$pj = strip_tags($pj);

$rollo = stripslashes($_POST["rollo"]);
$rollo = strip_tags($rollo);
$rollo = str_replace("\n\r","<br>",$rollo); //se cambian los saltos de linea por <br>
$rollo = str_replace("\r\n","<br>",$rollo);
$rollo = str_replace("\n","<br>",$rollo);

$fecha = time();
$level = "2"; //usaremos level 1 para admins, level 2 para los demas (se cambia manualmente desde phpmyadmin)

//introducimos el nuevo registro en la tabla users
$_SESSION['formulario'] = $_POST; 
mysql_query("INSERT INTO user (nick,pass,email,fecha,level,rollo,pj) values ('$user','$pass','$email','$fecha','$level','$rollo','$pj') ");
echo 'Usuario registrado con éxito.';
echo 'redireccionando al Home';
echo '<meta http-equiv="Refresh" content="1;URL=login.php">'; 
}

}

}
?>

 

and the code to send email is this: (but i not if he is correct)

 

<?
$remitente = $_REQUEST["email"];
$destino= "[email protected]";
$asunto= "Este es un mensaje de felicitacion";
$mensaje= "América y ya<p>Nos vamos a la Libertadores<p><b>América para los americanistas</b>";
$encabezados = "From: $remitente\nReply-To: $remitente\nContent-Type: text/html; charset=iso-8859-1";

mail($destino, $asunto, $mensaje, $encabezados) or die ("Su mensaje no se envio.");
?>

 

Well, i'm sorry for my bad english, can you understand the topic? xD

 

greetings from Argentinean!!

Bye!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.