UN EJEMPLO DE LO QUE QUIERO HACER:
Una "especie" de agenda con 2 archivos (son los que necesito que cree para cada usuario) Que en el primer archivo este el estilo de la pagina para guardar datos con metod post a otro archivo pero que solo lo vea el usuario que ingreso esos datos.
Les paso los codigos de registro y activacion de mi pagina para ver si se puede hacer lo que quiero en estos codigos.
Desde ya muchisimas gracias !
Form de registro
Código PHP:
<?php
require_once("models/config.php");
securePage($_SERVER['PHP_SELF']);
//Prevent the user visiting the logged in page if he/she is already logged in
if(isUserLoggedIn()) { header("Location: account.php"); die(); }
//Forms posted
if(!empty($_POST))
{
$errors = array();
$email = trim($_POST["email"]);
$username = trim($_POST["username"]);
$displayname = trim($_POST["displayname"]);
$password = trim($_POST["password"]);
$confirm_pass = trim($_POST["passwordc"]);
$captcha = md5($_POST["captcha"]);
if ($captcha != $_SESSION['captcha'])
{
$errors[] = lang("CAPTCHA_FAIL");
}
if(minMaxRange(5,25,$username))
{
$errors[] = lang("ACCOUNT_USER_CHAR_LIMIT",array(5,25));
}
if(!ctype_alnum($username)){
$errors[] = lang("ACCOUNT_USER_INVALID_CHARACTERS");
}
if(minMaxRange(5,25,$displayname))
{
$errors[] = lang("ACCOUNT_DISPLAY_CHAR_LIMIT",array(5,25));
}
if(!ctype_alnum($displayname)){
$errors[] = lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS");
}
if(minMaxRange(8,50,$password) && minMaxRange(8,50,$confirm_pass))
{
$errors[] = lang("ACCOUNT_PASS_CHAR_LIMIT",array(8,50));
}
else if($password != $confirm_pass)
{
$errors[] = lang("ACCOUNT_PASS_MISMATCH");
}
if(!isValidEmail($email))
{
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
}
//End data validation
if(count($errors) == 0)
{
//Construct a user object
$user = new User($username,$displayname,$password,$email);
//Checking this flag tells us whether there were any errors such as possible data duplication occured
if(!$user->status)
{
if($user->username_taken) $errors[] = lang("ACCOUNT_USERNAME_IN_USE",array($username));
if($user->displayname_taken) $errors[] = lang("ACCOUNT_DISPLAYNAME_IN_USE",array($displayname));
if($user->email_taken) $errors[] = lang("ACCOUNT_EMAIL_IN_USE",array($email));
}
else
{
//Attempt to add the user to the database, carry out finishing tasks like emailing the user (if required)
if(!$user->userCakeAddUser())
{
if($user->mail_failure) $errors[] = lang("MAIL_ERROR");
if($user->sql_failure) $errors[] = lang("SQL_ERROR");
}
}
}
if(count($errors) == 0) {
$successes[] = $user->success;
}
}
require_once("models/header.php");
echo "
<body>
<div id='wrapper'>
<div id='top'><div id='logo'></div></div>
<div id='content'>
<h1></h1>
<h2>Registrar</h2>
<div id='left-nav'>";
include("left-nav.php");
echo "
</div>
<div id='main'>";
echo resultBlock($errors,$successes);
echo "
<div id='regbox'>
<form name='newUser' action='".$_SERVER['PHP_SELF']."' method='post'>
<p>
<label>Usuario:</label>
<input type='text' name='username' />
</p>
<p>
<label>Nick:</label>
<input type='text' name='displayname' />
</p>
<p>
<label>Password:</label>
<input type='password' name='password' />
</p>
<p>
<label>Confirm:</label>
<input type='password' name='passwordc' />
</p>
<p>
<label>Email:</label>
<input type='text' name='email' />
</p>
<p>
<label>Capcha:</label>
<img src='models/captcha.php'>
</p>
<label>Ingresar capcha:</label>
<input name='captcha' type='text'>
</p>
<label> <br>
<input type='submit' value='Register'/>
</p>
</form>
</div>
</div>
<div id='bottom'></div>
</div>
</body>
</html>";
?>
Código PHP:
<?php
require_once("models/config.php");
securePage($_SERVER['PHP_SELF']);
//Get token param
if(isset($_GET["token"]))
{
$token = $_GET["token"];
if(!isset($token))
{
$errors[] = lang("FORGOTPASS_INVALID_TOKEN");
}
else if(!validateActivationToken($token)) //Check for a valid token. Must exist and active must be = 0
{
$errors[] = lang("ACCOUNT_TOKEN_NOT_FOUND");
}
else
{
//Activate the users account
if(!setUserActive($token))
{
$errors[] = lang("SQL_ERROR");
}
}
}
else
{
$errors[] = lang("FORGOTPASS_INVALID_TOKEN");
}
if(count($errors) == 0) {
$successes[] = lang("ACCOUNT_ACTIVATION_COMPLETE");
}
require_once("models/header.php");
echo "
<body>
<div id='wrapper'>
<div id='top'><div id='logo'></div></div>
<div id='content'>
<h1></h1>
<h2>Activar cuenta</h2>
<div id='left-nav'>";
include("left-nav.php");
echo "
</div>
<div id='main'>";
echo resultBlock($errors,$successes);
echo "
</div>
<div id='bottom'></div>
</div>
</body>
</html>";
?>