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

Es facil Men No necesitas SQL ni nada Aqui te paso el Codigo ;D
Código HTML:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
   $success_page = './index.html';
   $error_page = './index.html';
   $database = './usersdb.php';
   $crypt_pass = md5($_POST['password']);
   $found = false;
   $logindata = array();
   if(filesize($database) == 0)
   {
      header('Location: '.$error_page);
      exit;
   }
   else
   {
      $items = file($database);
      foreach($items as $line)
      {
         list($username, $password, $email, $fullname, $active) = explode('|', trim($line));
         $logindata[$username] = $password;
         if ($username == $_POST['username'] && $active != "0")
         {
            $found = true;
         }
      }
   }
   if($found == false)
   {
      header('Location: '.$error_page);
      exit;
   }
   if($logindata[$_POST['username']] == $crypt_pass)
   {
      session_start();
      $_SESSION['username'] = $_POST['username'];
      $rememberme = isset($_POST['rememberme']) ? true : false;
      if ($rememberme)
      {
         setcookie('username', $_POST['username'], time() + 3600*24*30);
         setcookie('password', $_POST['password'], time() + 3600*24*30);
      }
      header('Location: '.$success_page);
      exit;
   }
   else
   {
      header('Location: '.$error_page);
      exit;
   }
}
$username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
$password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';
?>
<!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_Login1" style="position:absolute;left:144px;top:72px;width:312px;height:144px;z-index:0;" align="left">
<form name="loginform" method="post" action="<?php echo basename(__FILE__); ?>" id="loginform">
<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:312px;height:144px;">
<tr>
   <td colspan="2" align="center" height="13px" style="background-color:#FFFFFF;color:#000000;">Log In</td>
</tr>
<tr>
   <td align="right" height="13px">User Name:</td>
   <td><input name="username" type="text" id="username" value="<?php echo $username; ?>" style="width:100px;height:18px;background-color:#FFFFFF;border-color:#000000;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" value="<?php echo $password; ?>" style="width:100px;height:18px;px;background-color:#FFFFFF;border-color:#000000;border-width:1px;border-style:solid;color:#000000;font-family:Verdana;font-size:11px;" /></td>
</tr>
<tr>
   <td colspan="2" height="13px" align="center"><input id="rememberme" type="checkbox" name="rememberme" />Remember me</td>
</tr>
<tr>
   <td align="right" valign="bottom" colspan="2"><input type="submit" name="login" value="Log In" id="login" style="color:#000000;background-color:#FFFFFF;border-color:#000000;border-width:1px;border-style:solid;font-family:Verdana;font-size:11px;width:70px;height:20px;" /></td>
</tr>
</table>
</form>
</div>
</body>
</html> 
Ok entonces Cojes ese codigo y cuando lo utilizes Modificale Solo estas partes
$success_page = './index.html';
$error_page = './index.html';
Esas Dos
Lo de SUCCESS_PAGE es el nombre de adonde Va a ir cuando alguien inicie Sesion y Lo de error_page Es donde va a ir si hay errores Tambien tienes que Crear un archivo que se llame usersdb.php ./ significa de donde vas a subir los Archivos y todo eso Digamos Subes la forma A ./public_html
Entonces dejas asi normal ./index.html
ok?
Ahorita te paso el register