HELP! Again. I seem to have some padding I can't get rid of and a PHP problem.

M

Mike Barnard

No, not my spare tyre, although thats true too.

www.thermachek.co.uk/

On the contact page if I look at it with Firefox I get huge amounts of
padding around the telephone number. Looking at it in IE it looks OK.
Why, please?

I have just thought, is it the famous "IE collapses margins but others
don't" bug? Because I don't see much margin or padding to collapse in
the css.

As for the PHP problem, I have downloaded a freebie php script for a
spam free email contact form. This is where it came from...

http://www.stevedawson.com/article0015.php

I have butchered it slightly, but not the basic code, just the excess
table stuff. The problem is that a valid email address I entered as a
test returns as invalid. Can anyone tell me if the script is any good
and worth persevering with or is there better somewhere?

OK, here I go again, off to the land of nod. 5 past 11 at night. But I
think I'm slowly getting there. :)

Thanks all. G'night.
 
E

Els

Mike said:
No, not my spare tyre, although thats true too.

www.thermachek.co.uk/

On the contact page if I look at it with Firefox I get huge amounts of
padding around the telephone number. Looking at it in IE it looks OK.
Why, please?

Becaues the h* elements have margin. Set margin:0; on that h5, and
it's gone.
As for the PHP problem, I have downloaded a freebie php script for a
spam free email contact form. This is where it came from...

http://www.stevedawson.com/article0015.php

I have butchered it slightly, but not the basic code, just the excess
table stuff. The problem is that a valid email address I entered as a
test returns as invalid. Can anyone tell me if the script is any good
and worth persevering with or is there better somewhere?

I'm no PHP wizard, nor do I know much about regexp, but for those who
are, this is the part in the script that seems to check the email
address:

// Check the email address enmtered matches the standard email address
format
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
 
B

Ben C

No, not my spare tyre, although thats true too.

www.thermachek.co.uk/

On the contact page if I look at it with Firefox I get huge amounts of
padding around the telephone number. Looking at it in IE it looks OK.
Why, please?

I have just thought, is it the famous "IE collapses margins but others
don't" bug?

I don't know about that famous bug, but for future reference Firefox
etc. do collapse top and bottom margins between blocks mostly correctly
as specified in CSS 2.1.
Because I don't see much margin or padding to collapse in
the css.

Padding never gets collapsed, only top and bottom margins.
 
M

Mike Barnard

Mike Barnard wrote:
Becaues the h* elements have margin. Set margin:0; on that h5, and
it's gone.

DOH! Again.

Thanks for pointing out the obvious to me. :)
I'm no PHP wizard, nor do I know much about regexp, but for those who
are, this is the part in the script that seems to check the email
address:
// Check the email address enmtered matches the standard email address
format
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}


True, this is the part, but I haven't worked it out and it doesn't
show which of the possible errors has caused the invalidity.

Oh well, off to the php reference sites to try and work it out.

Thanks.
 
J

John Hosking

I'm no PHP wizard, nor do I know much about regexp, but for those who
are, this is the part in the script that seems to check the email
address:

// Check the email address enmtered matches the standard email address
format
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}

I'm not only not a wizard, I'm not even a sorceror's apprentice. But it
seems to me this regexp is overly sensitive to case. (It looks to me as
if it doesn't like lowercase characters in the address.)

Mike: what happens when you captilaize the entire e-mail address?
Or: what happens when you steal a different e-mail validity regex from
somewhere else on the Web?
 
E

Els

John said:
I'm no PHP wizard, nor do I know much about regexp, but for those who
are, this is the part in the script that seems to check the email
address:

// Check the email address enmtered matches the standard email address
format
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}

I'm not only not a wizard, I'm not even a sorceror's apprentice. But it
seems to me this regexp is overly sensitive to case. (It looks to me as
if it doesn't like lowercase characters in the address.)

I thought the i in eregi meant 'insensitive'...
 
N

Neredbojias

if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}

I'm not only not a wizard, I'm not even a sorceror's apprentice. But it
seems to me this regexp is overly sensitive to case. (It looks to me as
if it doesn't like lowercase characters in the address.)

Er, the "i" in "eregi" indicates case-insensitivity. (Sorry to be pedantic
but it's hard to get one-up on you.)

Also, I "studied" the regex and could find nothing definitely wrong
although not sure about the use of the circumflex there. And I'm far from
an "expert", too.
 
N

Neredbojias

Er, the "i" in "eregi" indicates case-insensitivity. (Sorry to be
pedantic but it's hard to get one-up on you.)

On second thought, maybe the _range_ "A-Z" actually _is_ causing a
problem... It would have to be checked and I don't have the time now.
 
E

Els

Neredbojias said:
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}

I'm not only not a wizard, I'm not even a sorceror's apprentice. But it
seems to me this regexp is overly sensitive to case. (It looks to me as
if it doesn't like lowercase characters in the address.)

Er, the "i" in "eregi" indicates case-insensitivity. (Sorry to be pedantic
but it's hard to get one-up on you.)

Also, I "studied" the regex and could find nothing definitely wrong
although not sure about the use of the circumflex there. And I'm far from
an "expert", too.

circumflex means 'at the start', just like $ means 'at the end'
(although I'm sure the way I just described that would invoke a
correction from a Jukka like PHP person ;-))

Here's one from another script I sometimes use:
if
(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($c['email'])))
{
echo "That is not a valid e-mail address.";
}

No idea why they didn't just use eregi and got rid of strtolower
though...
 
J

John Hosking

Neredbojias said:
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
I'm not only not a wizard, I'm not even a sorceror's apprentice. But it
seems to me this regexp is overly sensitive to case. (It looks to me as
if it doesn't like lowercase characters in the address.)

Er, the "i" in "eregi" indicates case-insensitivity. (Sorry to be pedantic
but it's hard to get one-up on you.)

Hey, no problem; I don't believe I've ever even *heard* of eregi before.
See how much I know about regular expressions? I just learned something,
so there's no reason to apologize.

(Correction: it's _impossible_ to get one-up on me. ;-) )
 
J

Jonathan N. Little

John said:
Hey, no problem; I don't believe I've ever even *heard* of eregi before.
See how much I know about regular expressions? I just learned something,
so there's no reason to apologize.

It's a PHP thing, the developers of PHP evidentially never heard of
functions arguments so you have to have a zillion functions for ever
possible application of a function, unlike terse Perl.

Ex: Perl's sort vs PHP's sort, asort, rsort, ksort, and on and on....
 
N

Neredbojias

circumflex means 'at the start', just like $ means 'at the end'
(although I'm sure the way I just described that would invoke a
correction from a Jukka like PHP person ;-))

That I was aware of, but what I don't know is why it would be necessary in
that expression. Wouldn't the code-line work without it, starting at the
beginning automatically? If not, I am at a loss to explain why.
Here's one from another script I sometimes use:
if
(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{
2,6})$",strtolower($c['email']))) {
echo "That is not a valid e-mail address.";
}

No idea why they didn't just use eregi and got rid of strtolower
though...

Me, neither, but 2 things. This line _has_ the lowercase a-z, the
_content_ of which is, of course, necessary, and it also has the beginning
circumflex. I'd sure like to see that explained... Also, does:

eregi("[A-Z]+");

include a-z or not?
 
N

Neredbojias

Neredbojias said:
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a
href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
I'm not only not a wizard, I'm not even a sorceror's apprentice. But
it seems to me this regexp is overly sensitive to case. (It looks to
me as if it doesn't like lowercase characters in the address.)

Er, the "i" in "eregi" indicates case-insensitivity. (Sorry to be
pedantic but it's hard to get one-up on you.)

Hey, no problem; I don't believe I've ever even *heard* of eregi
before. See how much I know about regular expressions? I just learned
something, so there's no reason to apologize.

(Correction: it's _impossible_ to get one-up on me. ;-) )

<grin>

I like php alot; I think it works much better than html overall. However,
the perl-purists tend to disparage it, and they may have a point with
regard to the efficiency of coding, etc. Still, it seems to fit my
abilities well, and regexes in general are wonderful in their power and
simplicity. I've become a little adept, esp. at the latter, but there are
many who know more.
 
E

Els

Neredbojias said:
That I was aware of, but what I don't know is why it would be necessary in
that expression. Wouldn't the code-line work without it, starting at the
beginning automatically? If not, I am at a loss to explain why.

Without the ^, this string would be accepted as well:
!!NOT AN EMAIL [email protected]
Email addresses aren't allowed to start with a dot or dash or anything
that's not a-z0-9.
Here's one from another script I sometimes use:
if
(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{
2,6})$",strtolower($c['email']))) {
echo "That is not a valid e-mail address.";
}

No idea why they didn't just use eregi and got rid of strtolower
though...

Me, neither, but 2 things. This line _has_ the lowercase a-z, the
_content_ of which is, of course, necessary, and it also has the beginning
circumflex. I'd sure like to see that explained... Also, does:

eregi("[A-Z]+");

include a-z or not?

I think it does. But that's just me thinking :)
 
B

Ben C

Neredbojias wrote: [...]
That I was aware of, but what I don't know is why it would be necessary in
that expression. Wouldn't the code-line work without it, starting at the
beginning automatically? If not, I am at a loss to explain why.

Without the ^, this string would be accepted as well:
!!NOT AN EMAIL [email protected]
Email addresses aren't allowed to start with a dot or dash or anything
that's not a-z0-9.

That sounds right. I don't know php but different languages vary in
whether regexes are "anchored" by default. So sometimes you need to
start them with ^.* if you want to find things in the middle of the
line, in other environments you have to start them with ^ if you wan't
the pattern to only match at the beginning. It doesn't hurt to be sure.
Here's one from another script I sometimes use:
if
(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{
2,6})$",strtolower($c['email']))) {
echo "That is not a valid e-mail address.";
}

No idea why they didn't just use eregi and got rid of strtolower
though...

Me, neither, but 2 things. This line _has_ the lowercase a-z, the
_content_ of which is, of course, necessary, and it also has the beginning
circumflex. I'd sure like to see that explained... Also, does:

eregi("[A-Z]+");

include a-z or not?

I think it does. But that's just me thinking :)

It often depends on your locale, and especially on LC_COLLATE. Sometimes
[A-Z] is in dictionary order, so means AaBbCcDd...Zz, meaning it will
include a-z. Sometimes it's in an order more like ascending codepoints,
which means it goes ABC..Z with abc...z outside, so [A-Z] won't match
lowercase.

On my system egrep [A-Z] doesn't match a-z but it probably would if my
locale was different (mine is "en_GB.UTF-8").

This means your script might match differently when installed on
different servers, although you'd need to check exactly what php does--
it may not use the locale or may use it optionally.
 
E

Els

Ben said:
Neredbojias wrote:
Me, neither, but 2 things. This line _has_ the lowercase a-z, the
_content_ of which is, of course, necessary, and it also has the beginning
circumflex. I'd sure like to see that explained... Also, does:

eregi("[A-Z]+");

include a-z or not?

I think it does. But that's just me thinking :)

It often depends on your locale, and especially on LC_COLLATE. Sometimes
[A-Z] is in dictionary order, so means AaBbCcDd...Zz, meaning it will
include a-z. Sometimes it's in an order more like ascending codepoints,
which means it goes ABC..Z with abc...z outside, so [A-Z] won't match
lowercase.

On my system egrep [A-Z] doesn't match a-z but it probably would if my
locale was different (mine is "en_GB.UTF-8").

This means your script might match differently when installed on
different servers, although you'd need to check exactly what php does--
it may not use the locale or may use it optionally.

Sounds like the safest bet would be to use A-z ?
 
S

Steven Saunderson

Sounds like the safest bet would be to use A-z ?

This might include the special chars between 'Z' and 'a' which is
probably not what is wanted here.
 
E

Els

Steven said:
This might include the special chars between 'Z' and 'a' which is
probably not what is wanted here.

Which special chars are between Z and a then? Noob here - I just
thought it would either go AaBbCc.. or ABC...XYZabc...xyz ?
 
B

Ben C

Ben said:
Neredbojias wrote:
Me, neither, but 2 things. This line _has_ the lowercase a-z, the
_content_ of which is, of course, necessary, and it also has the beginning
circumflex. I'd sure like to see that explained... Also, does:

eregi("[A-Z]+");

include a-z or not?

I think it does. But that's just me thinking :)

It often depends on your locale, and especially on LC_COLLATE. Sometimes
[A-Z] is in dictionary order, so means AaBbCcDd...Zz, meaning it will
include a-z. Sometimes it's in an order more like ascending codepoints,
which means it goes ABC..Z with abc...z outside, so [A-Z] won't match
lowercase.

On my system egrep [A-Z] doesn't match a-z but it probably would if my
locale was different (mine is "en_GB.UTF-8").

This means your script might match differently when installed on
different servers, although you'd need to check exactly what php does--
it may not use the locale or may use it optionally.

Sounds like the safest bet would be to use A-z ?

That's a good idea, although I don't have total confidence that it's
either AaBbCc... or ABC...abc... and not some other other strange order
in some locales.

[A-Za-z] is the safest, because it makes the fewest assumptions.
 
T

Toby A Inkster

Els said:
Which special chars are between Z and a then? Noob here - I just thought
it would either go AaBbCc.. or ABC...XYZabc...xyz ?

There are six characters between 'Z' and 'a': [\]^_`

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 15 min.]

Best... News... Story... Ever!
http://tobyinkster.co.uk/blog/2008/03/23/hypnotist/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top