Thanks for your help Bastien.  I have it all working now, no problems.  I also 
have generated a Unique ID for the form also.
   
  Jerry

Bastien Koert <[EMAIL PROTECTED]> wrote:
  
You are in serious need of some regex here...google email regex and you will 
have enough results to get you what you want.

Postal Code (assume 2 letters 4 dgits in that order

if (ereg("^[A-Z]{2}{0-9]{4}$",$_POST['postal'])){
...

As for pasting it back to the form, I would suggest you have the form as a 
function and the processing code as a function, then you can pass the post 
arrays back and forth and pass the error handling along with it

Bastien

>From: JeRRy 
>To: php-db@lists.php.net
>Subject: [PHP-DB] php/sendmail help!
>Date: Tue, 7 Feb 2006 13:22:53 +1100 (EST)
>
>Hi, I have a form, form results are PUSHED to another page and processed. 
>Files below. (in plain-tet)
>
> Now this is what I want to do:
>
> 1) Make all fields required input, but if easy to configure I want to 
>have rules for each textarea. For instance an email address must contain a 
>'@' symbol. Must be at leat 5 character longs and must be in a form of an 
>email address. So if I type [EMAIL PROTECTED] it would produce an error, 
>highlighting 
>the error area or display a message at the top of the page. Postcode 
>should contain 4 numbers and numbers only, etc. The only field that can be 
>left blank will be the message area. How do I achieve this? (message 
>regarding this below)
>
> 2) I want to add to the form a UNIQUE ID generater. I will add a new 
>hidden form field for this. I need a script called by PHP to generate it. 
>Would include both letters and numbers and be atleast 8 CHARS long.
>
> As for 1) I have tried some javascript but it failed, since I PUSH all 
>field responses to another page. When i add it the submit button fails and 
>does not push the results through. But it produces the error fine, but 
>form is not PUSHED on. So it seems it's lost because of the javascript. 
>So i took it out completely. I think there is a way in PHP to call errors 
>for forms? But anways, here are the files below. Please help, I am on a 
>tight schedule here if anyone can assist me.
>
> file one looks like this: (form.php)
>
> 
>   
>     
>   
>   
>   
> 
>   Pre Order Form!
>   >BORDER="0">
>   
>
>      First Name:   [input] >MAXLENGTH="20">
    
>Last Name:   [input] >MAXLENGTH="25">    
>    Company:   [input] >MAXLENGTH="25">
    
>Unit/House #:   [input] >MAXLENGTH="6">
    
>Street Name:   [input] >MAXLENGTH="25">
    
>Suburb/Town:   [input] >MAXLENGTH="25">
    
>Post Code/Zip:   [input] >MAXLENGTH="25">
    
>Phone #:   [input] >MAXLENGTH="25">
    
>Email Address:   [input] >MAXLENGTH="25">
      
>
    Country:  >SIZE="1">AUSTRALIANEW >ZEALANDFIJIUNITED 
>KINGDOMGERMANYSWEDENCANADA-----------------AFGHANISTANALBANIAALGERIAAMERICAN 
>SAMOAANDORRAANGOLAANGUILLAANTARCTICAANTIGUA >AND 
>BARBUDAARGENTINAARMENIAARUBAAUSTRIAAZERBAIJANBAHAMASBAHRAINBANGLADESHBARBADOSBELARUSBELGIUMBELIZEBENINBERMUDABHUTANBOLIVIABOSNIA
 >AND HERZEGOWINABOTSWANABOUVET >ISLANDBRAZILBRITISH INDIAN OCEAN 
TERRITORYBRUNEI >DARUSSALAMBULGARIABURKINA> 
>FASOBURUNDICAMBODIACAMEROONCANADACAPE >VERDECAYMAN ISLANDSCENTRAL AFRICAN 
>REPUBLICCHADCHILECHINACHRISTMAS >ISLANDCOCOS (KEELING) 
>ISLANDSCOLOMBIACOMOROSCONGOCOOK >ISLANDSCOSTA RICACOTE D'IVOIRECROATIA (local 
name: >Hrvatska)CUBACYPRUSCZECH >REPUBLICDENMARKDJIBOUTIDOMINICADOMINICAN 
>REPUBLICEAST TIMORECUADOREGYPTEL >SALVADOREQUATORIAL 
>GUINEAERITREAESTONIAETHIOPIAFALKLAND >ISLANDS (MALVINAS)FAROE 
>ISLANDSFIJIFINLANDFRANCEFRANCE, >METROPOLITANFRENCH GUIANAFRENCH 
POLYNESIAFRENCH>
 >OTHERGABONGAMBIAGEORGIAGERMANYGHANAGIBRALTARGREECEGREENLANDGRENADAGUADELOUPEGUAMGUATEMALAGUINEAGUINEA-BISSAUGUYANAHAITIHEARD
 > >AND MC DONALD ISLANDSHONDURASHONG >KONGHUNGARYICELANDINDIAINDONESIAIRAN 
 >>(ISLAMIC REPUBLIC 
 >>OF)IRAQIRELANDISRAELITALYJAMAICAJAPANJORDANKAZAKHSTANKENYAKIRIBATIKOREAKUWAITKYRGYZSTANLATVIALEBANONLESOTHOLIBERIALIBYAN
 > >ARAB JAMAHIRIYALIECHTENSTEINLITHUANIALOCATION NOT 
 >>REPORTEDLUXEMBOURGMACAUMACEDONIAMADAGASCARMALAWIMALAYSIAMALDIVESMALIMALTAMARSHALL>
 > >ISLANDSMARTINIQUEMAURITANIAMAURITIUSMAYOTTEMEXICOMICRONESIAMOLDOVA, 
 >>REPUBLIC 
 >>OFMONACOMONGOLIAMONTSERRATMOROCCOMOZAMBIQUEMYANMARNAMIBIANAURUNEPALNETHERLANDSNETHERLANDS
 > >ANTILLESNEW CALEDONIANEW >ZEALANDNICARAGUANIGERNIGERIANIUENORFOLK 
 >>ISLANDNORTHERN MARIANA ISLANDSNORWAYNot 
 >>AvailableOMANPAKISTANPALAUPANAMAPAPUA >NEW 
 >>GUINEAPARAGUAYPERUPHILIPPINESPITCAIRNPOLANDPORTUGALPUERTO 
 >>RICOQATARREUNIONROMANIARUSSIAN >FEDERATIONRWANDASAINT KITTS AND NEVISSAINT 
 >>LUCIASAINT VINCENTSAMOASAN MARINOSAO TOME >AND PRINCIPESAUDI
 >ARABIASENEGALSEYCHELLESSIERRA> LEONESINGAPORESLOVAKIA (Slovak 
 >>Republic)SLOVENIASOLOMON >ISLANDSSOMALIASOUTH AFRICASOUTH GEORGIA >SPAINSRI 
 >LANKAST. HELENAST. PIERRE AND 
 >>MIQUELONSUDANSURINAMESWAZILANDSWEDENSWITZERLANDSYRIAN >ARAB REPUBLICTAIWAN, 
 >PROVINCE OF >CHINATAJIKISTANTANZANIA, UNITED REPUBLIC 
 >>OFTHAILANDTOGOTOKELAUTONGATRINIDAD >AND TOBAGOTUNISIATURKEYTURKMENISTANTURKS 
 >>AND CAICOS ISLANDSTUVALUUGANDAUKRAINEUNITED >ARAB EMIRATESUNITED 
 >KINGDOMUNITED STATESUNITED >STATES MINORUNKNOWN 
 >>LOCATIONURUGUAYUZBEKISTANVANUATUVATICAN >CITY STATE (HOLY SEE)VENEZUELAVIET 
 >NAMVIRGIN >ISLANDS (BRITISH)VIRGIN ISLANDS (U.S.)WALLIS AND FUTUNA 
 >>ISLANDSWESTERN> >SAHARAYEMENZAMBIAZIMBABWE    Message: 
>
>  <br>>
>      
>  [input] 
> 
> 
>  

>
>
>
>

> 
>
>
>
>
>
>
>
>--end--
>
> here is file 2: resultsubmit.php
>
> 
>   
>     
>   
>   
>   
> 
> > $to = '[EMAIL PROTECTED]';
> $from = '[EMAIL PROTECTED]';
>
> //Check if we have something POSTed by the form.
> if (isset($HTTP_POST_VARS)){
> //Start with an empty body for the mail message
> $body = '';
> //Iterate through all the POSTed variables, and add them to 
>the message body.
> while (list($key, $value) = each($HTTP_POST_VARS)){
> $body .= $key . ' = ' . $value . "
> ";
> }
> //Build up some nice From/Reply Headers
> $headers = "From: $from";
> //Mail the message out.
> //Requires setting php3.ini sendmail path as per instructions
> $success = mail($to, "Posted " . date("m/d/Y"), $body, 
>$headers);
> //Always check return codes from functions.
> if ($success){
> echo "  Please wait... Your request is being 
>processed...!";
> }
> else{
> echo "  Internal Error: Your input was 
>unprocessed.
Contact $from";
> }
> }
> ?>
>

> 
> 
>
> 
>
>
> --end--
>
>
> FYI I have changed some email settings and configuration files for 
>security reasons. But as you can see results are pushed to the second file 
>than emailed off, no need for a database or anything. So you should be 
>able to test very easily.
>
> If anyone can help with suggestions or even do the code it would be 
>mostly appreciated, can pay since it's urgent.
>
> Thanks for your time!
>
> J



Reply via email to