Hi there,
I've made a basic register script, which has the following code:
$site->Register points to this part of funcs.inc.php:
As you can see, the check/validate queries in funcs.inc.php return a value (e.g. 3 = Username is taken)
Is there some way I can go about incorporating some kind of error message on the initial form depending on what the script returns?
1 = Complete all fields
2 = Passwords don't match
3 = Username is taken
4 = Email is taken
Anything else = Registration complete
Ideally, I'd like this to show up on the form rather than have the user re-directed to another.
Is this possible? (Hope that's easy to follow)
Cheers
I've made a basic register script, which has the following code:
Code:
<?php
include( 'funcs.inc.php' );
if (!isset($_POST["register"]))
{ echo(" form goes here "); } else {
$user = $_POST["user"];
$pass1 = $_POST["pass1"];
$pass2 = $_POST["pass2"];
$email = $_POST["email"];
$mother = $_POST["mothername"];
$site->Register($user, $email, $mother, $pass1, $pass2);
}
?>
$site->Register points to this part of funcs.inc.php:
Code:
function Register( $user, $email, $mothername, $pass1, $pass2 )
{
if( empty( $user ) || empty( $email ) || empty( $mothername ) || empty( $pass1 ) || empty( $pass2 ) )
return 1;
if( $pass1 != $pass2 )
return 2;
$query = $this->QueryDb( "query to check if username is taken" );
if( mssql_num_rows( $query ) > 0 )
return 3;
$query = $this->QueryDb( "query to check if email is taken" );
if( mssql_num_rows( $query ) > 0 )
return 4;
$this->QueryDb( "if everything is fine, this INSERT script is ran inputting all the data" );
}
As you can see, the check/validate queries in funcs.inc.php return a value (e.g. 3 = Username is taken)
Is there some way I can go about incorporating some kind of error message on the initial form depending on what the script returns?
1 = Complete all fields
2 = Passwords don't match
3 = Username is taken
4 = Email is taken
Anything else = Registration complete
Ideally, I'd like this to show up on the form rather than have the user re-directed to another.
Is this possible? (Hope that's easy to follow)
Cheers