473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Writing a condition for a variable which stores text

3
I have a form for registering. Am trying to prevent the person from entering too much of text for username and password but getting an error.

my code is:

Expand|Select|Wrap|Line Numbers
  1. $uLength = strlen($regusername);
  2. $pLength = strlen($regpassword);
  3. if ($uLength >= 7 && $uLength <= 20)
  4.     {
  5.     $errorMessage = "";
  6.     }
  7. else 
  8.     {
  9.     $errorMessage = $errorMessage."Username must be between 7 and 20 characters"."<br/>";
  10.     }
  11.  
  12. if ($pLength >= 6 && $pLength <= 15)
  13.     {
  14.     $errorMessage = "";
  15.     }
  16. else 
  17.     {
  18.     $errorMessage = $errorMessage."Password must be between 6 and 15 characters"."<br/>";
  19.     }
am getting an error on this line saying undeclared variable...

$errorMessage = $errorMessage."Username must be between 7 and 20 characters"."<br/>";


Can you please help me out? Will be very thankful :)
Nov 7 '12 #1
4 1392
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

It's a fairly clear error message. You need to declare the variable before trying to use it.
Nov 7 '12 #2
nitz06
3
how do I declare it? because after this code am using it in a condition like if $errorMessage is blank then do this or else this. But am confused on how to declare the variable "$errorMessage". I looked for it on the net but got more confused as to different answers. Please help me :)
Nov 8 '12 #3
Dormilich
8,658 Expert Mod 8TB
Am trying to prevent the person from entering too much of text for username and password
use the HTML attribute maxlength.
Nov 8 '12 #4
nitz06
3
thanks for the replies... my code works now but I used some other codes.. neway thanks
Nov 8 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: nescio | last post by:
hello, i have a page called 'a.php'. on this page is a form with a textfield and a link. if you click the link an pop up opens. in this pop up is an number visible with a link. what i want...
5
by: Michelle A. | last post by:
I have a four page form. Pages 1-3 stores there information in a session variables. Page four is reached (a final review page) and then the information will be written to the SQL server. When...
2
by: Tony | last post by:
Yes, I need to specify a font type so that the characters will be evenly spaced when I write to a tab delimited text file. So how does one specify a font type to write/print and which font is...
24
by: Agnes | last post by:
my date format is in yyyy-mm-dd mycommandtext is 'select * from myTable where issuedate >='" & Me.txtStartDate.text & "' and issuedate <= '" & Me.txtEndDate.text & "' " It return zero records,...
1
by: ChrisFrohlich | last post by:
ASP.NET 2.0 with Text DataTypes: I've got a similar question going in the SQL group, but I was wondering if anyone has successfully implemented reading/writing character data from a Text datatype...
4
by: Mike - EMAIL IGNORED | last post by:
In a Posix compliant multi-threaded C++ program, I would like to use sigaction() to catch SIGTERM, and from my signal handler, lock a mutex, and broadcast a condition variable. Is this ok? ...
5
by: rjddude1 | last post by:
Well I know how to pass value of an item from drop down list to a text box, but this ones different. I'm very new to javascript and have no idea how to pass value calculated variable into a text box....
3
by: Pandiankk | last post by:
Hello, I am having a performance issue with one of my C#.NET console application. The application is faster(takes 10 mins) when it runs from our test environment, but slower on Production...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.