Developer Support »

Check for an entered password  (See more user questions)

Hi .

My pleasure to assist.

These two lines of code should do the job for you (watch for wordwrap):

$acceptable_passwords = array('password01','password02','password03');

if(isset($_REQUEST['Password']) &&
!in_array($_REQUEST['Password'],$acceptable_passwords)){$errors[] =
"Password is incorrect";}

As you can see, the $acceptable_passwords array contains the passwords.
Change them to suit. You can have any number in there. They are case
sensitive. Put them in quotes and separate them with commas, as above.

The second line contains two instances of the field name. Case sensitive
(the example above uses the name you suggested with the first letter upper
case). Again, change this to suit. You can also change the error message
to suit.

Paste the lines into the script after these lines:

$errors = array();
$attachment_array = array();

...so it looks like this (watch for wordwrap):

$errors = array();
$attachment_array = array();

$acceptable_passwords = array('password01','password02','password03');

if(isset($_REQUEST['Password']) &&
!in_array($_REQUEST['Password'],$acceptable_passwords)){$errors[] =
"Password is incorrect";}

I haven't tested this but it looks ok to me.

Any questions, just let me know.

Best wishes.

Charles Sweeney
https://formtoemail.com
The world's easiest feedback script!

----- Original Message -----
Sent: Friday, January 21, 2011 9:59 AM
Subject: RE: FormToEmail script


> Hi Charles and thank you for your fast reply.
>
> The 'validation' you mention is exactly what I need. Basically, I have a
> field called "Password" which will be a required field, and ideally I'd
> like
> about 10 different words (ie passwords) that I would like to be used to
> validate this field. Would this be OK?
>
> If you could help me set up this validation using "password01",
> "password02"
> etc, maybe I could then change this text when I know exactly what
> passwords
> will be used.
>
> If it helps, I do have the pro version too.
>
> If you need me to send you what I've done already, just let me know what
> to
> do and I'll do it ASAP.
>
> Many thanks again for your help with this.
>
> -----Original Message-----
> Sent: 20 January 2011 16:47
> Subject: Re: FormToEmail script
>
> Hi .
>
> Thank you for your question.
>
> Required fields are no problem. With FormToEmail-Pro you can state which
> fields are "required" fields. You can get it here:
>
> https://formtoemail.com/formtoemail_pro_version.php
>
> Such "required" fields must be completed or the form will not send.
>
> As for requiring specific information a field, you are talking about
> "validation" there. Due to a multitude of different customer requirements
> there isn't a facility in the script to set particular validation for a
> field.
>
> That said, I often help customers with little snippets of custom code. If
> you tell me what your requirements are for your password field, I will
> have
> a look at it for you.
>
> Any questions, just let me know.
>
> Best wishes.
>
> Charles Sweeney
> https://formtoemail.com
> The world's easiest feedback script!
>
> ----- Original Message -----
> Sent: Thursday, January 20, 2011 2:14 PM
> Subject: FormToEmail script
>
>
>>
>> Comments: Hi. I wish to have a required field on my form, but is there
>> any
>
>> way that I can specify what information is required within that field?
>> eg.
>
>> Can I have a required field called "Password", and then specify what text
>> can be used within this field? Ideally, what I'm after is a form that
>> will
>
>> only submit is the "Password" field is correctly entered. Many thanks.