Page 1 of 1

a few things I am trying to do with PHP form aren't working

Posted: Tue Oct 11, 2005 10:08 pm
by bruceg
I have added the follow code to try and validate the email part of my form, but it doesn't seem to be working.

the form can be found at: http://www.inspired-evolution.com/Contact_Form.php

what I want is legimate characters must be entered in the email field, so what I have added is:

Code: Select all

if(!eregi("^(.+)@(.+)\\.(.+)$",$_POST['email']))
{
 $error_msg .= "<BR />Your email appears to be invalid.";
 $ok = "false";
}
the form part is:

<input id="email" name="email" type="text" value="{$_POST['email']}" />

another function that isn't working is I wanted the form field to be hilighted when no information is entered, so I tried this:

Code: Select all

<input class="<? if($error_msg){ echo "error"; } ELSE { echo
"normal"; } id="firstname" name="firstname" type="text" value="{$_POST['firstname']}"? />"
and to my css:

form.info_request input.normal {
border: 2px inset #666;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}

form.info_request input.error {
border: 2px inset red;
margin:0;
font-family: arial, helvetica, sans-serif;
color: #036;
width: 15em;
padding-left: .25em;
font-weight: bold;
background: #eee;
}

this doesn't work either.

Please advise as to how I can get these ideas to work!

Posted: Wed Oct 19, 2005 10:38 am
by kendall
I have added the follow code to try and validate the email part of my form, but it doesn't seem to be working.
Do a search for my name under regular expressions or email, mail form and see what u come up with i think i develop a regs pattern to test for email
another function that isn't working is I wanted the form field to be hilighted when no information is entered, so I tried this:
i think your CSS is wrong (not a css person)[/quote]

but shouldnt it be

Code: Select all

.error{
// style for error field
}

Re: a few things I am trying to do with PHP form aren't wor

Posted: Wed Oct 19, 2005 1:58 pm
by Roja
bruceg wrote:what I want is legimate characters must be entered in the email field, so what I have added is:
"Legitimate characters" in email addresses is a VERY large field. Save yourself a headache, and refer here:

viewtopic.php?t=38863