Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/06/2009, 05:03
jochite
 
Fecha de Ingreso: septiembre-2008
Mensajes: 185
Antigüedad: 15 años, 6 meses
Puntos: 1
Respuesta: Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or cus

<?php require_once('Connections/conectaip.php'); ?>

<?php

// Este fichero recibe y procesa los datos del formulario de recuperacion de contraseña


// en el que se escriben usuario y email

// recogemos las variables enviadas por el formulario

session_start(); //abrimos la sesion para poder despues pasar variables de una pagina a otra


$nombreusuario=$_POST['username'];


// Conectamos a la base de datos

$con=mysql_connect('localhost','ip','ip)or die ('Ha fallado la conexión: '.mysql_error());
mysql_select_db('base_ip')or die ('Error al seleccionar la Base de Datos: '.mysql_error());


function quitar($mensaje) //funcion para quitar caracteres no permitidos
{
$nopermitidos = array("'",'\\','<','>',"\"",";","$","%","&","/","|","{","}","[","]","+","#");
$mensaje = str_replace($nopermitidos, "", $mensaje);
return $mensaje;
}



// Consultamos si existe $nombreusuario + $emailusuario

$res=mysql_query("SELECT COUNT(*) FROM usuarios WHERE username='$username'");

if (mysql_num_rows($res)==0) {
// Si no existe, datos incorrectos y fin del proceso y volvemos al formulario de recuperacion
header("Location:recuperar.php");

}
else {
// Si existe, buscamos en la bd

$res=mysql_query("SELECT * FROM usuarios WHERE username='$username' AND password='$password'");
$row=mysql_fetch_assoc($res);
$password=$row['password'];




//Generar contraseña aleatoria

function generar_id($length)
{
$str = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLM NOPQRSTUVWXYZ";

for($i=0;$i<$length;$i++)
$key .= $str[mt_rand(0,strlen($str)-1)];

return $key;
}

$random = generar_id(15);


// enviamos el email de recuperacion

$username=$_POST['username'];
$asunto="Recuperación:Sus datos en nuestra web son: $username, $random";


mail($username,$asunto,"MIME-Version:1.0\nContent-type:text/html;charset=UTF-8\nFrom:$empresa<$correo_empresa>");

$asunto .= " Copia ";

mail($username, $correo_empresa,$asunto,"MIME-Version:1.0\nContent-type:text/html;charset=UTF-8\nFrom:$empresa<$correo_empresa>");

$random=md5($random);


$query = "UPDATE usuarios
SET password = '$random' WHERE username ='$username' " ;
mysql_query($query) or die(mysql_error());

}

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<div id="mainContent"><!-- TemplateBeginEditable name="Contenido_principal" -->


<form action="" method="get">
<table width="90%" height="4%" border="1" cellpadding="10">
<tr>
<td width="100%" height="20"><span class="Estilo19">Si has olvidado tu clave utiliza el siguiente formulario. </span></td>
</tr>
<tr>
<td height="20">&nbsp;</td>
</tr>
<tr>
<td height="20">&nbsp;</td>
</tr>
<tr>
<td height="20"><div align="center"><span class="Estilo19">Correo
</span>
<input name="username" type="text" id="username" size="60" />
</div></td>
</tr>
<tr>
<td height="20"><label for="button2">
<div align="left"></div>
</label>
<label for="button3"></label>
<label for="button2"> </label> <div align="left"></div></td>
</tr>
<tr>
<td height="20"><input type="submit" name="button2" id="button2" value="Recordar Clave" /></td>
</tr>
</table>
</form>


<!-- TemplateEndEditable --> </div>


<!-- TemplateEndEditable --> </div>
<!-- Este elemento de eliminación siempre debe ir inmediatamente después del div #mainContent para forzar al div #container a que contenga todos los elementos flotantes hijos -->
<div id="footer">
<table width="947" height="100%" border="0" align="center" cellpadding="10">
<tr>

</tr>
<tr align="left">
<td height="108" colspan="3"><form id="form1" name="form1" method="get"
<span class="Estilo8">
<label for="q"></label>
</span>
<div align="center"> <span class="Estilo8">
<input name="q" type="text" id="q" size="40" />
</span><span class="Estilo7"> </span><span class="Estilo6"> </span><span class="Estilo3"> </span>
<input type="submit" name="button" id="button" value="Buscar en Google" />
</div>
<label for="button"></label>
</form></td>
</tr>
</table>
</div>

Última edición por jochite; 06/07/2009 a las 06:12