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

Discussion in 'HTML' started by Mike Barnard, Mar 25, 2008.

  1. Mike Barnard

    Mike Barnard Guest

    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.
     
    Mike Barnard, Mar 25, 2008
    #1
    1. Advertising

  2. Mike Barnard

    Els Guest

    Mike Barnard wrote:

    > 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>";
    }

    --
    Els http://locusmeus.com/
     
    Els, Mar 26, 2008
    #2
    1. Advertising

  3. Mike Barnard

    Ben C Guest

    On 2008-03-25, Mike Barnard <> wrote:
    > 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.
     
    Ben C, Mar 26, 2008
    #3
  4. Mike Barnard

    Mike Barnard Guest

    On Wed, 26 Mar 2008 08:57:24 +0100, Els <>
    wrote:

    >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.
     
    Mike Barnard, Mar 26, 2008
    #4
  5. Mike Barnard

    John Hosking Guest

    Re: HELP! Again. I seem to have some padding I can't get rid of anda PHP problem.

    Els wrote:
    > Mike Barnard wrote:
    >
    >>
    >> www.thermachek.co.uk/
    >>


    > 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?


    --
    John
    Read about the UIP: http://improve-usenet.org/
     
    John Hosking, Mar 26, 2008
    #5
  6. Mike Barnard

    Els Guest

    John Hosking wrote:

    > Els wrote:
    >> Mike Barnard wrote:
    >>
    >>>
    >>> www.thermachek.co.uk/
    >>>

    >
    >> 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'...

    --
    Els http://locusmeus.com/
     
    Els, Mar 26, 2008
    #6
  7. Mike Barnard

    Neredbojias Guest

    On 26 Mar 2008, John Hosking <> wrote:

    >> 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.

    --
    Neredbojias
    http://www.neredbojias.com/
    Great sights and sounds
     
    Neredbojias, Mar 26, 2008
    #7
  8. Mike Barnard

    Neredbojias Guest

    On 26 Mar 2008, Neredbojias <> wrote:

    >> 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.)


    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.

    --
    Neredbojias
    http://www.neredbojias.com/
    Great sights and sounds
     
    Neredbojias, Mar 26, 2008
    #8
  9. Mike Barnard

    Els Guest

    Neredbojias wrote:

    > On 26 Mar 2008, John Hosking <> wrote:
    >
    >>> 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...

    --
    Els http://locusmeus.com/
     
    Els, Mar 26, 2008
    #9
  10. Mike Barnard

    John Hosking Guest

    Re: HELP! Again. I seem to have some padding I can't get rid of anda PHP problem.

    Neredbojias wrote:
    > On 26 Mar 2008, John Hosking wrote:
    >
    >>> 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. ;-) )


    --
    John
    Now, I wouldn't mind being a *pinball* wizard.
     
    John Hosking, Mar 27, 2008
    #10
  11. Re: HELP! Again. I seem to have some padding I can't get rid of anda PHP problem.

    John Hosking wrote:
    > Neredbojias wrote:
    >> On 26 Mar 2008, John Hosking wrote:


    >> 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.
    >


    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....

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Mar 27, 2008
    #11
  12. Mike Barnard

    Neredbojias Guest

    On 26 Mar 2008, Els <> wrote:

    > Neredbojias wrote:
    >> 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 ;-))


    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?

    --
    Neredbojias
    http://www.neredbojias.com/
    Great sights and sounds
     
    Neredbojias, Mar 27, 2008
    #12
  13. Mike Barnard

    Neredbojias Guest

    On 26 Mar 2008, John Hosking <> wrote:

    > Neredbojias wrote:
    >> On 26 Mar 2008, John Hosking wrote:
    >>
    >>>> 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.

    --
    Neredbojias
    http://www.neredbojias.com/
    Great sights and sounds
     
    Neredbojias, Mar 27, 2008
    #13
  14. Mike Barnard

    Els Guest

    Neredbojias wrote:
    > On 26 Mar 2008, Els <> wrote:
    >> Neredbojias wrote:
    >>> 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 ;-))

    >
    > 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 ADDRESS!!!!
    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 :)

    --
    Els http://locusmeus.com/
     
    Els, Mar 27, 2008
    #14
  15. Mike Barnard

    Ben C Guest

    On 2008-03-27, Els <> wrote:
    > 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 ADDRESS!!!!
    > 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.
     
    Ben C, Mar 27, 2008
    #15
  16. Mike Barnard

    Els Guest

    Ben C wrote:
    > On 2008-03-27, Els <> wrote:
    >> 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 ?

    --
    Els http://locusmeus.com/
     
    Els, Mar 27, 2008
    #16
  17. On Thu, 27 Mar 2008 10:38:49 +0100, Els <> wrote:

    > 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.
    --
    Steven
     
    Steven Saunderson, Mar 27, 2008
    #17
  18. Mike Barnard

    Els Guest

    Steven Saunderson wrote:

    > On Thu, 27 Mar 2008 10:38:49 +0100, Els <> wrote:
    >
    >> 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.


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

    --
    Els http://locusmeus.com/
     
    Els, Mar 27, 2008
    #18
  19. Mike Barnard

    Ben C Guest

    On 2008-03-27, Els <> wrote:
    > Ben C wrote:
    >> On 2008-03-27, Els <> wrote:
    >>> 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.
     
    Ben C, Mar 27, 2008
    #19
  20. Re: HELP! Again. I seem to have some padding I can't get rid of and aPHP problem.

    Els wrote:

    > 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/
     
    Toby A Inkster, Mar 27, 2008
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack Schafer
    Replies:
    1
    Views:
    533
    Joe Smith
    Apr 23, 2004
  2. Sharon Lee
    Replies:
    2
    Views:
    390
    Sharon Lee
    Dec 31, 2003
  3. dolphin
    Replies:
    3
    Views:
    367
    rossum
    Mar 9, 2007
  4. Replies:
    6
    Views:
    543
    Chris F.A. Johnson
    Oct 20, 2007
  5. Rajive Narain
    Replies:
    0
    Views:
    1,860
    Rajive Narain
    Sep 18, 2009
Loading...

Share This Page