08/07/2008, 23:41
|
| | | Fecha de Ingreso: enero-2004 Ubicación: Matamoros, Tamaulipas
Mensajes: 305
Antigüedad: 20 años, 10 meses Puntos: 3 | |
Ni idea porque no funciona. Código PHP:
<?php
require('../include/database_connection.php');
//añadimos la funcion que se encargara de generar un numero aleatorio
function genera_random($longitud){
$exp_reg="[^A-Z0-9]";
return substr(eregi_replace($exp_reg, "", md5(rand())) .
eregi_replace($exp_reg, "", md5(rand())) .
eregi_replace($exp_reg, "", md5(rand())),
0, $longitud);
}
if($_POST['yes'] == '1'){
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$country = $_POST['country'];
//validar campos que esten llenos.
if ($username == "" && $password == "" && $email == "" && $firstname == "" && $lastname == "" )
{ //abro el if
?>
<SCRIPT LANGUAGE="javascript">
alert("Please fill all fields...");
history.go(-1);
</SCRIPT>
<?
} //cierro el IF
else
{//abro el else
//fin de la validacion, comparo los campos de password
if ($password != $password2)
{
?>
<SCRIPT LANGUAGE="javascript">
alert("The passwords dont match...");
history.go(-1);
</SCRIPT>
<?
exit();
}
//empieza a comprarar usuario.
$user = "SELECT *
FROM users
WHERE username = '$username'";
$email = "SELECT *
FROM users
WHERE email = '$email'";
$checkusername = mysql_db_query($base,$user,$conn) or die (mysql_error());
$checkemail = mysql_db_query($base,$email,$conn) or die (mysql_error());
if(mysql_num_rows($checkusername) == 0){// Empiezo IF de verificacion de usuario
if(mysql_num_rows($checkemail) == 0){//Empiexo IF de verificacion de email
//delimitation
//agregamos la variable $activate que es un numero aleatorio de
//20 digitos crado con la funcion genera_random de mas arriba
$activate = genera_random(20);
$sql = 'INSERT INTO users (username, password, email, name, lastname, day, month, year, country, activate, status)
VALUES ("' . $username . '", "' . $password . '", "' . $email . '", "' . $firstname . '",
"' . $lastname . '", "' .$day. '", "' .$month. '", "' .$year. '", "' .$country. '",
"' .$activate. '", 1);';
if(mysql_query($sql)){
echo 'Registration successful! You have been registered as '.$username.'. Now we will send you an email with instructions on how to activate your account.';
//empezamos a enviar email
$sacaremail = "SELECT *
FROM users
WHERE username = '$username'";
$obteneremail = mysql_db_query($base,$sacaremail,$conn) or die (mysql_error());
$row = mysql_fetch_array($obteneremail);
$path="http://localhost/users/actions/";//localizacion de archivo de activacion.
//armamos link de activacion
$activateLink=$path."user_activate.php?id=".$row['id']."&activateKey=".$activate."";
// Datos del email
$nombre_origen = "Galvax.net";
$email_origen = "[email protected]";
$email_copia = "[email protected]";
$email_ocultos = "[email protected]";
$email_destino = "".$row['email']."";
$asunto = "".$row['usuario']." Your registration information from Galvax.net, please keep this email.";
$mensaje = '<table width="629" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="623" align="left"></td>
</tr>
<tr>
<td bgcolor="#2EA354"><div style="color:#FFFFFF; font-size:14; font-family: Arial, Helvetica, sans-serif; text-transform: capitalize; font-weight: bold;"><strong> This is the information you entered, '.$row['username'].'</strong></div></td>
</tr>
<tr>
<td height="95" align="left" valign="top"><div style=" color:#000000; font-family:Arial, Helvetica, sans-serif; font-size:12px; margin-bottom:3px;"> USERNAME: '.$row['username'].'</strong><br><br><br>
<strong>PASSWORD : </strong>'.$row['password'].'</strong><br><br><br>
<strong>EMAIL : </strong>'.$row['email'].'</strong><br><br><br>
<strong>ACTIVATION LINK:<br><a href="'.$activateLink.'">'.$activateLink.' </strong></a><br><br><br>
<strong>We require that you "validate" your registration to ensure that the email address you entered was correct. This protects against unwanted spam and malicious abuse.
To activate your account, simply click on the ACTIVATION LINK (above this text).
</strong><br><br><br>
<strong>IF THE LINK DOESNT WORK, PLEASE TRY AGAIN.</strong><br><br><br>
<strong>Thank you for registering and enjoy your stay!.</strong><br><br><br>
<strong>Regards, Galvax.net.</strong><br><br><br>
</div>
</td>
</tr>
</table>';
$formato = "html";
//*****************************************************************//
$headers = "From: $nombre_origen <$email_origen> \r\n";
$headers .= "Return-Path: <$email_origen> \r\n";
$headers .= "Reply-To: $email_origen \r\n";
$headers .= "X-Sender: $email_origen \r\n";
$headers .= "X-Priority: 3 \r\n";
$headers .= "MIME-Version: 1.0 \r\n";
$headers .= "Content-Transfer-Encoding: 7bit \r\n";
//*****************************************************************//
if($formato == "html")
{ $headers .= "Content-Type: text/html; charset=iso-8859-1 \r\n"; }
else
{ $headers .= "Content-Type: text/plain; charset=iso-8859-1 \r\n"; }
@mail($email_destino, $asunto, $mensaje, $headers))
}
else{
echo 'We are sorry, but you were not able to register, please contact the administrator.<br><small>' . mysql_error() . '</small>';
}
exit;
}//Termino If de verificacion de email
else{
?>
<SCRIPT LANGUAGE="javascript">
alert("The Email already exists, please use another email...");
history.go(-1);
</SCRIPT>
<?
}//Termino Else de verificacion de email
}//Termino If de verificacion de usuario
else{
?>
<SCRIPT LANGUAGE="javascript">
alert("The Username already exists, please try again...");
history.go(-1);
</SCRIPT>
<?
} //End of Else
}
}//cierro el else
?> Este es el codigo que programe para registrar usuarios, pero tengo un error, y al parecer es una braqueta perdida pero no logro ubircarla, alguien no tendra un programa que pueda ayudarme a ubicarla o alguien me podria decir si es otra cosa lo que esta mal, gracias. |