php-general Digest 14 May 2008 08:46:23 -0000 Issue 5458

Topics (messages 274267 through 274289):

Re: validating textarea using php
        274267 by: Iv Ray
        274275 by: Shawn McKenzie
        274276 by: Richard Heyes
        274277 by: Dotan Cohen
        274281 by: Robert Cummings
        274286 by: Chris W

Re: A Little Something.
        274268 by: Thiago Pojda

fsockopen on ssl://
        274269 by: bob pilly
        274271 by: bob pilly
        274285 by: Manuel Lemos

Re: $_SESSION NOT WORKING
        274270 by: Daniel Brown
        274272 by: Thiago Pojda
        274273 by: Balpo
        274274 by: Jens Himmelrath

Re: tracking Mials Which were bounced.
        274278 by: Chris
        274279 by: mike

Re: Good XML Parser
        274280 by: Waynn Lue
        274284 by: Nathan Nobbe

Re: $_SESSION NOT WORKING --SOLVED
        274282 by: Balpo

Re: Can Safari 3 be forced to cache a large jpeg with PHP headers?
        274283 by: Chris
        274289 by: Colin Guthrie

validating using php
        274287 by: Sudhakar

form validation using php
        274288 by: Sudhakar

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Sudhakar wrote:
> i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.

From usability point of view such check will, in many cases, generate annoyance, and bring nothing.

If I do not want to enter anything, and you "error me" to enter "something", I'll do like this -

asdlöfjasdpoöfja spdfj as fsdaölkjf

And your check is dead. If you want "something", you will get "something".

It is hard (from usability point of view) to "validate" textarea to that extent, and especially - to get reasonable answers...

I work for a scientific database, where all content providers are very intelligent, well educated and very disciplined, and the content editors still have hard time thinking how to guide the content provider so that they provide reasonable input.

Your problem is not so much php related, but a usability and editorial one.

Iv

--- End Message ---
--- Begin Message ---
Dan Joseph wrote:
On Tue, May 13, 2008 at 12:02 PM, Usamah al-Amin <[EMAIL PROTECTED]>
wrote:

 if(chop($comments) == "") { ... }   //hope that helps.
Well, chop() is an alias of rtrim(), so it won't work here for, say,
trimming control characters at the end of the string like line feeds.

trim() is actually the best bit here.

Regards,
Usamah

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


There is always using substr to mimic the Perl chomp() function.  Look thru
the comments on http://us.php.net/chop and you'll find a few different ways
of doing it.

Or just use trim()  :-)

-Shawn

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
Richard Heyes wrote:
Also you can use short tags (popular...) to make the HTML more readable. Eg:

<textarea name="comments" cols="26" rows="3" id="comments">
    <?=htmlspecialchars($comments)?>
</textarea>


It also makes the code less portable.

If that's even a concern. A lot of the time, it's not.

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
|    http://www.phpguru.org/sftpdrive    |
+----------------------------------------+

--- End Message ---
--- Begin Message ---
2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
>> It also makes the code less portable.
>
> If that's even a concern. A lot of the time, it's not.
>

A lot of people think that, until their host upgrades php. Have you
seen how many things are being removed for php6?

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message ---
On Wed, 2008-05-14 at 00:32 +0300, Dotan Cohen wrote:
> 2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
> >> It also makes the code less portable.
> >
> > If that's even a concern. A lot of the time, it's not.
> >
> 
> A lot of people think that, until their host upgrades php. Have you
> seen how many things are being removed for php6?

PHP6??? Pshaw... PHP5 just came out the other week ;D

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
It also makes the code less portable.
If that's even a concern. A lot of the time, it's not.


A lot of people think that, until their host upgrades php. Have you
seen how many things are being removed for php6?

From the article I read, that isn't one of them.


--
Chris W
KE5GIX

"Protect your digital freedom and privacy, eliminate DRM,
learn more at http://www.defectivebydesign.org/what_is_drm";

Ham Radio Repeater Database.
http://hrrdb.com

--- End Message ---
--- Begin Message ---
Too bad I do not run that ;)

BTW it's in aspx... I'm not that insane.


Atenciosamente,

www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-----Mensagem original-----
De: Robert Cummings [mailto:[EMAIL PROTECTED] 
Enviada em: terça-feira, 13 de maio de 2008 15:51
Para: Thiago Pojda
Cc: [EMAIL PROTECTED]
Assunto: Re: RES: [PHP] Re: A Little Something.

On Tue, 2008-05-13 at 15:22 -0300, Thiago Pojda wrote:
> > Our neighbors all thought I had lost my mind
> 
> If they only knew you lost it long ago... ;)
> 
> Atenciosamente,
> 
> www.softpartech.com.br

I tried to hear your website... my screen reader had a lot of trouble :|

;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP





--- End Message ---
--- Begin Message ---
Hi all

I have tried researching this issue but havent come up with any solution so im 
hoping someone has seen it before and can help. I have the following test 
script that uses fsockopen to connect to a https site, get the contents and 
outputs it.

<?php
$host = "www.microsoft.com";
$path = "/";
$fh = fsockopen("ssl://".$host, 443, $errno, $errstr, 5);//opens url for 
reading with a timeout of 2 seconds

if (!$fh){
    echo "FAIL: $errno $errstr ";
}
else{
    $out = "GET $path HTTP/1.1\r\n";
    $out .= "Host: $host\r\n";
    $out .= "Connection: Close\r\n";
    $out .= "\r\n";
    fwrite($fh, $out);
    stream_set_timeout($fh,2);
    $info = stream_get_meta_data($fh);
    if($info['timed_out']){
        echo "TIMEOUT\n";
    }
    else{
        $haystack = "";
        while (!feof($fh)) {
            $haystack.= fgets($fh, 4096);
        }
    }
    print $haystack;
    fclose($fh);
}
?>

if i run this script using php -f test.php it works fine. However if i try and 
run this on my loca apache server i get the following error:

Warning:  fsockopen() [function.fsockopen]:unable to connect to 
ssl://www.microsoft.com:443 (A connection attemptfailed because the connected 
party did not properly respond after aperiod of time, or established connection 
failed because connected hosthas failed to respond.) in C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\test.php on line 4
FAIL: 10060 A connection attempt failed because the connected party didnot 
properly respond after a period of time, or established connectionfailed 
because connected host has failed to respond.

As you can see from that error i am using windows and apache 2.2. My php 
version is 5.25. I have Registered Stream Socket Transports tcp, udp, ssl, 
sslv3, sslv2, tlsin my config.

Thanks for any help in advance and it is greatly appreciated, this problem is 
driving me nuts!!

Cheers

Bob




      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

--- End Message ---
--- Begin Message ---
Hi all

I have tried researching this issue but havent come up with any solution so im 
hoping someone has seen it before and can help. I have the following test 
script that uses fsockopen to connect to a https site, get the contents and 
outputs it.

<?php
$host = "www.microsoft.com";
$path = "/";
$fh = fsockopen("ssl://".$host, 443, $errno, $errstr, 5);//opens url for 
reading with a timeout of 2 seconds

if (!$fh){
    echo "FAIL: $errno $errstr ";
}
else{
    $out = "GET $path HTTP/1.1\r\n";
    $out .= "Host: $host\r\n";
    $out .= "Connection: Close\r\n";
    $out .= "\r\n";
    fwrite($fh, $out);
    stream_set_timeout($fh,2);
    $info = stream_get_meta_data($fh);
    if($info['timed_out']){
        echo "TIMEOUT\n";
    }
    else{
        $haystack = "";
        while (!feof($fh)) {
            $haystack.= fgets($fh, 4096);
        }
    }
    print $haystack;
    fclose($fh);
}
?>

if i run this script using php -f test.php it works fine. However if i try and 
run this on my loca apache server i get the following error:

Warning:  fsockopen() [function.fsockopen]:unable to connect to 
ssl://www.microsoft.com:443 (A connection attemptfailed because the connected 
party did not properly respond after aperiod of time, or established connection 
failed because connected hosthas failed to respond.) in C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\test.php on line 4
FAIL: 10060 A connection attempt failed because the connected party didnot 
properly respond after a period of time, or established connectionfailed 
because connected host has failed to respond.

As you can see from that error i am using windows and apache 2.2. My php 
version is 5.25. I have Registered Stream Socket Transports tcp, udp, ssl, 
sslv3, sslv2, tlsin my config.

Thanks for any help in advance and it is greatly appreciated, this problem is 
driving me nuts!!

Cheers

Bob








      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

--- End Message ---
--- Begin Message ---
Hello,

on 05/13/2008 04:37 PM bob pilly said the following:
> Hi all
> 
> I have tried researching this issue but havent come up with any solution so 
> im hoping someone has seen it before and can help. I have the following test 
> script that uses fsockopen to connect to a https site, get the contents and 
> outputs it.
> 
> <?php
> $host = "www.microsoft.com";
> $path = "/";
> $fh = fsockopen("ssl://".$host, 443, $errno, $errstr, 5);//opens url for 
> reading with a timeout of 2 seconds
> 
> if (!$fh){
>     echo "FAIL: $errno $errstr ";
> }
> else{
>     $out = "GET $path HTTP/1.1\r\n";
>     $out .= "Host: $host\r\n";
>     $out .= "Connection: Close\r\n";
>     $out .= "\r\n";
>     fwrite($fh, $out);
>     stream_set_timeout($fh,2);
>     $info = stream_get_meta_data($fh);
>     if($info['timed_out']){
>         echo "TIMEOUT\n";
>     }
>     else{
>         $haystack = "";
>         while (!feof($fh)) {
>             $haystack.= fgets($fh, 4096);
>         }
>     }
>     print $haystack;
>     fclose($fh);
> }
> ?>
> 
> if i run this script using php -f test.php it works fine. However if i try 
> and run this on my loca apache server i get the following error:
> 
> Warning:  fsockopen() [function.fsockopen]:unable to connect to 
> ssl://www.microsoft.com:443 (A connection attemptfailed because the connected 
> party did not properly respond after aperiod of time, or established 
> connection failed because connected hosthas failed to respond.) in C:\Program 
> Files\Apache Software Foundation\Apache2.2\htdocs\test.php on line 4
> FAIL: 10060 A connection attempt failed because the connected party didnot 
> properly respond after a period of time, or established connectionfailed 
> because connected host has failed to respond.
> 
> As you can see from that error i am using windows and apache 2.2. My php 
> version is 5.25. I have Registered Stream Socket Transports tcp, udp, ssl, 
> sslv3, sslv2, tlsin my config.

I suspect that you are giving a very short timeout but then you are not
handling the timeout error properly.

Anyway, before reinventing the wheel, you may to try this HTTP client
class that supports many options including establishing SSL corrections
and setting and handling timeouts correctly.

http://www.phpclasses.org/httpclient

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
On Tue, May 13, 2008 at 2:38 PM, Balpo <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>  I'm having a problem moving my code to a linux computer.
>  I won't post the whole code here, but an accurate example that reproduces
> exactly the error.
[snip!]

    Modify 2.php as follows:

<?php
session_start();
print_r($_SESSION);
?>

    You only missed instantiating the session.  The rest looks good.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
Actually his question was about why session.auto_start is not working on
Linux, I almost answered what you both did :)


Atenciosamente,

www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-----Mensagem original-----
De: Daniel Brown [mailto:[EMAIL PROTECTED] 
Enviada em: terça-feira, 13 de maio de 2008 16:43
Para: Balpo
Cc: PHP General
Assunto: Re: [PHP] $_SESSION NOT WORKING

On Tue, May 13, 2008 at 2:38 PM, Balpo <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>  I'm having a problem moving my code to a linux computer.
>  I won't post the whole code here, but an accurate example that reproduces
> exactly the error.
[snip!]

    Modify 2.php as follows:

<?php
session_start();
print_r($_SESSION);
?>

    You only missed instantiating the session.  The rest looks good.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--- End Message ---
--- Begin Message ---
Yes, that way it works. Thanx.
But the Windows version of the same code and the same php.ini ***does not *** need the session_start()
because it has the session.auto_start = 1 inside php.ini.

The thing is,  I think session.auto_start = 1 does not work on Linux.

Is this a bug?

Daniel Brown wrote:
On Tue, May 13, 2008 at 2:38 PM, Balpo <[EMAIL PROTECTED]> wrote:
Hi everyone,
 I'm having a problem moving my code to a linux computer.
 I won't post the whole code here, but an accurate example that reproduces
exactly the error.
[snip!]

    Modify 2.php as follows:

<?php
session_start();
print_r($_SESSION);
?>

    You only missed instantiating the session.  The rest looks good.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


--- End Message ---
--- Begin Message ---
Balpo schrieb:
>> Hi everyone, I'm having a problem moving my code to a linux 
>> computer. I won't post the whole code here, but an accurate example
>>  that reproduces exactly the error.
>> 
>> //************************ 1.php <?php session_register('tree'); 
>> $_SESSION['tree'] = "This is tree number one"; header("Location:
>> 2.php"); ?>
>> 
>> //************************ 2.php <?php print_r($_SESSION, false); 
>> ?>
>> 
>> session.auto_start = 1
>> 
>> I want to know why session.auto_start does not work on Linux.
>> 
>> If you require the whole php.ini, I'll send it gladly

Hi!

Did you test with phpinfo() if the correct php.ini is used?

regards,
Jens


--- End Message ---
--- Begin Message ---
mike wrote:
> Seems like the general way is to create a mailbox (POP3 or IMAP) to
> accept the bounces, then check it periodically and mark the emails as
> invalid in your local database.
> 
> I would set threshholds so you don't mark something failed that only
> bounced once - it could have been a mail setup error or something
> else; I'd say wait for 3 failures in a 7 day period at least. If you
> get 3 bounces by that point, the address is probably safely dead.
> 
> You can use PHP's IMAP functions to check the mailbox (even for POP3)
> or a million classes or your own functions directly on the socket
> (POP3 is a simple protocol) - it also helps if you parse the bounced
> email message to process the return address and the mail code; perhaps
> build something better than just 3 failures = invalid, but actually
> determine if they're full out failures, or if they're just temporary
> bounces, etc.

I use this method and it works reasonably well. The hard part is the
last sentence - there are so many ways to say "mailbox full" - half
don't include smtp error codes, the rest tell you the same thing in
thousands of different ways.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On 5/13/08, Chris <[EMAIL PROTECTED]> wrote:

> I use this method and it works reasonably well. The hard part is the
> last sentence - there are so many ways to say "mailbox full" - half
> don't include smtp error codes, the rest tell you the same thing in
> thousands of different ways.

exactly. that's why i try to make it spread out - if there's failures
for 7 days, odds are that email account is dead/unused. worst case you
lose one person on your mailing list who doesn't check their email
often enough to be worthwhile :)

--- End Message ---
--- Begin Message ---
Ok, thanks so much for the help.  I went with DOM-parsing to begin
with, I'll explore XPath + SimpleXML later.

Thanks,
Waynn

On Mon, May 12, 2008 at 5:23 AM, David Otton
<[EMAIL PROTECTED]> wrote:
> 2008/5/12 Waynn Lue <[EMAIL PROTECTED]>:
>> So if I'm looking to parse certain attributes out of an XML tree, if I
>> use SAX, it seems that I would need to keep track of state internally.
>>  E.g., if I have a tree like
>>
>> <head>
>>  <a>
>>   <b></b>
>>  </a>
>>  <a>
>>    <b></b>
>>  </a>
>> </head>
>>
>> and say I'm interested in all that's between <b> underneath any <a>,
>> I'd need to have a state machine that looked for an <a> followed by a
>> <b>.  If I'm doing that, though, it seems like I should just start
>> using a DOM parser instead?
>
> Yeah, I think you've got it nailed, although your example is simple
> enough (you're only holding one state value - "am I a child of <a>?")
> that I'd probably still reflexively reach for the lightweight
> solution). I use SAX for lightweight hacks, one step up from regexes -
> I know the information I want is between <tag> and </tag>, and I don't
> care about the rest of the document. The more I need to navigate the
> document, the more likely I am to use DOM. I could build my own data
> structures on top of a SAX parser, but why bother reinventing the
> wheel? Of course, you have to factor document size into that - parsing
> a big XML document into a tree can be slow.
>
> You might also want to explore XPath
> (http://uk.php.net/manual/en/function.simplexml-element-xpath.php
> http://uk.php.net/manual/en/class.domxpath.php)... XPath is to XML as
> Regexes are to text files. There's a good chance you'll be able to
> roll all your parsing up into a couple of XPath queries.
>
> I probably should have added that simple parsers come in two flavours
> - Push Parsers and Pull Parsers. I tend to think (lazily) of Push and
> Pull as variations on SAX, but strictly speaking they are different.
>

--- End Message ---
--- Begin Message ---
On Tue, May 13, 2008 at 7:29 PM, Waynn Lue <[EMAIL PROTECTED]> wrote:

> Ok, thanks so much for the help.  I went with DOM-parsing to begin
> with, I'll explore XPath + SimpleXML later.


just fyi, youre likely to get more bang for your buck starting off w/
SimpleXML.  DOM is a successor to DOMXML from php4.  its a bulky, yet
powerful interface into the DOM.  SimpleXML is also a DOM parser, however
the interface is simpler in exchange for less power.  the good news is in
php5 you can switch back and for between DOM and SimpleXML easily at
virtually no cost.

my modo in php5 is to use SimpleXML unless there is a real need for DOM, and
in that case most likey, you can get away w/ converting to DOM at runtime
(again very little cost there) and doing a few operations, then carrying on
w/ SimpleXML.

-nathan

--- End Message ---
--- Begin Message ---
After an all-evening debugging I found out what the problem is.

Why? Please don't ask. I have no idea.

The problem was php's extension php-colorer

How I got to the problem. Eliminating every extension until I got the *bad* one.

Thank you: Daniel, Thiago,  Jens, Verny & Dmitri for your concern.

Balpo

Thiago Pojda wrote:
Actually his question was about why session.auto_start is not working on
Linux, I almost answered what you both did :)


Atenciosamente,

www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-----Mensagem original-----
De: Daniel Brown [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 13 de maio de 2008 16:43
Para: Balpo
Cc: PHP General
Assunto: Re: [PHP] $_SESSION NOT WORKING

On Tue, May 13, 2008 at 2:38 PM, Balpo <[EMAIL PROTECTED]> wrote:
Hi everyone,
 I'm having a problem moving my code to a linux computer.
 I won't post the whole code here, but an accurate example that reproduces
exactly the error.
[snip!]

    Modify 2.php as follows:

<?php
session_start();
print_r($_SESSION);
?>

    You only missed instantiating the session.  The rest looks good.


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


--- End Message ---
--- Begin Message ---
Rob Gould wrote:
> I am creating a touch-screen kiosk application, using a full-screen version 
> of Safari 3.1, and was wondering if there's a way I can force Safari to cache 
> a large background image JPEG.  
> 
> What I'm finding is that Safari 3 will sometimes cache my large 1.1 MB 
> background image (1680x1050), and display perfectly fine, but on occassion 
> Safari 3  will "think about the cache" and Flash the screen white for a 
> millisecond and then draw the screen.  Firefox doesn't seem to have this 
> problem, so unfortunately this is a Safari 3 only issue.
> 
> I really only want to cache this ONE image - - - nothing else.  Is that 
> possible?

How are you sending it? through a php script or through a normal html tag?

If it's through a php script, try setting a far-future expiry header.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Chris wrote:
Rob Gould wrote:
I am creating a touch-screen kiosk application, using a full-screen version of Safari 3.1, and was wondering if there's a way I can force Safari to cache a large background image JPEG.
What I'm finding is that Safari 3 will sometimes cache my large 1.1 MB background image 
(1680x1050), and display perfectly fine, but on occassion Safari 3  will "think 
about the cache" and Flash the screen white for a millisecond and then draw the 
screen.  Firefox doesn't seem to have this problem, so unfortunately this is a Safari 3 
only issue.

I really only want to cache this ONE image - - - nothing else.  Is that 
possible?

How are you sending it? through a php script or through a normal html tag?

If it's through a php script, try setting a far-future expiry header.

Yeah PHP can send out appropriate headers to tell the browser to cache the content delivered. You just use header() with appropriate Cache-Control and Pragma etc. headers. There are lots of good resources out there on how to do this so just google around now you know the concept :)

Col


--- End Message ---
--- Begin Message ---
thanks to everyone for providing the solution for validating textarea using
php i have used the following and it worked

$add = trim($_POST["add"]);

if(strlen(trim($add)) == 0 )
{
$error.="<br>Please enter your address ";
}


as part of the form the user has to fill in their name, assuming if the user
simply presses the space bar i would like to display a message like the text
area. presently my validation for name is

$name = trim($_POST["name"]);

if( strlen(trim($name) == 0 ) || !preg_match('/^[a-zA-Z ]+$/x', $name) )
{
$error.="Name is blank or has special characters ";
}

with the above code for validating the name if a user types only spaces then
the error message is displayed however if there is a gap in the name example
john smith the error message is appearing which should not be happening as i
have given
preg_match('/^[a-zA-Z ]+$/x', $name) which means the user can type small,
upper case letters and also there can be a space in the name

how can i change the php code = if( strlen(trim($name) == 0 ) ||
!preg_match('/^[a-zA-Z ]+$/x', $name) )

so that i can validate both a) blank spaces and also accept spaces between
the name, i can validate individually for spaces and uses preg_match as 2
separate lines, instead i would like to validate in a single line of php

please advice.

thanks.

--- End Message ---
--- Begin Message ---
hi

i need to validate a field in a form where a user enters their lodgement
number as part of a registration form. this lodgement number can have
letters, numbers, spaces and special characters. i do not know exactly what
those special characters are, so do i have to define the type of special
characters and validate accordingly.

presently my php code for validating the lodgement number is

$lodgementtf  = $_POST["lodgementtf"];

if($lodgementtf == "" || !preg_match("/^[a-zA-Z0-9_ <]+$/", $lodgementtf) )

{
echo "display error message":
}

i also have another way of validating

if($lodgementnumber == "" || !preg_match("/^[a-zA-Z0-9_ [EMAIL 
PROTECTED]&*()]+$/",
$lodgementnumber) )

does this mean that the special characters can only be = a space AND
[EMAIL PROTECTED]&*() and no other special characters.

please advice.

thanks.

--- End Message ---

Reply via email to