Ver Mensaje Individual
  #13 (permalink)  
Antiguo 26/07/2007, 21:40
Avatar de leskolpykos
leskolpykos
 
Fecha de Ingreso: junio-2007
Ubicación: Caracas
Mensajes: 96
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: cómo recordar contraseña y enviarle al usuario la misma que creó

bueno GatorV, este código es el de registro de usuarios de mi web, de aqui quisiera intentar sacar algo pero copio y pego pedazos por todos lados y no me funciona, claro eliminando los datos que son del registro de usuario pues

<?php require_once('conexion.php'); ?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="error_log.php";
$loginUsername = $_POST['nick'];
$LoginRS__query = "SELECT nick FROM usuarios WHERE nick='" . $loginUsername . "'";
mysql_select_db($ho000429_users);
$LoginRS=mysql_query($LoginRS__query) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO usuarios (nombre, cedula, fecha, edad, nick, contrasena, email, newsletter, eventos) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['cedula'], "int"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['edad'], "int"),
GetSQLValueString($_POST['nick'], "text"),
GetSQLValueString($_POST['contrasena'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString(isset($_POST['newsletter']) ? "true" : "", "defined","'SI'","'NO'"),
GetSQLValueString(isset($_POST['eventos']) ? "true" : "", "defined","'SI'","'NO'"));

mysql_select_db($ho000429_users);
$Result1 = mysql_query($insertSQL) or die(mysql_error());

$insertGoTo = "reg_ok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
/* envio del mail */
$asunto = "Felicidades!! Ya eres un usuario de Luisespectaculo.net!";
$destinatario = $_POST['email'];
$tema = $_POST['nick'];
$tema = $_POST['contrasena'];
$mensaje='Felicidades - aqui va el cuerpo del mensaje-';
$cuerpo = $parte1.$gt5fg8t4.$link.$gt5fg8t4.$partex.$destina tario.$parte2.$password.$parte3;
$headers.= "From: Luisespectaculo.net <[email protected]>\r\n";
//para el envío en formato HTML
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

//dirección del remitente
$headers .= "From: Luisespectaculo.net <[email protected]>\r\n";

//dirección de respuesta, si queremos que sea distinta que la del remitente
$headers .= "Reply-To: [email protected]\r\n";

if ($destinatario != '') {
mail($destinatario,$asunto,$mensaje,$headers);
}
?>

si puedes asesorarme tambien de un sitio web donde pueda aprender rapido a hacerlo te lo agradeceria, espero tu respuesta gracias