Comparing revisions for RegisterAction

Additions:
>>==See also:==
Current version: 0.2
* @version 0.2
if ($this->GetConfigValue("allow_new_users") == "0") {
print $this->Format('//User registration is disabled on this wiki//');
} else {
if ($user = $this->GetUser()){
// is this the first time the user is logged in?
if ($_GET['reg'] == 'ok') {
// first login welcome stuff
// print $this->Format('--- **Registration successful!** --- --- You are currently logged in as '.$this->GetUserName());
// ...or forward
$this->Redirect($this->href('','WelcomeUser'));
} else {
// print user information
print $this->Format('--- You are currently logged in as '.$this->GetUserName());
} else {
print "<script type=\"text/javascript\"><!-- \nfunction hov(loc,cls){ \n if(loc.className) loc.className=cls;\n}\n //-->\n</script>\n";
if ($_POST) {
if ($_POST['name']) $name = trim($_POST['name']);
if ($_POST['email']) $email = trim($_POST['email']);
if ($_POST['password']) $password = $_POST['password'];
if ($_POST['confpassword']) $confpassword = $_POST['confpassword'];
// todo: add icons on non-valid fields
if ($this->LoadUser($name)) {
$error = 'Sorry, this username already exists. Please choose a different name.';
} elseif ($this->ExistsPage($name)) {
$error = 'Sorry, this username is reserved for a page. Please choose a different name.';
} elseif (!$this->IsWikiName($name)) {
$error = 'Please fill in a valid username (formatted as a ##""WikiName""##).';
} elseif (!isset($email)) {
$error = 'Please specify an email address.';
} elseif (!preg_match("/^.+?\@.+?\..+$/", $email)) {
$error = 'That does not quite look like an email address.';
} elseif (!isset($password)) {
$error = 'Please choose your password.';
} elseif (strlen($password) < 5) {
$error = 'Sorry, password too short.';
$error = 'Sorry, spaces are not allowed in passwords.';
} elseif (!isset($confpassword)) {
} elseif ($confpassword != $password) {
} else {
"password = md5('".mysql_real_escape_string($_POST["password"])."')");
$this->Redirect($this->href('','','reg=ok'));
~-a **valid password** (min. 5 characters, no space allowed).
$form .= ' <table summary="Form to provide registration data: username, email and password">';
=== Implemented modifications ===
CategoryDevelopment
Deletions:
>>**See also:**
~-UserAccountModules
Current version: 0.3
~-Variable initialization and constants section;
* @version 0.3
* - define welcome page where new users must be redirected;
// constants
define('MIN_PASSW_LENGTH', '5');
define('DEFAULT_REDIRECT_TO', 'WelcomeUser');
if ($this->GetConfigValue('allow_new_users') == '0')
{
print $this->Format('//User registration is disabled on this wiki//');
} else
{
if ($user = $this->GetUser())
{
// initializing variables
$name = '';
$email = '';
$password = '';
$confpassword = '';
$error = '';
// is this the first time the user logs in?
if ((isset($_GET['reg'])) && ($_GET['reg'] == '1'))
{
switch ($this->GetConfigValue('allow_new_users'))
{
default:
case 0:
// print first login welcome screen
print $this->Format('--- **Registration successful!** --- --- You are currently logged in as '.$this->GetUserName());
break;
case 1:
// redirect to welcome page
$this->Redirect($this->href('', DEFAULT_REDIRECT_TO));
break;
case 2:
// redirect to referrer page
$this->Redirect($this->href('', DEFAULT_REDIRECT_TO));
break;
} else
{
// user is already logged in: print user information
print $this->Format('--- You are currently logged in as '.$this->GetUserName());
} else
{
if ($_POST)
{
if (isset($_POST['name'])) $name = trim($_POST['name']);
if (isset($_POST['email'])) $email = trim($_POST['email']);
if (isset($_POST['password'])) $password = $_POST['password'];
if (isset($_POST['confpassword'])) $confpassword = $_POST['confpassword'];
if ($this->LoadUser($name))
{
$error = 'Sorry, this username already exists. Please choose a different name.';
} elseif ($this->ExistsPage($name))
{
$error = 'Sorry, this username is reserved for a page. Please choose a different name.';
} elseif (!$this->IsWikiName($name))
{
$error = 'Please fill in a valid username (formatted as a ##""WikiName""##).';
} elseif (!$email)
{
$error = 'Please specify an email address.';
} elseif (!preg_match("/^.+?\@.+?\..+$/", $email))
{
$error = 'That does not quite look like an email address.';
} elseif (!$password)
{
$error = 'Please choose your password.';
} elseif (strlen($password) < MIN_PASSW_LENGTH)
{
$error = 'Sorry, password too short (min. '.MIN_PASSW_LENGTH.' chars).';
$error = 'Sorry, spaces are not allowed in passwords.';
} elseif (!$confpassword)
{
} elseif ($confpassword != $password)
{
} else
{
"password = md5('".mysql_real_escape_string($password)."')");
$this->Redirect($this->href('','','reg=1'));
~-a **valid password** (min. '.MIN_PASSW_LENGTH.' characters, no space allowed).
$form .= ' <table summary="Form to provide registration data: username, email and password">';
$form .= ' <caption>Registration form</caption>';
if (isset($error))
{
$form .= ' <th align="right" scope="row"><label for="name">Your username:</label></th>';
$form .= ' <td><input name="name" id="name" size="40" value="'.$name.'" title="Choose a valid username (formatted as a WikiName)" /></td>';
$form .= ' <th align="right" scope="row"><label for="email">Your email address:</label></th>';
$form .= ' <td><input name="email" id="email" size="40" value="'.$email.'" title="Fill in a valid email address"/></td>';
$form .= ' <th align="right" scope="row"><label for="password">Your password:</label></th>';
$form .= ' <td><input type="password" name="password" id="password" size="40" title="Choose a valid password (min. '.MIN_PASSW_LENGTH.' chars, no space)" /></td>';
$form .= ' <th align="right" scope="row"><label for="confpassword">Confirm password:</label></th>';
$form .= ' <td><input type="password" name="confpassword" id="confpassword" size="40" title="Type again your password for confirmation" /></td>';
$form .= ' <td><input type="submit" value="Register" title="Register" /></td>';
''See RegisterUserIpAddress for a small (security-related) modification. --JavaWoman''
=== Discussion ===
~~~~~~& OK, agreeing to disagree a done deal! ;) I apologise for not picking up on your earlier mentioning of align="right" going into CSS. But you will find that align probably **will** be deprecated in [[http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-tables.html#s_tablesmodule XHTML 2]], so it is still deemed a presentational throwback that they weren't brave enough to expunge in 1.1! If you have any links to articles defending the use of tables in forms, I'd be interested, leave them on my page here. Thank you for the interesting discussion, even if you are wrong :p (that is the stick-out tongue smiley just in case!), take care, --IanAndolina
CategoryDevelopmentActions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki