Lillin
Starting Member
2 Posts |
Posted - 2007-03-17 : 10:31:24
|
Hi,I am just learning SQL (love it though so far). I was wondering if someone could help me out with understanding this:A site I am working on has a SQL Database with a mailing list form - that is extremely basic..two fields name and email. The client is concerned because to many errors appear on the email address text list. I would like to add better error control to the script..which currently is:<!-- Start of FORM --> <?if($_POST['submit']){ mysql_connect("lutee","database123","words4u"); mysql_select_db("database123"); $name = $_POST['name']; $email = $_POST['email']; $result=MYSQL_QUERY("INSERT INTO mailer (id,name,email)". "VALUES ('NULL', '$name', '$email')"); include('sent.php'); }else{?><form method="post" action="index.php"><TABLE width="806" align="center" id="mailform"> <TR> <TD class="style4">Name:</TD> <TD><INPUT TYPE='TEXT' NAME='name' VALUE='' size=40></TD> </TR> <TR> <TD class="style4">Email:</TD> <TD><INPUT TYPE='TEXT' NAME='email' VALUE='' size=40></TD> </TR><br> <TR> <TD></TD><br> <TD><INPUT TYPE="submit" name="submit" value="submit"></TD> </TR></TABLE></form><?}?><!-- /End of FORM -->okay - so i foud this script online - wondering if and how i should combine the two...CREATE OR REPLACE FUNCTION EMAILVALIDATE_V1(email VARCHAR2) RETURN NUMBER IS t_valid NUMBER(1); t_totallen NUMBER(2); t_counter NUMBER(2):=0; t_atpos NUMBER(2):= 1; i NUMBER(2) := 1; t_pointpos NUMBER(2):= 1; mail_ch VARCHAR2(1); BEGIN t_totallen := LENGTH(email); t_counter := t_totallen; i := 1; t_valid := 1;------------------------------------------------------------------------------------- IF LENGTH(ltrim(rtrim(email))) = 0 THEN t_valid := 0; ELSE--------------------------------------------------------------------------------------- --This is to check special characters are present or not in the email ID t_counter := t_totallen; WHILE t_counter > 0 LOOP mail_ch := substr(email,i,1); i := i+1; t_counter := t_counter -1; IF mail_ch IN (' ','!','#','$','%','^','&','*','(',')','-','','"', '+','|','{','}','[',']',':','>','<','?','/','\','=') THEN t_valid := 0; EXIT; END IF; END LOOP; --------------------------------------------------------------------------------------- --This is to check more than one '@' character present or not t_atpos := instr(email,'@',1,2) ; IF t_atpos > 1 then t_valid := 0; END IF; --------------------------------------------------------------------------------------- --This is to check at minimum and at maximum only one '@' character present t_atpos := instr(email,'@',1) ; IF t_atpos IN (0,1) THEN t_valid := 0; END IF; --------------------------------------------------------------------------------------- --This is to check at least one '.' character present or not t_pointpos := instr(email,'.',1) ; IF t_pointpos IN (0,1) THEN t_valid := 0; END IF; --------------------------------------------------------------------------------------- END IF; RETURN t_valid;END;so curious and thanks in advance-lili |
|