473,382 Members | 1,238 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,382 software developers and data experts.

Array small question

I need help in a small problem,
I have created a registration form and I want my users not leave the
username empty or even enter any number of spaces because sometimes I
found that the users enter some space hits in the username and the
form is submitted, so I created an array and tried to enter the spaces
but I don't know how to make my code reject any spaces whatever their
number and I failed doing this, and what I did was that I entered in
an array the user-names I reserve for later use and space, two-spaces,
three-spaces, four-spaces, ........... but I was exhausted so please
could you tell me how to solve this and do it in a professional way.

shror

Oct 4 '07 #1
2 1259
On Thu, 04 Oct 2007 09:44:51 +0200, shror <sh******@gmail.comwrote:
I need help in a small problem,
I have created a registration form and I want my users not leave the
username empty or even enter any number of spaces because sometimes I
found that the users enter some space hits in the username and the
form is submitted, so I created an array and tried to enter the spaces
but I don't know how to make my code reject any spaces whatever their
number and I failed doing this, and what I did was that I entered in
an array the user-names I reserve for later use and space, two-spaces,
three-spaces, four-spaces, ........... but I was exhausted so please
could you tell me how to solve this and do it in a professional way.
http://www.php.net/trim

//trim whitespace surrounding the string
$string = trim($string);
//check for empty string
if(!empty($string)){
//do your thing
} else {
echo 'Please enter a username';
}
--
Rik Wasmus
Oct 4 '07 #2
On Oct 4, 9:48 am, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Thu, 04 Oct 2007 09:44:51 +0200, shror <shahi...@gmail.comwrote:
I need help in a small problem,
I have created a registration form and I want my users not leave the
username empty or even enter any number of spaces because sometimes I
found that the users enter some space hits in the username and the
form is submitted, so I created an array and tried to enter the spaces
but I don't know how to make my code reject any spaces whatever their
number and I failed doing this, and what I did was that I entered in
an array the user-names I reserve for later use and space, two-spaces,
three-spaces, four-spaces, ........... but I was exhausted so please
could you tell me how to solve this and do it in a professional way.

http://www.php.net/trim

//trim whitespace surrounding the string
$string = trim($string);
//check for empty string
if(!empty($string)){
//do your thing} else {

echo 'Please enter a username';}

--
Rik Wasmus
thank you so much Rik for your help

Oct 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Marco | last post by:
Hi all, I have a base class and some subclasses; I need to define an array of objects from these various subclasses. What I have is something like: { //I have a base class, something like:...
2
by: J. J. Cale | last post by:
In IE6 both these functions *seem* to be working. I don't see much recursion in this group except the occasional setTimeout problems. Besides the obvious stack problems that can occur if one...
32
by: Carson | last post by:
Hi , Is there a very efficient way to set a double array to 0 ? (I have tried memset, but the result doesn't look correct.) Carson
3
by: Pol Bawin | last post by:
Hi All, One : I have a property that get/set a array of an abstract class A By default my array is null In the propertygrid, It is not works correctly when my array is null. (when my array...
3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
14
by: abhi147 | last post by:
Hi , I want to convert an array of bytes like : {79,104,-37,-66,24,123,30,-26,-99,-8,80,-38,19,14,-127,-3} into Unicode character with ISO-8859-1 standard. Can anyone help me .. how should...
15
by: Mik0b0 | last post by:
Hallo everybody, my problem is: there are two single-dimension arrays, longer and shorter, every array is organized in ascending order. We need to build a new array out of two. This is what I...
1
by: Richard Harter | last post by:
On Fri, 27 Jun 2008 09:28:56 -0700 (PDT), pereges <Broli00@gmail.comwrote: There are some obvious questions that should be asked, e.g., is the contents of your array already sorted as your...
5
by: Immortal Nephi | last post by:
I would like to design an object using class. How can this class contain 10 member functions. Put 10 member functions into member function pointer array. One member function uses switch to call...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.