hace un tiempo que deje la web y volvi a codificarla pero no se si php cambio codigos y ahora no me da mensaje de error ni nada y en la base de datos no me aparece el usuario creado, no se si estoy haciendo mal la base de datos o es el codigo
Código PHP:
<?php
$error_message = NULL;
$user = make_safe($_POST['user']);
$pwd = make_safe($_POST['password']);
$confirmpwd = make_safe($_POST['confirm_password']);
$email = make_safe($_POST['email']);
//if I wasn't lazy I bet I could have made a loop for all these make_safe's
$name = make_safe($_POST['contact_name']);
$street = make_safe($_POST['contact_street']);
$city = make_safe($_POST['contact_city']);
$state = make_safe($_POST['contact_state']);
$zip = make_safe($_POST['contact_zip']);
if($_POST['action'] == 'create') {
// creating a new account.
// perform a PHP test to see if the account already exists
if(!user_exists($user) && ($pwd == $confirmpwd)) {
create_user($user, $pwd, $email); //make the user!
do_login($user, $pwd); //login
header('Location: ?co=home');
//redirect to homepage
} else { //oh noes!
$error_message = "Account creation failed!";
}
} else if($_POST['action'] == 'login') {
if(do_login($user, $pwd)) {
// user is logged in
// redirecting user to somewhere useful
header('Location: ?co=home');
} else {
$error_message = "Username or password bad!";
}
} else if($_POST['action'] == 'add_contact'){
$created_by = get_user();
$stammy_query = "insert into contacts (name, street, city, state, zip, created_by) values('$name', '$street', '$city', '$state', '$zip', '$created_by')";
if (!mysql_query($stammy_query)){
die('Error: ' . mysql_error());
}
header('Location: ?co=manage');
//good place to put an error message thing
}
if($error_message !== NULL) //if error message exists, output it!
echo $error_message;
?>