Re: [PHP] Validate if the field of a form is empty

2010-07-13 Thread te0t3l
It works fine for me,

foreach ( $_FILES['archivo']['name'] as $file ) {
   //echo $file;
}
if($file == ){
echo empty;
}else{
   //continue...
}

Thanks a lot Jim!

Te0


[PHP] Validate if the field of a form is empty

2010-07-12 Thread te0t3l
Hi, I need to validate a field that work with Multifile plugin of Jquery,
I want to check if the field is empty with php.

[code]
input name=archivo[] class=multi type=file accept=gif|jpg|png/
input name=button type=submit value=Submit
[code]

I've tried different ways but it does not work:
for example:
$field = $_FILES[archivo][name];
$field = $_FILES[archivo[]][name];

i dont know how to validate it, any help would be appreciated.

Thanks,


Re: [PHP] Validate if the field of a form is empty

2010-07-12 Thread Jim Lucas
te0t3l wrote:
 Hi, I need to validate a field that work with Multifile plugin of Jquery,
 I want to check if the field is empty with php.
 
 [code]
 input name=archivo[] class=multi type=file accept=gif|jpg|png/
 input name=button type=submit value=Submit
 [code]
 
 I've tried different ways but it does not work:
 for example:
 $field = $_FILES[archivo][name];
 $field = $_FILES[archivo[]][name];
 
 i dont know how to validate it, any help would be appreciated.
 
 Thanks,
 

To see what is happening, look at the output of print_r($_FILES);

But, you should be doing it like this.

foreach ( $_FILES[archivo] AS $file ) {
  $field = $file['name'];
  ...
}


-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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



[PHP] [PHP]: php validate user password

2009-02-09 Thread Andrew Williams
Hi,

Can some body help out on how to validate user password from the database?

Thanks
Andrew


Re: [PHP] [PHP]: php validate user password

2009-02-09 Thread Jan G.B.
2009/2/9 Andrew Williams andrew4willi...@gmail.com:
 Hi,


Hi,
 Can some body help out on how to validate user password from the database?

There are several possibilities. This would be one.
?
$query = 'SELECT 1 from `usertable` where `name` = ' .
mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE)
  . ' AND `pass` = md5(' .
mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE) .
');';
?



 Thanks
 Andrew


Bye,bye

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



[PHP] php validate user password

2009-02-09 Thread Michael Kubler
These days SHA should really be used instead of MD5, and you should be 
SALTing the password as well.

Here's a great guide : http://phpsec.org/articles/2005/password-hashing.html

Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



Jan G.B. wrote:

2009/2/9 Andrew Williams andrew4willi...@gmail.com:
  


Can some body help out on how to validate user password from the database?



There are several possibilities. This would be one.
?
$query = 'SELECT 1 from `usertable` where `name` = ' .
mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE)
  . ' AND `pass` = md5(' .
mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE) .
');';
?


  


Re: [PHP] php validate user password

2009-02-09 Thread Stuart
2009/2/9 Michael Kubler mdk...@gmail.com:
 These days SHA should really be used instead of MD5, and you should be
 SALTing the password as well.
 Here's a great guide : http://phpsec.org/articles/2005/password-hashing.html

Good advice. I would also advise against stripping and trimming
anything from passwords. By removing characters you're significantly
reducing the number of possible passwords.

-Stuart

 Jan G.B. wrote:

 2009/2/9 Andrew Williams andrew4willi...@gmail.com:


 Can some body help out on how to validate user password from the
 database?


 There are several possibilities. This would be one.
 ?
 $query = 'SELECT 1 from `usertable` where `name` = ' .
 mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE)
  . ' AND `pass` = md5(' .
 mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE) .
 ');';
 ?

-- 
http://stut.net/

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



Re: [PHP] php validate user password

2009-02-09 Thread Jan G.B.
2009/2/9 Stuart stut...@gmail.com:
 2009/2/9 Michael Kubler mdk...@gmail.com:
 These days SHA should really be used instead of MD5, and you should be
 SALTing the password as well.
 Here's a great guide : http://phpsec.org/articles/2005/password-hashing.html

 Good advice.

Absolutley. I used mysqls md5() function only as an example.

 I would also advise against stripping and trimming
 anything from passwords. By removing characters you're significantly
 reducing the number of possible passwords.

Surely, the stripping should only be done when when magic_quotes is
enabled! (e.g. Your Server makes \' out of ').
Trimming could be left out but it minimizes user errors and users
pretending to know their password.
(Like copy/paste from a passwords-file with added spaces on the end, etc..)

Regards

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



Re: [PHP] php validate user password

2009-02-09 Thread Stuart
2009/2/9 Jan G.B. ro0ot.w...@googlemail.com:
 2009/2/9 Stuart stut...@gmail.com:
 I would also advise against stripping and trimming
 anything from passwords. By removing characters you're significantly
 reducing the number of possible passwords.

 Surely, the stripping should only be done when when magic_quotes is
 enabled! (e.g. Your Server makes \' out of ').

If you have this option switched on on your server you really need to
do everything you can to get rid of it. It's evil and has been
completely removed from PHP 6. But yes, if you're stuck with it then
you need to strip them before storage, but the poster did not make
that clear.

 Trimming could be left out but it minimizes user errors and users
 pretending to know their password.
 (Like copy/paste from a passwords-file with added spaces on the end, etc..)

Not sure what you mean by users pretending to know their password, but
if I put a space at the start or end of my password I would expect
that to add to its complexity and make it harder to guess. By
stripping it you're not doing anyone any favours.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] php validate user password

2009-02-09 Thread tedd

At 2:02 PM + 2/9/09, Stuart wrote:

2009/2/9 Michael Kubler mdk...@gmail.com:

 These days SHA should really be used instead of MD5, and you should be
 SALTing the password as well.
 Here's a great guide : http://phpsec.org/articles/2005/password-hashing.html


Good advice. I would also advise against stripping and trimming
anything from passwords. By removing characters you're significantly
reducing the number of possible passwords.


I read the article and didn't find any objection to it, but before we 
all jump on the SHA bus, why can't we do this:


1. Allow the user to pick whatever password they want.

2. After entry, add a token string to it, such as 'a14fmw9'.

3. Do a M5() hash and store the hash the dB.

When the user wants to log back in:

1. They enter their password.

2. We add the token string ('a14fmw9') to it.

3. Then we M5() the string and compare that hash with what's stored. 
That will work.


Furthermore, if the token string is stored in the script, or in a 
configuration file, and not in the database (as suggested by the 
author), then if someone obtains access to the database, all the 
dictionary and other such brute force attacks will be more difficult 
because the hashes are more complex than one would normally expect, 
right?


If not so, then where am I wrong?

Another scheme would be simply to use the user's password and 
generate a hash. Then reverse the users password and generate another 
hash. Then shuffle the two hashes, or take pairs, or quads, or any 
number of other techniques to obscure the hash. As long at the 
process can be reversed, it will work.


From my limited view, a minor amount of work can throw a major monkey 
wrench in any method of trying to crack a hash -- am I wrong?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php validate user password

2009-02-09 Thread Bruno Fajardo
tedd,

I think that the problem of the duplicated hashes in the database
(in the case of two users using the same password) persists with a
constant prefix in the passwords. Although the random salt portion get
stored in the database concatenated to the hash, the attacker don't
know the string length of the salt, making the attack very difficult.

Cheers

2009/2/9 tedd tedd.sperl...@gmail.com:
 At 2:02 PM + 2/9/09, Stuart wrote:

 2009/2/9 Michael Kubler mdk...@gmail.com:

  These days SHA should really be used instead of MD5, and you should be
  SALTing the password as well.
  Here's a great guide :
 http://phpsec.org/articles/2005/password-hashing.html

 Good advice. I would also advise against stripping and trimming
 anything from passwords. By removing characters you're significantly
 reducing the number of possible passwords.

 I read the article and didn't find any objection to it, but before we all
 jump on the SHA bus, why can't we do this:

 1. Allow the user to pick whatever password they want.

 2. After entry, add a token string to it, such as 'a14fmw9'.

 3. Do a M5() hash and store the hash the dB.

 When the user wants to log back in:

 1. They enter their password.

 2. We add the token string ('a14fmw9') to it.

 3. Then we M5() the string and compare that hash with what's stored. That
 will work.

 Furthermore, if the token string is stored in the script, or in a
 configuration file, and not in the database (as suggested by the author),
 then if someone obtains access to the database, all the dictionary and other
 such brute force attacks will be more difficult because the hashes are more
 complex than one would normally expect, right?

 If not so, then where am I wrong?

 Another scheme would be simply to use the user's password and generate a
 hash. Then reverse the users password and generate another hash. Then
 shuffle the two hashes, or take pairs, or quads, or any number of other
 techniques to obscure the hash. As long at the process can be reversed, it
 will work.

 From my limited view, a minor amount of work can throw a major monkey wrench
 in any method of trying to crack a hash -- am I wrong?

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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



Re: [PHP] php validate user password

2009-02-09 Thread tedd

At 12:20 PM -0300 2/9/09, Bruno Fajardo wrote:

tedd,

I think that the problem of the duplicated hashes in the database
(in the case of two users using the same password) persists with a
constant prefix in the passwords. Although the random salt portion get
stored in the database concatenated to the hash, the attacker don't
know the string length of the salt, making the attack very difficult.



I've seen many duplicate password hashes in databases. Get a user 
number in the thousands and it's almost certain you'll have duplicate 
passwords. People just cannot create unique passwords.


The article discussed using a random salt to avoid this, I got the message.

I was just saying that even if there are duplicates, that doesn't 
make solving the hash any easier -- it just focuses the attention of 
the cracker to those duplicates. In some cases, I could see that as 
another way to foil a cracker by deliberately having those records in 
a database without a solution.


For example, I could have a duplicate hash appear five times in a 5K 
population -- that certainly would become a focus for a cracker. 
However, I could also have my code looking for that hash and never 
provide a solution regardless of what the cracker does -- do you see 
what I mean?


Granted, there are things here that are above my head -- I am not 
passing myself off as an expert but rather as someone proposing ideas 
to see if they pass or fail.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] php validate user password

2009-02-09 Thread Boyd, Todd M.
 -Original Message-
 From: tedd [mailto:tedd.sperl...@gmail.com]
 Sent: Monday, February 09, 2009 10:30 AM
 To: Bruno Fajardo
 Cc: PHP General
 Subject: Re: [PHP] php validate user password
 
 At 12:20 PM -0300 2/9/09, Bruno Fajardo wrote:
 tedd,
 
 I think that the problem of the duplicated hashes in the database
 (in the case of two users using the same password) persists with a
 constant prefix in the passwords. Although the random salt portion
get
 stored in the database concatenated to the hash, the attacker don't
 know the string length of the salt, making the attack very difficult.
 
 
 I've seen many duplicate password hashes in databases. Get a user
 number in the thousands and it's almost certain you'll have duplicate
 passwords. People just cannot create unique passwords.
 
 The article discussed using a random salt to avoid this, I got the
 message.
 
 I was just saying that even if there are duplicates, that doesn't
 make solving the hash any easier -- it just focuses the attention of
 the cracker to those duplicates. In some cases, I could see that as
 another way to foil a cracker by deliberately having those records in
 a database without a solution.
 
 For example, I could have a duplicate hash appear five times in a 5K
 population -- that certainly would become a focus for a cracker.
 However, I could also have my code looking for that hash and never
 provide a solution regardless of what the cracker does -- do you see
 what I mean?
 
 Granted, there are things here that are above my head -- I am not
 passing myself off as an expert but rather as someone proposing ideas
 to see if they pass or fail.

I don't think Security By Obscurity gets a fair shake anymore in
today's security world. Sure, it would be horrible to employ it
exclusively, but I think the added layer of abstraction that comes along
with it is a wonderful benefit to any application's security procedures.

The salt itself could be considered security by obscurity, since it is
being passed through the same algorithm as what you're hashing to begin
with. This might be a stretch, though. :)

I say, Huzzah, tedd. Good idea.

Hash + Obscurity  Hash + Nothing


// Todd

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



RE: [PHP] php validate user password

2009-02-09 Thread tedd

At 10:41 AM -0600 2/9/09, Boyd, Todd M. wrote:

  -Original Message-
  From: tedd [mailto:tedd.sperl...@gmail.com]

  Granted, there are things here that are above my head -- I am not

 passing myself off as an expert but rather as someone proposing ideas
 to see if they pass or fail.


I don't think Security By Obscurity gets a fair shake anymore in
today's security world. Sure, it would be horrible to employ it
exclusively, but I think the added layer of abstraction that comes along
with it is a wonderful benefit to any application's security procedures.

The salt itself could be considered security by obscurity, since it is
being passed through the same algorithm as what you're hashing to begin
with. This might be a stretch, though. :)

I say, Huzzah, tedd. Good idea.

Hash + Obscurity  Hash + Nothing


I understand, but a hash is nothing more than an algorithm. An 
algorithm is nothing more that a standardized way of doing something 
-- it's the same as a function.


If I add a suffix, or prefix, to a password and use that, it's just 
another step in the algorithm process. I have not obscured the 
process, I've just added another step to it.


Over the years I have seen all sorts of ways to transmit data from 
one point to another, and that's really what we are doing here. We 
are just trying to protect the data from when it's exposed to a third 
party. There are many ways to do that.


I think the MD5() hash is a pretty good way and if the weakness is 
the user's lack of uniqueness in determining their passwords, then we 
can focus on that problem instead of looking to another hash. And 
besides, the solution presented was to create a salt and use that -- 
that's just another step in the algorithm process not much different 
than what I propose.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php validate user password

2009-02-09 Thread Jan G.B.
2009/2/9 Stuart stut...@gmail.com:
 2009/2/9 Jan G.B. ro0ot.w...@googlemail.com:
 2009/2/9 Stuart stut...@gmail.com:
 I would also advise against stripping and trimming
 anything from passwords.

 Trimming could be left out but it minimizes user errors and users
 pretending to know their password.
 (Like copy/paste from a passwords-file with added spaces on the end, etc..)

 Not sure what you mean by users pretending to know their password,

Well, as soon as you come into contact with the support team of a
quite big online store/community or so, you will see that there are
trillions of users pretending stuff you couldn't ever think of
before.. these people have the PEBCAK-Syndrome.. But that's quite
offtopic ..here.  :-)

But I must admit - as a power user you would expect that whitespace
as a suffix or prefix would not be stripped.

Regards

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



Re: [PHP] php validate user password

2009-02-09 Thread Micah Gersten
onlist this time...

tedd wrote:

  snip
 
  I think the MD5() hash is a pretty good way and if the weakness is the
  user's lack of uniqueness in determining their passwords, then we can
  focus on that problem instead of looking to another hash. And besides,
  the solution presented was to create a salt and use that -- that's
  just another step in the algorithm process not much different than
  what I propose.
 
  Cheers,
 
  tedd
 
   

The MD5 hash IS the problem.  The problem isn't the uniqueness of the
passwords, but rather the uniqueness of the hash. The solution is to use
another hash that does not have the same collision issues.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] php validate user password

2009-02-09 Thread Bruno Fajardo
Or, like the article suggested, a random portion for the hash... I
agree with you, Micah. The hash collision is a problem, and must be
avoided.
Same password hashes for different users are very good candidates for
a dictionary attack. Probably, in most of this cases, users picked
easy passwords, like 1234 or admin.

Cheers

2009/2/9 Micah Gersten mi...@onshore.com

 onlist this time...

 tedd wrote:

   snip
  
   I think the MD5() hash is a pretty good way and if the weakness is the
   user's lack of uniqueness in determining their passwords, then we can
   focus on that problem instead of looking to another hash. And besides,
   the solution presented was to create a salt and use that -- that's
   just another step in the algorithm process not much different than
   what I propose.
  
   Cheers,
  
   tedd
  
 

 The MD5 hash IS the problem.  The problem isn't the uniqueness of the
 passwords, but rather the uniqueness of the hash. The solution is to use
 another hash that does not have the same collision issues.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com




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




--
Bruno Fajardo - Desenvolvimento
bruno.faja...@dinamize.com - www.dinamize.com
Dinamize RS - Porto Alegre-RS - CEP 90420-111
Fones (51) 3027 7158 / 8209 4181 - Fax (51) 3027 7150

Dinamize BA - Lauro de Freitas - Fone 71 3379.7830
Dinamize SC - Joinville - Fone 47 3025.1182
Dinamize DF - Asa Norte - Brasília - Fone 61 3274.1172
Dinamize SP - São Paulo - Fone 11 6824.6250
Dinamize PR - Curitiba - Fone 41 3306.4388
Dinamize RS - Caxias do Sul - Fone 54 3533.4333
Dinamize RJ - Rio de Janeiro - Fone 21 2169.6311

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



[PHP] validate + if

2008-02-23 Thread Emiliano Boragina
Hi list!

 

I have a form.

I validated it with javascript.

Do the validation, but send the form information.

How can I prevent send the information and stay in the form?

When validate all correctly send the info, but if the form isn’t complete
correctly don’t send.

 

Thanks!

 

+  _
   // Emiliano Boragina _

   // Diseño  Comunicación //
+  _

   // [EMAIL PROTECTED]  /
   // 15 40 58 60 02 ///
+  _

 



RE: [PHP] validate + if

2008-02-23 Thread Bastien Koert

 From: [EMAIL PROTECTED] To: php-general@lists.php.net Date: Sat, 23 Feb 
 2008 16:01:08 -0300 Subject: [PHP] validate + if  Hi list!I have a 
 form.  I validated it with javascript.  Do the validation, but send the 
 form information.  How can I prevent send the information and stay in the 
 form?  When validate all correctly send the info, but if the form isn’t 
 complete correctly don’t send.Thanks!+ _ // Emiliano 
 Boragina _  // Diseño  Comunicación // + _  // [EMAIL 
 PROTECTED] / // 15 40 58 60 02 /// + _   
Return false from the form validation if it fails and call if with the form's 
onSubmit function
 
form onsubmit=return validate();
 
returning false will stop the submission
 
bastien
_



Re: [PHP] validate + if

2008-02-23 Thread Richard Lynch
If your onClick handler returns true (or is it false?) in JS, the
action won't happen.

Or something like that.

Google for it.

And you still need to validate server-side, as JS is easily bypassed.

On Sat, February 23, 2008 1:01 pm, Emiliano Boragina wrote:
 Hi list!



 I have a form.

 I validated it with javascript.

 Do the validation, but send the form information.

 How can I prevent send the information and stay in the form?

 When validate all correctly send the info, but if the form isn’t
 complete
 correctly don’t send.



 Thanks!



 +
 _
// Emiliano Boragina _

// Diseño  Comunicación //
 +
 _

// [EMAIL PROTECTED]  /
// 15 40 58 60 02 ///
 +
 _






-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



[PHP] validate international phone numbers

2004-11-02 Thread Merlin
Hi,
I am trying to validate international phone numbers before adding into a db.
After a bit of research I came up with this regex:
return (ereg('^[0-9]{1,3}\.[0-9]{1,6}\.[0-9]{1,8}$', $phone));
However, this tightens the numbers to something like this:  409.711.933838
Thats a problem, since some countries have complete other formats and some 
peopole place a + in front and a : instead of . or even just the number.

Can anybody recommend a good regex to validate this? I am not to good at 
creating regex :-(

Thanx for any help,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] validate international phone numbers

2004-11-02 Thread Jason Wong
On Tuesday 02 November 2004 10:49, Merlin wrote:

 I am trying to validate international phone numbers before adding into a
 db. After a bit of research I came up with this regex:

 return (ereg('^[0-9]{1,3}\.[0-9]{1,6}\.[0-9]{1,8}$', $phone));
 However, this tightens the numbers to something like this:  409.711.933838

 Thats a problem, since some countries have complete other formats and some
 peopole place a + in front and a : instead of . or even just the number.

 Can anybody recommend a good regex to validate this? I am not to good at
 creating regex :-(

Using a single regex which encompasses all formats of telephone numbers used 
throughout the world will result in something that is pretty much useless. I 
would just check that their entry consists only of digits, space, hyphen, 
plus sign and period.

Otherwise create an individual check for each country in the world that you're 
interested in.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
No one so thoroughly appreciates the value of constructive criticism as the
one who's giving it.
  -- Hal Chadwick
*/

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



RE: [PHP] validate international phone numbers

2004-11-02 Thread Graham Cossey
 -Original Message-
 From: Merlin [mailto:[EMAIL PROTECTED]
 Sent: 02 November 2004 10:49
 To: [EMAIL PROTECTED]
 Subject: [PHP] validate international phone numbers


 Hi,

 I am trying to validate international phone numbers before adding
 into a db.
 After a bit of research I came up with this regex:

 return (ereg('^[0-9]{1,3}\.[0-9]{1,6}\.[0-9]{1,8}$', $phone));
 However, this tightens the numbers to something like this:  409.711.933838

 Thats a problem, since some countries have complete other formats
 and some
 peopole place a + in front and a : instead of . or even just the number.

 Can anybody recommend a good regex to validate this? I am not to good at
 creating regex :-(

 Thanx for any help,

 Merlin

I know this is not exactly what you were asking, but, some time ago I did
some phone number validation/formatting but not in PHP.

IIRC I had a list of countries each of which had the relevant international
dialling code recorded.

The user of a form would select their country and enter a telephone number.
The international dialling code would be added if not present or validated
if '+' was present. Any leading 0 (after an int. code) would be removed.
Beyond that I think all you can do is validate that a certain number of
digits must have been entered as different people/countries use different
formatting chars: space , . - : etc etc

Another approach would be to request each component separately: int.code,
area code, local number.

This of course was all done within a function/class not a single statement.

HTH
Graham

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



Re: [PHP] validate international phone numbers

2004-11-02 Thread Joshua D. Drake
Merlin wrote:
Hi,
I am trying to validate international phone numbers before adding into 
a db.
After a bit of research I came up with this regex:

return (ereg('^[0-9]{1,3}\.[0-9]{1,6}\.[0-9]{1,8}$', $phone));
However, this tightens the numbers to something like this:  
409.711.933838

Thats a problem, since some countries have complete other formats and 
some peopole place a + in front and a : instead of . or even just the 
number.

Can anybody recommend a good regex to validate this? I am not to good 
at creating regex :-(

Strip out all non-numerical characters before you process.
Sincerely,
Joshua D. Drake

Thanx for any help,
Merlin

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [EMAIL PROTECTED] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL

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

[PHP] validate a tag

2004-10-05 Thread Pahlevanzadeh Mohsen
Dear,I have a input text tag that it named question.
Also i have a 2 radio bottum.
When i receive their value,I want to test that
question tag is empty or not.If empty,I again send to
client until client fill out this tag.
Can u solve my problem?


?php
 function display_form()
  {
   echo form action=\.$_SERVER['PHP_SELF']. \
method=\post\;
   echo Your questioninput type=\text\
name=\question\ br /;
   echo radio type input type=\radio\
name=\type_of_reply\ value=\0\br /;
   echo check box type input type=\radio\
name=\type_of_reply\ value=\1\br /;
   echo input type=\submit\;
/*   if (empty($HTTP_POST_VARS['question']))
{
 echo please fill out question field.;
 display_form();
}//end of if*/

  }//end of display_form func
 function test_var()
  {
   if (empty($HTTP_POST_VARS['question']))
{
 echo please fill out question field.;
 display_form();
}//end of if

  }//end of func
 function insert_to_question()
  {
   display_form();
   while(empty($HTTP_POST_VARS['question']))
test_var();
  }//end of insert_to_question func
 insert_to_question();
?


=
-DIGITAL  SIGNATURE---
///Mohsen Pahlevanzadeh
 Network administrator   programmer 
  My home phone is: +98213810146  
My email address is  
  m_pahlevanzadeh at yahoo dot com   
My website is: http://webnegar.net





__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

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



Re: [PHP] validate a tag

2004-10-05 Thread Greg Donald
On Tue, 5 Oct 2004 01:59:12 -0700 (PDT), Pahlevanzadeh Mohsen
[EMAIL PROTECTED] wrote:
 Dear,I have a input text tag that it named question.
 Also i have a 2 radio bottum.
 When i receive their value,I want to test that
 question tag is empty or not.If empty,I again send to
 client until client fill out this tag.
 Can u solve my problem?

Do you know about isset() or empty() ?  


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] Validate XML data

2004-08-19 Thread Jacob Friis Larsen
It is possible to validate a XML document with XML Schema Definition 
Language (XSDL).

Is it possible to use XSDL in Php?
Thanks,
Jacob
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Validate XML data

2004-08-19 Thread Christian Stocker
It's possible in PHP 5, but not in PHP 4

And I advise to use the most recent libxml2 libraries, since they made
big improvements concerning XSD support lately

chregu

On Thu, 19 Aug 2004 17:11:47 +0200, Jacob Friis Larsen [EMAIL PROTECTED] wrote:
 It is possible to validate a XML document with XML Schema Definition
 Language (XSDL).
 
 Is it possible to use XSDL in Php?
 
 Thanks,
 Jacob
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

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



Re: [PHP] Validate XML data

2004-08-19 Thread Jacob Friis Larsen
It's possible in PHP 5, but not in PHP 4
Could you link me to the documentation?
And I advise to use the most recent libxml2 libraries, since they made
big improvements concerning XSD support lately
It is possible to validate a XML document with XML Schema Definition
Language (XSDL).
Is it possible to use XSDL in Php?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Validate XML data

2004-08-19 Thread Christian Stocker
On Thu, 19 Aug 2004 18:06:27 +0200, Jacob Friis Larsen [EMAIL PROTECTED] wrote:
  It's possible in PHP 5, but not in PHP 4
 
 Could you link me to the documentation?

http://ch2.php.net/manual/en/function.dom-domdocument-schemavalidate.php

chregu
 
  And I advise to use the most recent libxml2 libraries, since they made
  big improvements concerning XSD support lately
 
 It is possible to validate a XML document with XML Schema Definition
 Language (XSDL).
 
 Is it possible to use XSDL in Php?
 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

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



[PHP] validate names with regex

2003-11-12 Thread Chris W. Parker
Hey all.

I tried googling for this AND looking in the archives with no luck.

Can someone post a function or regex that can validate names (first and
last)? The most important bit is that names like O'Malley and Hope-Jones
are not barred.


Hopefully I haven't been too brief with my request.

Thanks,
Chris.

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



Re: [PHP] validate names with regex

2003-11-12 Thread CPT John W. Holmes
From: Chris W. Parker [EMAIL PROTECTED]

 Can someone post a function or regex that can validate names (first and
 last)? The most important bit is that names like O'Malley and Hope-Jones
 are not barred.

I use this:

//allow a possible ', -, or space in name. ' will
//be replaced with \' by magic_quotes upon
//form submission (so we search for \\\')
$match = ^[a-z]+([- ]{1}|(\\\'))?[a-z]+$;

along with eregi(), but it can (should) be easily adapted to a syntax
compatible with preg_match().

I remember a large discussion about this a while back. Archives may be
useful.

---John Holmes...

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



Re: [PHP] validate names with regex

2003-11-12 Thread Eugene Lee
On Wed, Nov 12, 2003 at 01:56:10PM -0800, Chris W. Parker wrote:
: 
: Can someone post a function or regex that can validate names (first and
: last)? The most important bit is that names like O'Malley and Hope-Jones
: are not barred.

The range of human names is so wide that there probably isn't a way to
validate names.  What part of one's name do you consider valid?

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



RE: [PHP] validate names with regex

2003-11-12 Thread Chris W. Parker
CPT John W. Holmes mailto:[EMAIL PROTECTED]
on Wednesday, November 12, 2003 2:09 PM said:

 $match = ^[a-z]+([- ]{1}|(\\\'))?[a-z]+$;
 
 along with eregi(), but it can (should) be easily adapted to a syntax
 compatible with preg_match().

I'm wondering two things:

1. Is there a performance difference between ereg() and eregi()? I'm
thinking it might be better to change [a-z] to [\w].

2. I know \w covers [a-zA-Z] but does it cover anything else?

 I remember a large discussion about this a while back. Archives may be
 useful.

I couldn't find anything, but I was pretty sure it had been discussed
before as well. Happen to know the subject of the thread?



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



RE: [PHP] validate names with regex

2003-11-12 Thread Chris W. Parker
Eugene Lee mailto:[EMAIL PROTECTED]
on Wednesday, November 12, 2003 3:12 PM said:

 The range of human names is so wide that there probably isn't a way to
 validate names.  What part of one's name do you consider valid?

What part of one's name do I consider valid? Umm... probably the whole
thing. ;) But seriously, what do you mean?

If the name doesn't have anything more than a-zA-Z' - I think I'll be
ok. If I can validate a wider range that's great but I won't stress
about it.



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



Re: [PHP] validate names with regex

2003-11-12 Thread John W. Holmes
Chris W. Parker wrote:

CPT John W. Holmes mailto:[EMAIL PROTECTED]
on Wednesday, November 12, 2003 2:09 PM said:
   $match = ^[a-z]+([- ]{1}|(\\\'))?[a-z]+$;

along with eregi(), but it can (should) be easily adapted to a syntax
compatible with preg_match().


I'm wondering two things:

1. Is there a performance difference between ereg() and eregi()? I'm
thinking it might be better to change [a-z] to [\w].
Would probably be better to use \w, but best overall to just use 
preg_match(). The preg_* functions are faster than the ereg* functions...

I remember a large discussion about this a while back. Archives may be
useful.
I couldn't find anything, but I was pretty sure it had been discussed
before as well. Happen to know the subject of the thread?
I looked through 40 pages of archives and couldn't find it either. :)

It had to deal with validating an entire name and capitalizing it with 
the whole McNab vs MacNab vs O'Reilly vs Marco de Blabla or whatever.

If I find it, I'll forward it your way.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-17 Thread Nicholas Robinson
And the reason I quoted 'usual' is that my suggestion is more portable.

On Thursday 14 Aug 2003 11:54 am, Ford, Mike [LSS] wrote:
 On 13 August 2003 20:05, Nicholas Robinson wrote:
  On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
   Hi!
  
   Here's a trick script.  We know that some months have the last
   day which is 30 while other is 31.  As for February, it can be
either 28 or 29. So, what's the trick in using the php to find out
   what is the last day of the month if you want to checked it against
   the server's clock to find out the last day of the month.  Suppose
   it is this month or 3 months ago or 3 months from now.  Anyone know?
 
  The 'usual' trick is to set the date to the first day of the month
  after the one you want and then subtract one day.

 Actually, the usual trick is to ask mktime() for the 0th day of the
 following month.  One of the examples on the mktime() page of the manual
 (http://www.php.net/mktime) even illustrates exactly this.

 Cheers!

 Mike

 -
 Mike Ford,  Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211


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



RE: [PHP] Validate The Last Day of Month with server's clock????

2003-08-17 Thread Ralph Guzman
?php

// check last day of september
$month = '08';
$year = date(Y);

$last_day = date(t, mktime (0,0,0, $month,1,$year));

print $last_day;
?

-Original Message-
From: Scott Fletcher [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 13, 2003 12:00 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Validate The Last Day of Month with server's clock

Hi!

Here's a trick script.  We know that some months have the last day
which
is 30 while other is 31.  As for February, it can be either 28 or 29.
So,
what's the trick in using the php to find out what is the last day of
the
month if you want to checked it against the server's clock to find out
the
last day of the month.  Suppose it is this month or 3 months ago or 3
months
from now.  Anyone know?

Thanks!



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




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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread CPT John W. Holmes
From: Nicholas Robinson [EMAIL PROTECTED]

 The 'usual' trick is to set the date to the first day of the month after
the
 one you want and then subtract one day.

Along those same lines, this works:


?php

$month = 12;
$year = 2003;

$last_day_of_month = mktime(12,0,0,$month+1,0,$year);

echo date('m/d/Y',$last_day_of_month);

?

---John Holmes...


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



[PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Scott Fletcher
Hi!

Here's a trick script.  We know that some months have the last day which
is 30 while other is 31.  As for February, it can be either 28 or 29.  So,
what's the trick in using the php to find out what is the last day of the
month if you want to checked it against the server's clock to find out the
last day of the month.  Suppose it is this month or 3 months ago or 3 months
from now.  Anyone know?

Thanks!



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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Scott Fletcher
Alright, interesting thought, never thought it would be possible.  So, what
would the PHP script be when matching it against the clock or something?
Perhap mktime().  Anyone know?

Scott F.

Nicholas Robinson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
The 'usual' trick is to set the date to the first day of the month after the
one you want and then subtract one day.

HTH

Nick

On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
 Hi!

 Here's a trick script.  We know that some months have the last day
 which is 30 while other is 31.  As for February, it can be either 28 or
29.
  So, what's the trick in using the php to find out what is the last day of
 the month if you want to checked it against the server's clock to find out
 the last day of the month.  Suppose it is this month or 3 months ago or 3
 months from now.  Anyone know?

 Thanks!



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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Scott Fletcher
Ah!  that seem nicer when just using the script ($month+1)...

Cpt John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 From: Nicholas Robinson [EMAIL PROTECTED]

  The 'usual' trick is to set the date to the first day of the month after
 the
  one you want and then subtract one day.

 Along those same lines, this works:


 ?php

 $month = 12;
 $year = 2003;

 $last_day_of_month = mktime(12,0,0,$month+1,0,$year);

 echo date('m/d/Y',$last_day_of_month);

 ?

 ---John Holmes...




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



RE: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Ford, Mike [LSS]
On 14 August 2003 16:01, Scott Fletcher wrote:

 Mike Ford [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  On 13 August 2003 20:05, Nicholas Robinson wrote:
  
   On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
Hi!

Here's a trick script.  We know that some months have the
last day which is 30 while other is 31.  As for February, it
 can be either 28 or 29. So, what's the trick in using the php
to find out what is the last day of the month if you want to
checked it against the server's clock to find out the last day
of the month.  Suppose it is this month or 3 months ago or 3
months from now. Anyone know? 
   
   The 'usual' trick is to set the date to the first day of the month
   after the one you want and then subtract one day.
  
  Actually, the usual trick is to ask mktime() for the 0th
 day of the
 following month.  One of the examples on the mktime() page of the
 manual (http://www.php.net/mktime) even illustrates exactly this.

 True but I just only want the day date, don't want the number of
 seconds. 

So use one of the other Date/Time functions to to convert it back to
whatever you do want -- date(), getdate() and strftime() all accept a
timestamp produced by mktime() as an optional parameter.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Mike Migurski
Here's a trick script.  We know that some months have the last day
which is 30 while other is 31.  As for February, it can be either 28 or
29.  So, what's the trick in using the php to find out what is the last
day of the month if you want to checked it against the server's clock to
find out the last day of the month.  Suppose it is this month or 3 months
ago or 3 months from now.  Anyone know?

If you're in unix, pull the last token from the default output of `cal`:

August 2003
 S  M Tu  W Th  F  S
1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



RE: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Ford, Mike [LSS]
On 13 August 2003 20:05, Nicholas Robinson wrote:

 On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
  Hi!
  
  Here's a trick script.  We know that some months have the last
  day which is 30 while other is 31.  As for February, it can be
   either 28 or 29. So, what's the trick in using the php to find out
  what is the last day of the month if you want to checked it against
  the server's clock to find out the last day of the month.  Suppose
  it is this month or 3 months ago or 3 months from now.  Anyone know?

 The 'usual' trick is to set the date to the first day of the month
 after the one you want and then subtract one day.

Actually, the usual trick is to ask mktime() for the 0th day of the following month. 
 One of the examples on the mktime() page of the manual (http://www.php.net/mktime) 
even illustrates exactly this.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Nicholas Robinson
The 'usual' trick is to set the date to the first day of the month after the 
one you want and then subtract one day.

HTH

Nick

On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
 Hi!

 Here's a trick script.  We know that some months have the last day
 which is 30 while other is 31.  As for February, it can be either 28 or 29.
  So, what's the trick in using the php to find out what is the last day of
 the month if you want to checked it against the server's clock to find out
 the last day of the month.  Suppose it is this month or 3 months ago or 3
 months from now.  Anyone know?

 Thanks!


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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Scott Fletcher
True but I just only want the day date, don't want the number of seconds.

Mike Ford [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On 13 August 2003 20:05, Nicholas Robinson wrote:

  On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
   Hi!
  
   Here's a trick script.  We know that some months have the last
   day which is 30 while other is 31.  As for February, it can be
either 28 or 29. So, what's the trick in using the php to find out
   what is the last day of the month if you want to checked it against
   the server's clock to find out the last day of the month.  Suppose
   it is this month or 3 months ago or 3 months from now.  Anyone know?
 
  The 'usual' trick is to set the date to the first day of the month
  after the one you want and then subtract one day.

 Actually, the usual trick is to ask mktime() for the 0th day of the
following month.  One of the examples on the mktime() page of the manual
(http://www.php.net/mktime) even illustrates exactly this.

 Cheers!

 Mike

 -
 Mike Ford,  Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211



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



Re: [PHP] Validate The Last Day of Month with server's clock????

2003-08-14 Thread Scott Fletcher
Did a lot of searching on the internet and found a simple PHP code that does
the trick.  How the code work is when you pick a month where you want the
last day to be in, then use the next month into the PHP script to get the
last day of the month you're looking for.

--snip--
//Want to see the last day of Febraury (Then insert the next
month to find out).
echo strftime(%d, mktime(0,0,0,3,0,2004));
--snip--

Scott Fletcher [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Alright, interesting thought, never thought it would be possible.  So,
what
 would the PHP script be when matching it against the clock or something?
 Perhap mktime().  Anyone know?

 Scott F.

 Nicholas Robinson [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 The 'usual' trick is to set the date to the first day of the month after
the
 one you want and then subtract one day.

 HTH

 Nick

 On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
  Hi!
 
  Here's a trick script.  We know that some months have the last day
  which is 30 while other is 31.  As for February, it can be either 28 or
 29.
   So, what's the trick in using the php to find out what is the last day
of
  the month if you want to checked it against the server's clock to find
out
  the last day of the month.  Suppose it is this month or 3 months ago or
3
  months from now.  Anyone know?
 
  Thanks!





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



[PHP] Validate MySQL date

2003-03-31 Thread Ben C.
How do I easily check to see if a MySQL formatted date is valid such as if a
user enters

2003/02/28 would return true
2003/02/31 would return false

I have check the manual and other resources but can't come up with anything.

--
The content of this email message and any attachments are confidential and
may be legally privileged, intended solely for the addressee.  If you are
not the intended recipient, be advised that any use, dissemination,
distribution, or copying of this e-mail is strictly prohibited.  If you
receive this message in error, please notify the sender immediately by reply
email and destroy the message and its attachments.


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



Re: [PHP] Validate MySQL date

2003-03-31 Thread Charles Kline
try the checkdate() function. i think that will do what you need.

On Monday, March 31, 2003, at 11:06 PM, Ben C. wrote:

How do I easily check to see if a MySQL formatted date is valid such  
as if a
user enters

2003/02/28 would return true
2003/02/31 would return false
I have check the manual and other resources but can't come up with  
anything.

--- 
---
The content of this email message and any attachments are confidential  
and
may be legally privileged, intended solely for the addressee.  If you  
are
not the intended recipient, be advised that any use, dissemination,
distribution, or copying of this e-mail is strictly prohibited.  If you
receive this message in error, please notify the sender immediately by  
reply
email and destroy the message and its attachments.

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


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


[PHP] validate date

2002-12-19 Thread Diana Castillo
If a user inputs a date into a form, what function can I use to validate
that he put in a valid date?
I want to use checkdate but that needs the date split up into day, month
year.
Anyone have an easy way of doing this?
Thanks,
Diana




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




RE: [PHP] validate date

2002-12-19 Thread Jon Haworth
Hi Diana,

 If a user inputs a date into a form, what function can I 
 use to validate that he put in a valid date?

You can't. Here are two dates in two different formats. Only one is valid.

  - 13/04/01
  - 13/04/01

Can you spot which is which?

 I want to use checkdate but that needs the date split up 
 into day, month year. Anyone have an easy way of doing this?

You could try separate drop-downs: one for day (with numbers 1-31), one for
month (with names) and one for years (whatever you need). This gives you
three variables that you can easily pass to checkdate().

Don't fall into the trap of thinking that if you put some text on your form
saying please enter dates in mm-dd-yy format that that's what you'll get,
unless you *really* know your audience.

Cheers
Jon



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




Re: [PHP] validate date

2002-12-19 Thread Manuel Ochoa

Here is a funtion that I use.
A user can enter a date in any of the following ways:
01 01 03
01-01-03
1-1-03
01-1-2003
1-01/03
1/1 03  you get the idea...
This function will standardize the date and make sure it's valid. If invalid it 
returns ERROR
function fixdate($data){
 $aux[0]=;
 $aux[1]=;
 $aux[2]=;
 $z=0;
 for($i=0; $istrlen($data); $i++) {
  if(is_numeric($data[$i])) {
   $aux[$z].=$data[$i];
  }
  else {
   $z++;
  }
 }
 if(strlen($aux[0])==1) {
  $aux[0]= 0.$aux[0];
 }
 if(strlen($aux[1])==1) {
  $aux[1]= 0.$aux[1];
 }
 if(strlen($aux[2])==2) {
  $aux[2]= 20.$aux[2];
 }
 $mdate= $aux[0]./.$aux[1]./.$aux[2];
 if(checkdate($aux[0], $aux[1], $aux[2])) {
  Return $mdate;
 }
 else {
  Return ERROR;
 }
}//function
 Diana Castillo [EMAIL PROTECTED] wrote:If a user inputs a date into 
a form, what function can I use to validate
that he put in a valid date?
I want to use checkdate but that needs the date split up into day, month
year.
Anyone have an easy way of doing this?
Thanks,
Diana


RE: [PHP] validate date

2002-12-19 Thread John W. Holmes
 If a user inputs a date into a form, what function can I use to
validate
 that he put in a valid date?
 I want to use checkdate but that needs the date split up into day,
month
 year.
 Anyone have an easy way of doing this?

You have to specify a date format to your users, or at least assume a
certain amount of formats. If you don't do this, then there's no way to
validate it, because any amount of variations exist of date formats. 

If you require a mm/dd/yy format, then just break it apart and validate
each element. You'll basically have to write your own function, or
possibly use strtotime() to see if it returns a result. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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




[PHP] validate querystring

2002-12-11 Thread Dara Dowd
Hello,
I have a query string like this 
http://server/download.php?fname=name_of_remote_file. The script runs and displays a 
file download dialog box.
Is there a way of validating the querystring to ensure that a user doesn't try 
something like fname=. or fname=.. or fname=? or fname=/, which enable the user to see 
the contents of the remote directory, without resorting to a load of 'if' 
statements.Are there any other special characters i should be aware of?
Cheers,Dara

-- 
For the largest free email in Ireland (25MB)  
File Storage space (20MB), visit http://www.campus.ie

Powered by Outblaze

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




Re: [PHP] validate querystring

2002-12-11 Thread Brad Bulger

you could try doing

$realfilename = realpath($fname);
if (strpos($realfilename, $the_valid_path_to_my_file_directory) !== 0)
{
// bad file name, like /etc/passwd
}
elseif (is_dir($realfilename))
{
// bad user looking at directory
}

On Thu, 12 Dec 2002, Dara Dowd wrote:

 Hello,
 I have a query string like this
 http://server/download.php?fname=name_of_remote_file. The script runs and displays a 
file download dialog box.
 Is there a way of validating the querystring to ensure that a user doesn't try 
something like fname=. or fname=.. or fname=? or fname=/, which enable the user to 
see the contents of the remote directory, without resorting to a load of 'if' 
statements.Are there any other special characters i should be aware of?
 Cheers,Dara

 --
 For the largest free email in Ireland (25MB) 
 File Storage space (20MB), visit http://www.campus.ie

 Powered by Outblaze

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


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




[PHP] Validate CSV file With Table in Database!!

2001-09-13 Thread Coenraad Steenkamp

I need to compare a csv file to a table in the database but only one field
in the database with
one field in the CSV file! Comparing only one field will make it much
easier! When there is any change in the Database compared to the CSV file ,
the database must then be updated or if there are no such a field it must be
added to the table!

I am new in php Please help!




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Validate CSV file With Table in Database!!

2001-09-13 Thread David Robley

On Thu, 13 Sep 2001 16:37, Coenraad Steenkamp wrote:
 I need to compare a csv file to a table in the database but only one
 field in the database with
 one field in the CSV file! Comparing only one field will make it much
 easier! When there is any change in the Database compared to the CSV
 file , the database must then be updated or if there are no such a
 field it must be added to the table!

 I am new in php Please help!

That seems an awful lot of work, if you know that the csv is at least as 
up to date, if not more so, than the actual table. You might as well just 
drop the table and import the contents of the csv.

Unless there's a good reason not to that you haven't mentioned?

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   Birds are trapped by their feet, people by their tongues.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Validate CSV file With Table in Database!!

2001-09-13 Thread David Robley

On Thu, 13 Sep 2001 16:52, you wrote:
 There is a very good reason !
 The csv file contains world currency's
 The system is updated with the changed currency's only !
 The Master field contains all country currency's , this makes it
 difficult because if i drop the master table and upload the csv there
 will only be a few currency's!

 Thanks
 Coenraad Steenkamp


 - Original Message -
 From: David Robley [EMAIL PROTECTED]
 Newsgroups: php.general
 To: Coenraad Steenkamp [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Thursday, September 13, 2001 9:18 AM
 Subject: Re: [PHP] Validate CSV file With Table in Database!!

  On Thu, 13 Sep 2001 16:37, Coenraad Steenkamp wrote:
   I need to compare a csv file to a table in the database but only
   one field in the database with
   one field in the CSV file! Comparing only one field will make it
   much easier! When there is any change in the Database compared to
   the CSV file , the database must then be updated or if there are no
   such a field it must be added to the table!
  
   I am new in php Please help!
 
  That seems an awful lot of work, if you know that the csv is at least
  as up to date, if not more so, than the actual table. You might as
  well just drop the table and import the contents of the csv.
 
  Unless there's a good reason not to that you haven't mentioned?

OK. So it sounds like you need to do something like:

for each csv file line
  select record where table_key = csvfield_key
  if record found
if table_other_value != csv_other_value
  update table with csv_value
end if
  else (record not found)
insert new record
  end if
end for

where the key might be perhaps the country name and the other value is 
the current currency.

Am I on the right track? Does that help you any?

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   I am functioning within established parameters.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Validate CSV file With Table in Database!!

2001-09-13 Thread Coenraad Steenkamp

This is the code i came up with! But it is not 100%
?php
 if (isset($Submit)) {
  // File is uploaded
  if ($uFile  ) {
 if (!copy($uFile, $move_to_dir./.$uFile_name)) {
echo No File Uploaded;
 }
 $curr = fopen($move_to_dir./.$uFile_name, r);
 while ($currar = fgetcsv($curr, 1000, ,)) {
$CurrCode = $currar[0];
$Currency = $currar[1];
$From1 = $currar[2];
$To1 = $currar[3];
$ROEX = $currar[4];
$sqlcurr=SELECT * FROM CurrencyNetwork WHERE CNCurr =
'$Currency';
$result = mysql_query($sqlcurr,$db_con);
if (mysql_fetch_array($result)) {
   //Do Nothing
} else {
$sql=INSERT INTO CurrencyNetwork
(CNCode,CNCurr,CNAdBy,CNDtAd,CNROEX)
  values ('$CurrCode', '$Currency', '$From1', '$To1',
'$ROEX');
  mysql_query($sql,$db_con);
}

 }
 mysql_close($db_con);
  }
   }
 else
 {
  // No file uploaded, show the form
  echo div align='center';
  echo Upload this file: input name='uFile' type='file';
  echo input type='submit' name='Submit' value='Upload';
  echo /div;
 }
?



David Robley [EMAIL PROTECTED] wrote in message
01091317241109.14360@www">news:01091317241109.14360@www...
 On Thu, 13 Sep 2001 16:52, you wrote:
  There is a very good reason !
  The csv file contains world currency's
  The system is updated with the changed currency's only !
  The Master field contains all country currency's , this makes it
  difficult because if i drop the master table and upload the csv there
  will only be a few currency's!
 
  Thanks
  Coenraad Steenkamp
 
 
  - Original Message -
  From: David Robley [EMAIL PROTECTED]
  Newsgroups: php.general
  To: Coenraad Steenkamp [EMAIL PROTECTED];
  [EMAIL PROTECTED]
  Sent: Thursday, September 13, 2001 9:18 AM
  Subject: Re: [PHP] Validate CSV file With Table in Database!!
 
   On Thu, 13 Sep 2001 16:37, Coenraad Steenkamp wrote:
I need to compare a csv file to a table in the database but only
one field in the database with
one field in the CSV file! Comparing only one field will make it
much easier! When there is any change in the Database compared to
the CSV file , the database must then be updated or if there are no
such a field it must be added to the table!
   
I am new in php Please help!
  
   That seems an awful lot of work, if you know that the csv is at least
   as up to date, if not more so, than the actual table. You might as
   well just drop the table and import the contents of the csv.
  
   Unless there's a good reason not to that you haven't mentioned?

 OK. So it sounds like you need to do something like:

 for each csv file line
   select record where table_key = csvfield_key
   if record found
 if table_other_value != csv_other_value
   update table with csv_value
 end if
   else (record not found)
 insert new record
   end if
 end for

 where the key might be perhaps the country name and the other value is
 the current currency.

 Am I on the right track? Does that help you any?

 --
 David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
 CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA

I am functioning within established parameters.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Validate CSV file With Table in Database!!

2001-09-13 Thread David Robley

On Thu, 13 Sep 2001 17:27, Coenraad Steenkamp wrote:
 This is the code i came up with! But it is not 100%
 ?php
  if (isset($Submit)) {
   // File is uploaded
   if ($uFile  ) {
  if (!copy($uFile, $move_to_dir./.$uFile_name)) {
 echo No File Uploaded;
  }
  $curr = fopen($move_to_dir./.$uFile_name, r);
  while ($currar = fgetcsv($curr, 1000, ,)) {
 $CurrCode = $currar[0];
 $Currency = $currar[1];
 $From1 = $currar[2];
 $To1 = $currar[3];
 $ROEX = $currar[4];
 $sqlcurr=SELECT * FROM CurrencyNetwork WHERE CNCurr =
 '$Currency';
 $result = mysql_query($sqlcurr,$db_con);
 if (mysql_fetch_array($result)) {
//Do Nothing
 } else {
 $sql=INSERT INTO CurrencyNetwork
 (CNCode,CNCurr,CNAdBy,CNDtAd,CNROEX)
   values ('$CurrCode', '$Currency', '$From1', '$To1',
 '$ROEX');
   mysql_query($sql,$db_con);
 }

  }
  mysql_close($db_con);
   }
}
  else
  {
   // No file uploaded, show the form
   echo div align='center';
   echo Upload this file: input name='uFile' type='file';
   echo input type='submit' name='Submit' value='Upload';
   echo /div;
  }
 ?



 David Robley [EMAIL PROTECTED] wrote in message
 01091317241109.14360@www">news:01091317241109.14360@www...

  On Thu, 13 Sep 2001 16:52, you wrote:
   There is a very good reason !
   The csv file contains world currency's
   The system is updated with the changed currency's only !
   The Master field contains all country currency's , this makes it
   difficult because if i drop the master table and upload the csv
   there will only be a few currency's!
  
   Thanks
   Coenraad Steenkamp
  
  
   - Original Message -
   From: David Robley [EMAIL PROTECTED]
   Newsgroups: php.general
   To: Coenraad Steenkamp [EMAIL PROTECTED];
   [EMAIL PROTECTED]
   Sent: Thursday, September 13, 2001 9:18 AM
   Subject: Re: [PHP] Validate CSV file With Table in Database!!
  
On Thu, 13 Sep 2001 16:37, Coenraad Steenkamp wrote:
 I need to compare a csv file to a table in the database but
 only one field in the database with
 one field in the CSV file! Comparing only one field will make
 it much easier! When there is any change in the Database
 compared to the CSV file , the database must then be updated or
 if there are no such a field it must be added to the table!

 I am new in php Please help!
   
That seems an awful lot of work, if you know that the csv is at
least as up to date, if not more so, than the actual table. You
might as well just drop the table and import the contents of the
csv.
   
Unless there's a good reason not to that you haven't mentioned?
 
  OK. So it sounds like you need to do something like:
 
  for each csv file line
select record where table_key = csvfield_key
if record found
  if table_other_value != csv_other_value
update table with csv_value
  end if
else (record not found)
  insert new record
end if
  end for
 
  where the key might be perhaps the country name and the other value
  is the current currency.
 
  Am I on the right track? Does that help you any?
 
  --
  David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
  CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA
 
 I am functioning within established parameters.

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   A cat will go quack - if you squeeze it hard enough.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Validate CSV file With Table in Database!!

2001-09-13 Thread David Robley

Sorry - pressed send w/out writing anything. Topic followed up direct 
with problem owner.

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   There are 2 ways to handle women and I know neither.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validate phone numbers

2001-06-20 Thread Steve Werby

Richard Kurth [EMAIL PROTECTED] wrote:
 I am using this script to validate for phone numbers and it work just
 perfect for US phone numbers. But it rejects some European and
 Australian numbers what do I need to do to make it validate all phone
 numbers

 if (($WPHONE_NO) || ($wphone_no)) {
$wphone_no = trim($wphone_no);
if ($WPHONE_NO)
   $phone_no = trim($WPHONE_NO);
if (!ereg((^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$), $wphone_no))
{
   print_error(your bphone number/b is invalid);
}
 }

It would be helpful if you post a list of the range of phone numbers you are
encountering that you are having a problem with.  Or I can get you started
by saying that I think you're regular expression is saying beginning with
anything, then exactly 3 numbers, then anything, then exactly 3 numbers,
then anything, then ending in exactly 4 numbers.  Changing a {3} to {3,4}
would mean match 3-4 occurences of what's to the left.  Hopefully that
will get you started, if you post some other numbers you want to pass
validation we can be of more assistance.  regex are very powerful and I
recommend you add them to your training.  That said, people enter #s in many
different formats and sometimes it's necessary to enter a # like
011-817-972-1086 x103 or 817-972-1086, 1, 3, 12 if you're dealing with
business numbers with extensions or automated systems that have to be
traversed.  So you may be better off not validating the phone #.  YMMV.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/




RE: [PHP] validate phone numbers

2001-06-20 Thread scott [gts]

i agree.

there's NOTHING more annoying than a broken validation
script when you're trying to enter valid, but weird, data.

perhaps separate the form up into one box for the 
country code, one box for the number, and one box
for any add'l information (extensions, automated prompt
numbers, etc...), so that you'd only have to work at
validating the actual number (and not any extraneous
and oddly formatted info)


 -Original Message-
 From: Steve Werby [mailto:[EMAIL PROTECTED]]
 Subject: Re: [PHP] validate phone numbers
 
 people enter #s in many
 different formats and sometimes it's necessary to enter a # like
 011-817-972-1086 x103 or 817-972-1086, 1, 3, 12 if you're dealing with
 business numbers with extensions or automated systems that have to be
 traversed.  So you may be better off not validating the phone #.  YMMV.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validate phone numbers

2001-06-20 Thread Miles Thompson

There are so many combinations of European phone numbers, along with the 
possible combinations of area codes, and hyphens or spaces may be used as 
well, I wouldn't bother. If the phone number is critical, and important to 
the person using your site, then treatitlike a password and have them enter 
it twice. Although in that  case they are likely to enter it correctly anyway.

One can only do so much.

Miles Thompson

At 07:24 PM 6/19/01 -0700, Richard Kurth wrote:
I am using this script to validate for phone numbers and it work just
perfect for US phone numbers. But it rejects some European and
Australian numbers what do I need to do to make it validate all phone
numbers

if (($WPHONE_NO) || ($wphone_no)) {
$wphone_no = trim($wphone_no);
if ($WPHONE_NO)
   $phone_no = trim($WPHONE_NO);
if (!ereg((^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$), $wphone_no)) {
   print_error(your bphone number/b is invalid);
}
}











Best regards,
  Richard
mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] validate phone numbers

2001-06-19 Thread Richard Kurth

I am using this script to validate for phone numbers and it work just
perfect for US phone numbers. But it rejects some European and
Australian numbers what do I need to do to make it validate all phone
numbers

if (($WPHONE_NO) || ($wphone_no)) {
   $wphone_no = trim($wphone_no);
   if ($WPHONE_NO)
  $phone_no = trim($WPHONE_NO);
   if (!ereg((^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$), $wphone_no)) {
  print_error(your bphone number/b is invalid);
   }
}











Best regards,
 Richard  
mailto:[EMAIL PROTECTED]




RE: [PHP] validate form with javascript

2001-05-14 Thread Sandeep Hundal

doh! forgot to add, you need to put this in your form tage as well :
name=formname onSubmit=return formCheck()


regards

/sunny

-Original Message-
From: Sandeep Hundal [mailto:[EMAIL PROTECTED]]
Sent: 14 May 2001 10:43
To: 'Meir Kriheli - MKsoft'; Chris Mason; [EMAIL PROTECTED]
Subject: RE: [PHP] validate form with javascript


here's one that i use along with my forms you can ofcourse expand it to
include all forms as long as you change the input names too

hapy coding :)

/sunny



script language=JavaScript
transmitted = 0;
function formCheck() {
if (document.formname.inputname.value == ) {
   alert(You need to enter an email address!);
   document.formname.inputname.focus();
   return false;
}
}
/script


-Original Message-
From: Meir Kriheli - MKsoft [mailto:[EMAIL PROTECTED]]
Sent: 14 May 2001 11:42
To: Chris Mason; [EMAIL PROTECTED]
Subject: Re: [PHP] validate form with javascript


You can try the forms class from Manuel Lemos, which handles
this and more.

For more details:
http://phpclasses.upperdesign.com/browse.html/package/1


--
Meir Kriheli
MKsoft computer systems

  'There's someone in my head but it's not me - Pink Floyd
- Original Message -
From: Chris Mason [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 14, 2001 2:46 AM
Subject: [PHP] validate form with javascript


 I have a form in which I validate the email address using a php function
 then alert the operson if the email address is not correct. However, I
would
 like to pop up an alert with javascript if the email field is left blank.
I
 am using the function below but it down't work with php, probably works
 great with a cgi.

 Does anyone have a better way to do this?

 Chris Mason
 Code:
 in the head

 function validForm(replyForm)
 {
 if(replyForm.email.value==\\){
 alert(\You must enter an email address\)
 replyform.email.value.focus()
 return false
 }
 return true
 }


 in the form:
 FORM  onSubmit=\return validForm(this)\ METHOD=\POST\
 ACTION=\reserve.php3?action=send\ ENCTYPE=\x-www-form-urlencoded\
 table
 TR CLASS=\$c\ TD CLASS=\$c\E-Mail /TD TD COLSPAN=\$i\INPUT
 TYPE=\text\ NAME=\email\ VALUE=\$email\ SIZE=\50\/TD/TR

 /table
 /form
 )



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] validate form with javascript

2001-05-13 Thread Chris Mason

I have a form in which I validate the email address using a php function
then alert the operson if the email address is not correct. However, I would
like to pop up an alert with javascript if the email field is left blank. I
am using the function below but it down't work with php, probably works
great with a cgi.

Does anyone have a better way to do this?

Chris Mason
Code:
in the head

function validForm(replyForm)
{
if(replyForm.email.value==\\){
alert(\You must enter an email address\)
replyform.email.value.focus()
return false
}
return true
}


in the form:
FORM  onSubmit=\return validForm(this)\ METHOD=\POST\
ACTION=\reserve.php3?action=send\ ENCTYPE=\x-www-form-urlencoded\
table
TR CLASS=\$c\   TD CLASS=\$c\E-Mail /TD   TD COLSPAN=\$i\INPUT
TYPE=\text\ NAME=\email\ VALUE=\$email\ SIZE=\50\/TD/TR

/table
/form
)





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validate form with javascript

2001-05-13 Thread Steve

What is the particular error you're getting?

Chris Mason [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have a form in which I validate the email address using a php function
 then alert the operson if the email address is not correct. However, I
would
 like to pop up an alert with javascript if the email field is left blank.
I
 am using the function below but it down't work with php, probably works
 great with a cgi.

 Does anyone have a better way to do this?

 Chris Mason
 Code:
 in the head

 function validForm(replyForm)
 {
 if(replyForm.email.value==\\){
 alert(\You must enter an email address\)
 replyform.email.value.focus()
 return false
 }
 return true
 }


 in the form:
 FORM  onSubmit=\return validForm(this)\ METHOD=\POST\
 ACTION=\reserve.php3?action=send\ ENCTYPE=\x-www-form-urlencoded\
 table
 TR CLASS=\$c\ TD CLASS=\$c\E-Mail /TD TD COLSPAN=\$i\INPUT
 TYPE=\text\ NAME=\email\ VALUE=\$email\ SIZE=\50\/TD/TR

 /table
 /form
 )





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Validate forms into PHP file

2001-04-09 Thread elias

You can use JavaScript to validate the fields in a form too, would be
easier.
As for PHP it's too easy, you can check fields values against whatever
condition.
ie: if (length($password)  3) die("password too short");

-elias
http://www.kameelah.org/eassoft

""Fernando Buitrago"" [EMAIL PROTECTED] wrote in message
9aq09s$jck$[EMAIL PROTECTED]">news:9aq09s$jck$[EMAIL PROTECTED]...
 Hi.

 Tell me the steps to validate field's forms in the same PHP file, before
to
 send the result to another file.

 Regards



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Validate forms into PHP file

2001-04-08 Thread Fernando Buitrago

Hi.

Tell me the steps to validate field's forms in the same PHP file, before to
send the result to another file.

Regards



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]