Require first and last name

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
michalhana99
Posts: 33
Joined: Thu Dec 02, 2021 1:05 pm

Require first and last name

Post by michalhana99 »

Script URL:
Version of script:
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

Hi,
first of all I would like to thank you for the work you do.

I would need the user to enter their first and last name when submitting a ticket, in previous versions I solved this using code, see link below.

viewtopic.php?f=13&t=6977&p=29010&hilit ... ame#p29010

But in the new version 3.5.1, it will obviously need to be edited elsewhere

Thanks
Klemen
Site Admin
Posts: 10141
Joined: Fri Feb 11, 2005 4:04 pm

Re: Require first and last name

Post by Klemen »

It's a bit more complicated because customer accounts have been introduced.

Do you plan on using customer accounts or keeping them disabled?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
michalhana99
Posts: 33
Joined: Thu Dec 02, 2021 1:05 pm

Re: Require first and last name

Post by michalhana99 »

Hi, we would like to use customer accounts.
Klemen
Site Admin
Posts: 10141
Joined: Fri Feb 11, 2005 4:04 pm

Re: Require first and last name

Post by Klemen »

You will need to force full names at registration time then.

In register.php, just below

Code: Select all

$name = hesk_input(hesk_POST('name'));
add

Code: Select all

if ( ! strpos($name, ' ')) {
$hesk_error_buffer['name'] = 'Please enter your full name';
}
(similar, but not same code as before)
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
shddcit
Posts: 60
Joined: Wed Mar 30, 2022 3:54 pm

Re: Require first and last name

Post by shddcit »

And can I use the following code after the line?

Code: Select all

$name = hesk_input(hesk_POST('name'));

Code: Select all

function space_word_count($str)
{
    return count(preg_split('/\s+/', $str)); 
}
if ( ! strpos($tmpvar['name'], ' ')) {
    $hesk_error_buffer['name'] = $hesklang['enter_your_full_name'];
} 
else
if (space_word_count($tmpvar['name'])<3) {
$hesk_error_buffer['name'] = $hesklang['enter_your_full_name'];
}
else
if ( ! strpos($tmpvar['name'], '.') !==true) {
    $hesk_error_buffer['name'] = $hesklang['enter_your_full_name'];
}
Or would this be a more accurate option?

Code: Select all

function space_word_count($str)
{
    return count(preg_split('/\s+/', $str));
}

if (strpos($name, ' ') === false || space_word_count($name) < 3 || strpos($name, '.') !== false) {
    $hesk_error_buffer['name'] = $hesklang['enter_your_full_name']; // $hesklang['enter_your_full_name'] it is necessary to add to your translation text file so that the message is displayed
}

P.S. That's it, my second option actually gave me the ability to restrict registration without using my conditions.
Klemen
Site Admin
Posts: 10141
Joined: Fri Feb 11, 2005 4:04 pm

Re: Require first and last name

Post by Klemen »

Depending on how much you wish to complicate your customer's life :)

Use whatever works for you. It can be as simple as checking that there is an empty space in the name, or as complex as verifying the number of words, their length, composition, ...
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply