Page 1 of 1

Name don't accept swedish characters; å, ä, ö ??

Posted: Mon Jan 25, 2021 11:36 pm
by Bluesman
Hi Pablo or other... I am almost ready with a login user system and testing... Trying to sign up a new account with my name containing the letter "ö" and it doesn't accept??
When changing the letter to "o" it works.
All pages in the project uses UTF-8
All forms also setted to UTF-8
Please is there a way to fix this?? I'm just some days from the deadline for publish :(

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 6:58 am
by Pablo
For security reasons, the name may only contain alpha numeric characters.
If you want to change this (at your own risk) then you can convert the login form to a standard form and edit the PHP script.

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 10:48 am
by Bluesman
Pablo wrote: Tue Jan 26, 2021 6:58 am For security reasons, the name may only contain alpha numeric characters.
If you want to change this (at your own risk) then you can convert the login form to a standard form and edit the PHP script.
Thanks Pablo, shall check that out... but I wonder... there are several countries that uses this kind of letters in their language; Sweden, Norway, Denmark, Iceland, Germany, Turkey etc... I think it's very odd to not have the possibility to insert names in name fields that contains this letters.
More than 20% of the names contains this.
If I use a regular form with name fields in and setted to "Use built-in PHP processor" it's no problem?? Just setted to UTF-8.
Kind regards

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 11:47 am
by Bluesman
Pablo wrote: Tue Jan 26, 2021 6:58 am then you can convert the login form to a standard form and edit the PHP script.
Did not work out well, because I'm not a PHP programmer... all messed up when converted?? Maybe I must erase this system (more than a week of work) and use a PHP script from 3:rd party... feal bad about this :(

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 12:12 pm
by Pablo
You will only need to change one line in the code.

Code: Select all

if (!preg_match("/^[A-Za-z0-9-_!@$]{1,50}$/", $newusername))

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 12:42 pm
by Bluesman
Pablo wrote: Tue Jan 26, 2021 12:12 pm You will only need to change one line in the code.

Code: Select all

if (!preg_match("/^[A-Za-z0-9-_!@$]{1,50}$/", $newusername))
Hi again Pablo... can you just look fast how the system looks like?
Booking page: https://www.chevere.ec/tvattnet/hushallstvatt.php shop make a order and click "BESTÄLL"
Sign up page: "Do not have a username and password, sign up here"
Now your on the sign up page that doesn't accept åäö... and I think by making this to a regular form it nead some more programming than you wrote?
For example the extra fields... ?
A question: When making a ordinary form out of this shall I select "Use built-in PHP form processor script" ? Or shall I just leave this form settings for the layout grid without any changes and insert the script you provided to the HTML object?

Image

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 1:01 pm
by Pablo
When you select 'convert to 'form' then the login form will be converted to a standard form.
The required code will be placed in a HTML object.

The built-in form processor should NOT be enabled.

Please note that this option is for advanced users, some PHP knowledge is required.

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 1:21 pm
by Bluesman
So... I'm not a php programmer. Shall I skip these tools now then? Or shall I try to insert the code you gave me to the HTML object that was created?
I have no clue where to insert the code but maybe someone can tell me where in this code:

<?php
$database = './tvattnet_database.php';
$success_page = './pay-on-delivery-ok.php';
$activated_page = './password-recovery-error.html';
$error_message = "";
if (!file_exists($database))
{
die('User database not found!');
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['form_name']) && $_POST['form_name'] == 'signupform')
{
$newusername = $_POST['username'];
$newemail = $_POST['email'];
$newpassword = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$newfullname = $_POST['fullname'];
$extra1 = $_POST['extra1'];
$extra2 = $_POST['extra2'];
$extra3 = $_POST['extra3'];
$extra4 = $_POST['extra4'];
$extra5 = $_POST['extra5'];
$website = $_SERVER['HTTP_HOST'];
$script = $_SERVER['SCRIPT_NAME'];
$timestamp = time();
$code = md5($website.$timestamp.rand(100000, 999999));
if ($newpassword != $confirmpassword)
{
$error_message = 'Lösenord och Verifiera Lösenord är inte lika.';
}
else
if (!preg_match("/^[A-Za-z0-9-_!@$]{1,50}$/", $newusername))
{
$error_message = 'Användarnamnet är inte giltigt, kontrollera och försök igen.';
}
else
if (!preg_match("/^[A-Za-z0-9-_!@$]{1,50}$/", $newpassword))
{
$error_message = 'Lösenordet är inte giltigt, kontrollera och försök igen.';
}
else
if (!preg_match("/^[A-Za-z0-9-_!@$.' &]{1,50}$/", $newfullname))
{
$error_message = 'Namn är inte korrekt, kontrollera och försök igen.';
}
else
if (!preg_match("/^.+@.+\..+$/", $newemail))
{
$error_message = 'E-post adressen är inte korrekt. Kontrollera och försök igen.';
}
else
if (strlen($extra1) == 0)
{
$error_message = 'Fältet får inte vara tomt (Personnummer)';
}
else
if (strlen($extra2) == 0)
{
$error_message = 'Fältet får inte vara tomt (Adress)';
}
else
if (strlen($extra3) == 0)
{
$error_message = 'Fältet får inte vara tomt (Postnummer)';
}
else
if (strlen($extra4) == 0)
{
$error_message = 'Fältet får inte vara tomt (Stad)';
}
$items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($items as $line)
{
list($username, $password, $email, $fullname) = explode('|', trim($line));
if ($newusername == $username)
{
$error_message = 'Var vänlig välj ett annat användarnamn.';
break;
}
}
if (empty($error_message))
{
$file = fopen($database, 'a');
fwrite($file, $newusername);
fwrite($file, '|');
fwrite($file, md5($newpassword));
fwrite($file, '|');
fwrite($file, $newemail);
fwrite($file, '|');
fwrite($file, $newfullname);
fwrite($file, '|0|');
fwrite($file, $code);
fwrite($file, '|');
fwrite($file, $extra1);
fwrite($file, '|');
fwrite($file, $extra2);
fwrite($file, '|');
fwrite($file, $extra3);
fwrite($file, '|');
fwrite($file, $extra4);
fwrite($file, '|');
fwrite($file, $extra5);
fwrite($file, "\r\n");
fclose($file);
$subject = 'TvättNet. - Ditt nya konto';
$message = 'Ditt nya konto är registrerat; var vänlig aktivera genom att klicka på länken nedan.';
$message .= "\r\nUsername: ";
$message .= $newusername;
$message .= "\r\nPassword: ";
$message .= $newpassword;
$message .= "\r\n";
$message .= "\r\nhttp://".$website.$script."?user=".$newusername."&code=$code";
$header = "From: yourmail@yoursite.com"."\r\n";
$header .= "Reply-To: yourmail@yoursite.com"."\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: PHP v".phpversion();
mail($newemail, $subject, $message, $header);
mail('yourmail@yoursite.com', $subject, $message, $header);
header('Location: '.$success_page);
exit;
}
}
else
if (isset($_GET['code']) && isset($_GET['user']))
{
$found = false;
$items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($items as $line)
{
list($username, $password, $emailaddress, $fullname, $active, $code) = explode('|', trim($line));
if ($username == $_GET['user'] && $code == $_GET['code'])
{
$found = true;
}
}
if ($found == true)
{
$file = fopen($database, 'w');
foreach($items as $line)
{
$values = explode('|', trim($line));
if ($_GET['user'] == $values[0])
{
$values[4] = "1";
$values[5] = "NA";
$line = '';
for ($i=0; $i < count($values); $i++)
{
if ($i != 0)
$line .= '|';
$line .= $values[$i];
}
}
fwrite($file, $line);
fwrite($file, "\r\n");
}
fclose($file);
}
else
{
die ('User not found!');
}
header("refresh:5;url=".$activated_page);
echo 'Your user account was succesfully activated. You\'ll be redirected in about 5 secs. If not, click <a href="'.$activated_page.'">here</a>.';
exit;
}
?>

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 2:06 pm
by Pablo
If you want to change the restrictions of the user name then this code needs to be changed:

Code: Select all

if (!preg_match("/^[A-Za-z0-9-_!@$]{1,50}$/", $newusername))
Currently, this code restricts the input of the name to alpha numeric characters only for security reasons.
The more characters you allow, the less secure the form may become.

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 2:21 pm
by Bluesman
Pablo wrote: Tue Jan 26, 2021 2:06 pm If you want to change the restrictions of the user name then this code needs to be changed:

Code: Select all

if (!preg_match("/^[A-Za-z0-9-_!@$]{1,50}$/", $newusername))
Currently, this code restricts the input of the name to alpha numeric characters only for security reasons.
The more characters you allow, the less secure the form may become.
As mentioned from the beginning is the "Name" field it's about, not the "user name" but maybe better change both??

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Tue Jan 26, 2021 3:10 pm
by Pablo
In that case, you will need to change:

Code: Select all

if (!preg_match("/^[A-Za-z0-9-_!@$.' &]{1,50}$/", $newfullname))
or both...

Re: Name don't accept swedish characters; å, ä, ö ??

Posted: Thu Jan 28, 2021 10:50 pm
by Bluesman
Just for your knowledge Pablo... I skipped the login system from wwb regarding to the problem with the swedish characters. Must be easy to update and handle. I have deadline on sunday and had to take a fast decision. So now I'm using a 3rd part PHP script instead.
Tnx for your assistance