Ver Mensaje Individual
  #12 (permalink)  
Antiguo 05/05/2011, 11:29
Avatar de CristinxD
CristinxD
 
Fecha de Ingreso: mayo-2011
Ubicación: Manizales, Caldas, Colombia, Colombia
Mensajes: 5
Antigüedad: 13 años
Puntos: 0
De acuerdo Respuesta: nesecito ayuda para hacer un login y register en mi pagina

Ok sigamos Con el register
Código HTML:
<?php
$error_message = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
   $action = isset($_POST['action']) ? $_POST['action'] : '';
   $database = './usersdb.php';
   $success_page = './index.html';

   if (!file_exists($database))
   {
      echo 'User database not found!';
      exit;
   }
   if ($action == 'signup')
   {
      $newusername = $_POST['username'];
      $newemail = $_POST['email'];
      $newpassword = $_POST['password'];
      $confirmpassword = $_POST['confirmpassword'];
      $newfullname = $_POST['fullname'];
      if ($newpassword != $confirmpassword)
      {
         $error_message = 'Password and Confirm Password are not the same!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newusername))
      {
         $error_message = 'Username is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newpassword))
      {
         $error_message = 'Password is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $newfullname))
      {
         $error_message = 'Fullname is not valid, please check and try again!';
      }
      else
      if (!ereg("^.+@.+\..+$", $newemail))
      {
         $error_message = 'Email is not a valid email address. Please check and try again.';
      }
      $items = file($database);
      foreach($items as $line)
      {
         list($username, $password, $email, $fullname) = explode('|', trim($line));
         if ($newusername == $username)
         {
            $error_message = 'Username already used. Please select another username.';
            break;
         }
      }
      if (empty($error_message))
      {
         $file = fopen($database, 'a');
         fwrite($file, $newusername);
         fwrite($file, '|');
         fwrite($file, md5($newpassword));
         fwrite($file, '|');
         fwrite($file, $newemail);
         fwrite($file, '|');
         fwrite($file, $newfullname);
         fwrite($file, '|1');
         fwrite($file, "\r\n");
         fclose($file);

         $mailto = $newemail;
         $subject = 'Your new account';
         $message = 'A new account has been setup.';
         $message .= "\r\nUsername: ";
         $message .= $newusername;
         $message .= "\r\nPassword: ";
         $message .= $newpassword;
         $message .= "\r\n";
         $header  = "From: [email protected]"."\r\n";
         $header .= "Reply-To: [email protected]"."\r\n";
         $header .= "MIME-Version: 1.0"."\r\n";
         $header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
         $header .= "Content-Transfer-Encoding: 8bit"."\r\n";
         $header .= "X-Mailer: PHP v".phpversion();
         mail($mailto, $subject, $message, $header);
         header('Location: '.$success_page);
         exit;
      }
   }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Page</title>
<meta name="GENERATOR" content="Created by BlueVoda">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="bv_Signup1" style="position:absolute;left:72px;top:48px;width:225px;height:184px;z-index:0;" align="left">
<form name="signup" method="post" action="<?php echo basename(__FILE__); ?>" id="signup">
<input type="hidden" name="action" value="signup">
<table cellspacing="4" cellpadding="0" style="background-color:#FFFFFF;border-color:#FFFFFF;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;width:225px;height:184px;">
<tr>
   <td colspan="2" align="center" height="13px" style="background-color:#FFFFFF;color:#000000;">
Sign up for a new account</td>
</tr>
<tr>
   <td align="right" height="13px">Full Name:</td>
   <td><input name="fullname" type="text" id="fullname" style="width:100px;height:18px;background-color:#FFFFFF;border-color:#BFDBFF;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;" /></td>
</tr>
<tr>
   <td align="right" height="13px">User Name:</td>
   <td><input name="username" type="text" id="username" style="width:100px;height:18px;background-color:#FFFFFF;border-color:#BFDBFF;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;" /></td>
</tr>
<tr>
   <td align="right" height="13px">Password:</td>
   <td><input name="password" type="password" id="password" style="width:100px;height:18px;background-color:#FFFFFF;border-color:#BFDBFF;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;" /></td>
</tr>
<tr>
   <td align="right" height="13px">Confirm Password:</td>
   <td><input name="confirmpassword" type="password" id="confirmpassword" style="width:100px;height:18px;background-color:#FFFFFF;border-color:#BFDBFF;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;" /></td>
</tr>
<tr>
   <td align="right" height="13px">E-mail:</td>
   <td><input name="email" type="text" id="email" style="width:100px;height:18px;background-color:#FFFFFF;border-color:#BFDBFF;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;" /></td>
</tr>
<tr>
   <td colspan="2"><?php echo $error_message; ?></td>
</tr>
<tr>
   <td align="right" valign="bottom" colspan="2"><input type="submit" name="signup" value="Create User" id="signup" style="color:#000000;background-color:#FFFFFF;border-color:#000000;border-width:1px;border-style:solid;font-family:Verdana;font-size:11px;width:90px;height:20px;" /></td>
</tr>
</table>
</form>
</div>
</body>
</html> 
Ases lo mismo solo edita lo que dice [email protected] y lo de Succes_page


Chao No te olvides de crear el USERSDB.php si no te sirve algo enviame un correo a [email protected]
__________________________________________________ ______________

Este a sido Un correo de ayuda Hecho por uno de los Administradores de DapOrg Inc. y NanoCool Inc.

www.daporg.co.cc
nanocool.produccionscristian.com