View Full Version : user registration problem
SlowRoasted
March 18th, 2005, 12:30 PM
Hey i got some code here for a user registration form. when i hit submit on the form i get the critical error evacuate message i put if the message variable is not set. Can someone take a look, here is the script, the form will be below it.
mpelland
March 18th, 2005, 01:09 PM
from what i can see, you are getting the inital critical error because your if(isset($message)) is outside of the if (isset($_POST['submit'])). so what happens is $message doesn't get set when you first load the page.. so that statement picks it up and displays your critical event
SlowRoasted
March 18th, 2005, 01:22 PM
i tried that and message doesnt print. what pisses me off is that im referencing a book as im doing this so i dont get how its not working:scream:
any other ideas mpelland?
SlowRoasted
March 18th, 2005, 01:27 PM
well one thing was that i had submit instead of "Submit" might work now
SlowRoasted
March 18th, 2005, 01:29 PM
Fatal error: Call to undefined function: escape_date() in /home/design/public_html/testlogin/insert.php on line 35
:worried:
did i create that function wrong somehow?
SlowRoasted
March 18th, 2005, 01:33 PM
ok i fixed that
now:
im getting "please try again" error
my query isnt running correctly
<?php
//Checking form
if(isset($_POST['Submit'])){
//Connect to database
require_once ('connect2.php');
//Create function for escaping data
function escape_data ($data){
global $dbc;
if(ini_get('magic_quotes_gpc')){
$data = stripslashes($data);
}
return mysql_real_escape_string ($data, $dbc);
}
//End Function
$message = NULL; //empty variable
//Check for first name
if(empty($_POST['fname'])){
$fn = FALSE;
$message .= 'your forgot your first name<br /><br />';
}
else{
$fn = escape_data($_POST['fname']);
}
//Check for last name
if(empty($_POST['lname'])){
$ln = FALSE;
$message .= 'your forgot your last name<br /><br />';
}
else{
$ln = escape_data($_POST['lname']);
}
//Check for the email address
if(empty($_POST['email'])){
$e = FALSE;
$message .= 'your forgot your email address<br /><br />';
}
else{
$e = escape_data($_POST['email']);
}
//Check for username
if(empty($_POST['uname'])){
$u = FALSE;
$message .= 'your forgot your username<br /><br />';
}
else{
$u = escape_data($_POST['uname']);
}
//Check and Match Password
if(empty($_POST['pword'])){
$p = FALSE;
$message .= 'your forgot your password<br /><br />';
}
else{
if($_POST['pword'] == $_POST['pword2']){
$fn = escape_data($_POST['fname']);
}
else{
$p = FALSE;
$message .= 'your passwords do not match<br /><br />';
}
}
//Validate everything
if($fn && $ln && $e && $u && $p){
//query
$query = "INSERT INTO members (firstname, lastname, email, username, password)
VALUES ('$fn', '$ln', '$e', '$u', PASSWORD('$p'))";
$result = @mysql_query ($query); //run query
//if query ran ok
if($result){
echo 'you have been registered';
exit();
}
else{
$message = 'system error!';
}
mysql_close();//close database connection
}else{
$message .= 'please try again<br /><br />';
}
}
//print error message
if (isset($message)){
echo "$message";
}
else{
echo 'critical error, evacuate';
}
?>
SlowRoasted
March 18th, 2005, 01:38 PM
DONE, that was annoying
*jumps up and does a party dance* :trout:
Denda2004
March 18th, 2005, 01:51 PM
DONE, that was annoying
*jumps up and does a party dance* :trout:
thats good to know ^^
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.