function register($user, $pass){
if(strlen($user) < 4 || strlen($pass) < 4){
return "Your username must be over 3 characters.";
}
$result = some database registration stuff, true on row inserted false on none inserted.
return $result;
}
And then on the register process page:
<?php
$result = register($_POST['user'], $_POST['pass']);
if($result === true){
echo "You have been registered."
} else if($result === false){
echo "An unknown error has occurred. Please try again later.";
} else {
echo $result;
}
?>
I was wondering if this is good coding practice or not. I also make sure to document the function and what it returns.

New Topic/Question
Reply




MultiQuote






|