FormToEmail is not validating the fields

Hi all
iam newto contact form n php downloaded FormToEmail.php from dreamweaverspot.
The issue is email is working even if i submit blank form.
my page link http://fagencomputers.com/contact.html.
Can anyone help me how to validate the form using php?
thanks in advance,
naveen
here is the php script
<?php
$my_email = "[email protected]";
Enter the continue link to offer the user after the form is sent.  If you do not change this, your visitor will be given a continue link to your homepage.
If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"
$continue = "/";
Step 3:
Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace.  IMPORTANT - The file name is case sensitive!  You must save it exactly as it is named above!  Do not put this script in your cgi-bin directory (folder) it may not work from there.
THAT'S IT, FINISHED!
You do not need to make any changes below this line.
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Check all fields for an email header.
function recursive_array_check_header($element_value)
global $set;
if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc: )/i",$element_value)){$set = 1;}}
else
foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
recursive_array_check_header($_REQUEST);
if($set){$errors[] = "You cannot send an email header";}
unset($set);
// Validate email field.
if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}
$_REQUEST['email'] = trim($_REQUEST['email']);
if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
// Check for a blank form.
function recursive_array_check_blank($element_value)
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
// Display any errors and exit if errors exist.
if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
// Build message.
function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
$message = build_message($_REQUEST);
$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";
$message = stripslashes($message);
$subject = "FormToEmail Comments";
$headers = "From: " . $_REQUEST['email'];
mail($my_email,$subject,$message,$headers);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Dreamweaver Tutorial - Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.thanks {
    text-align:center;
    margin-right: auto;
    margin-left: auto;
    font-family: Geneva, Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #333333;
    width: 475px;
    margin-top: 290px;
    margin-bottom: 0px;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;
    font-weight: normal;
body {
    background-image: url(../images/01-main-copy.jpg);
    background-repeat: no-repeat;
    background-position: center top;
    background-color: #B7E4F9;
a:link {
    color: #0066CC;
    text-decoration: none;
a:visited {
    text-decoration: none;
    color: #006699;
a:hover {
    text-decoration: underline;
    color: #FF6600;
a:active {
    text-decoration: none;
.style3 {
    color: #0066CC;
    font-weight: bold;
.logo {
    color: #0066CC;
    font-weight: bold;
    float: left;
.text {
    float: right;
    padding-top: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    padding-left: 20px;
    font-weight: normal;
-->
</style>
</head>
<body text="#000000">
<div class="thanks">
<div class="logo"><b><a href="<?php print $continue; ?>"><img src="../images/logo.png" alt="fagen" width="216" height="86" border="0"></a><br>
</div>
<center>
<div class="text">
Thank you <?php print stripslashes($_REQUEST['name']); ?>
<br>
Your message has been sent
<p class="style3"><a href="<?php print $continue; ?>"><strong>Click here to continue</strong></a></p>
</div>
</center>
</div>
</body>
</html>

Hi All,
Thanks for reading my post,
I found a very cool javascript called gen_validatorv4 to validate the formtoemail.php
check this link.
http://www.javascript-coder.com/html-form/form-validation.phtml
thanks again
naveen

Similar Messages

  • DYNP_VALUES_UPDATE not Updating the Field on my Dynpro

    Hi.
    I want to create a dynpro where two fields are. Field 1 allows the user to enter a customer number, field two shall come up with a number that is calculated somehow. The calculation can last up to 20 seconds, so I dont want to make the user waite for this number.. .he shall be able to work with the rest of the dynpro.
    Therefore I called the function that does the calcuiation like that:
    MODULE user_command_0100 INPUT.
      DATA: lv_guid_16 TYPE guid_16.
      IF kna1-kunnr IS NOT INITIAL AND kna1-kunnr <> gv_kunnr
        CALL FUNCTION 'GUID_CREATE'
          IMPORTING
            ev_guid_16 = lv_guid_16.
        gv_taskid = lv_guid_16+8(8).
        CALL FUNCTION 'YDETERMINE_DEPOTDISTANCE' 
          STARTING NEW TASK gv_taskid
          PERFORMING receive_depent ON END OF TASK
          EXPORTING
            i_kunnr = kna1-kunnr.
      ENDIF.
    ENDMODULE. 
    The next piece of code shall get the returning value if the function wants to return its results.
    FORM receive_depent USING i_task TYPE clike.
      TABLES: d020s.
      DATA: dyname LIKE d020s-prog,
            dynumb LIKE d020s-dnum.
      DATA: BEGIN OF dynpfields OCCURS 1.
              INCLUDE STRUCTURE dynpread.
      DATA: END OF dynpfields.
      IF i_task = gv_taskid.
        RECEIVE RESULTS FROM FUNCTION 'YDETERMINE_DEPOTDISTANCE'
        IMPORTING
          e_depent         = kna1-yydepent
          e_accuracy       = gv_accuracy.
        MOVE 'KNA1-YYDEPENT' TO dynpfields-fieldname.
        MOVE kna1-yydepent TO dynpfields-fieldvalue.
        APPEND dynpfields.
        dyname = sy-cprog.
        dynumb = '0100'.
        CALL FUNCTION 'DYNP_VALUES_UPDATE'
          EXPORTING
            dyname               = dyname
            dynumb               = dynumb
          TABLES
            dynpfields           = dynpfields
          EXCEPTIONS
            invalid_abapworkarea = 01
            invalid_dynprofield  = 02
            invalid_dynproname   = 03
            invalid_dynpronummer = 04
            invalid_request      = 05
            no_fielddescription  = 06
            undefind_error       = 07.
        ASSERT sy-subrc = 0.
      ENDIF.
    Problem is: The DYNP_VALUES_UPDATE does not update the field on my dynpro at all. If I hit enter another time, then the field is provided by the value as another PBO will be processed. What is my mistake here?
    Regards
    Manfred
    Edited by: Rob Burbank on Oct 29, 2010 12:07 PM

    Hi Manfred,
    Replace all the DYNP_VALUES_UPDATE-related content by the following statement:
    SET USER-COMMAND 'xxx'.
    While DYNP_VALUES_UPDATE does update the fields, a roundtrip is not triggered so the content of the fields will not be refreshed. The SET USER-COMMAND does that.
    Hope this helps you!
    Cheers, Roel

  • Idocs not populating the fields

    Hi
    We are using Extended Classic Scenario. After the shopping cart is approved, the PO is generated in the backend R/3. The PO is generated in the backend and the idoc is triggered which is sent to supplier.
    The problem we are facing is as below:
    There are some fields in the idocs which are not getting populated. We are using badi implementation BBP_PO_INBOUND_BADI in the backend. We have used both the methods BBP_MAP_BEFORE_BAPI
    BBP_MAP_AFTER_BAPI
    The table EKPO is getting updated but the idoc does not have the fields.
    Also when we are second time retriggering the output the idoc is having the required fields.
    Kindly advice.
    Thanks and Regards
    Manoj

    Hello,
    It looks the first generation occurs to early in the process.
    Can you should check the processing time you defined in condition records ?
    3 is too early, 4 should work because a commit work is done before. And at worst set it to 1 (selection report) and schedule a job to process the message.
    Rgds,
    Pierre

  • Client would like the monetary fields to reflect . and not , in the fields.

    Client would like the monetary fields to reflect . and not , in the fields. There are commas and he wants decimals.
    can any one help me out, this is a tkt  can any one suggest me how do we take it further.

    Hi Jai Ram,
    Ask the user to go to SU3 tcode. Then go to defaults tab. There is a field called Decimal Notation. There are three formats as below
    1.234.456,789
    1,234,456.789
    1 234 456,789
    Select accordingly. Then quit SAP and relogin. The changes will be applied.
    Kind Regards
    sandeep

  • 2147189176 :Logon failed. Details:Could not open the field definition file

    Dear All..
    I get error message when i want to export my report to PDF, like this :
    2147189176 :Logon failed. Details:Could not open the field definition file.
    For information, i'm using database Oracle 10g, Crystal Report XI release 2, and Classic ASP as programming language.
    Can you help me for resolve this problem?
    Thanks for all.
    Regards,
    Yuni

    Let's throw SP 6 for CR XI R2 at this first:
    https://smpdl.sap-ag.de/~sapidp/012002523100015859952009E/crxir2win_sp6.exe
    Next. The error indicates that the report is created off of TTX files. If the SP above does to help, please specify the type of connection used in the report. Also, the OS and is it 32 or 64 bit OS?
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup

  • APO - /SAPAPO/SD_DOC not showing the fields

    Hello..We did set the field "FIXMG' and its value in US_CATALOGUE structure on ECC side and after ATP run (sales order) we are not picking up field value on APO side in table "/SAPAPO/SD_DOC". Please advise.  Do we need to add any BADI or userexits on APO side to populate this table.
    Thank you!.

    Hi,
    The FIXMG field is usually transfered in the requirement table and not in the field catalogue. If you want to have it in the field catalogue you need to add this in the userexit in R/3 (please check note 379196 and 385039). Afterwards you will find the additional fields in table /SAPAPO/SDFIELD. The table /SAPAPO/SD_DOC contains just the "standard" fields.
    Hope this helps.
    best regards,
    Michael

  • Hi, i am working in E.C.C. 6.0 , IN SMARTFORMS i am not getting the fields

    Hi, i am working in E.C.C. 6.0 , IN SMARTFORMS i am not getting the fields from field list on/off?

    Hiii
    dont worry u will get fields but u wont drag and paste it in ur text
    regards
    Jaipal

  • Can not change the field property - 10gR2 reports crashing on Linux :(

    All I want to do, is to change one field's property from NUMBER to DATE in the property palette. It does not allow me to do it (not east like forms). I can not change the field property - 10gR2 reports keep crashing on Linux :(
    I don't know if this is a Linux specific iDS issue, or a generic one.
    What are the proper steps to change one field (in my query, the field name is ptime, it was defined as a number field originally, and now I need to change it to DATE and apply the proper format mask). The matching database field definition was modified from number to date.
    very frustrating...
    Any input is appreciated.
    Message was edited by:
    zaferaktan

    nop, did not change anything in the select statement at all. Just selected the related query under the data model (in the navigator), then selected the related query from within the property panel, connected to the db, then from the related navigor menu selected compile all, when the related query was highlighted (selected). Then I saved it, checked the groups, and bingo - the datatype was changed from number to date. Then I went to the related object under the page layout and applied the format mask (that was another funny story). And it worked. It is not as flexible as the forms for sure - pain in the a.. And I still don't know why Reports Builder keeps crashing on Linux - have no problems with Forms Developer on Linux at all. It is a certified RH platform with all the required libs, rpms, etc installed. I am certain it is not an installation issue. Maybe I should check Metalink and apply if an iDS 10gR2 patch exists for reports.

  • I purchased Lightroom from Amazon.  When I go to register, the license key from amazon does not match the fields in the software.  I am stuck.

    I need help registering Lightroom.  Purchased from Amazon.  The license key Amazon provided did not match the fields when activating the software.  Help!

    Maybe Amazon provided a redemption code not a license key:
    https://redeem.licenses.adobe.com/getserial

  • Validating the field

    I want to maka a select of table febko based on condition that field AZIDT's first seven character is given in the select-options
    i.e my selection should be based only on the seven characters of the field which is given by the user
    Regards,
    jaga.

    The Visual Composer is a composition tool, you can do the same in very different ways, this is not a fix tool with only one way to do it...
    I'm sad you think that this forum do not help you, but maybe with playing a bit with the storyboard you will get the answer that you're looking for.
    Also in you case you give us very small details, you asked how to validate an input and we answered you...(with drop-down list or by using validation rules)
    Maybe you're asking for a formula but what kind of formula you want ? which datasources you want to use ? what kind of result are you expecting...
    So, again, i think we give you the tricks, now you have to adapt it to use in the right way...
    Kind Regards,
    Luis
    Nikhil Bansal  
    Posts: 331
    Questions: 139
    Registered: 12/20/06
    Forum points: 10 
       Re: How to validate the input field  
    Posted: Jun 25, 2007 10:21 AM    in response to: Luis Felipe Lanz       Reply      E-mail this post 
    Hi Luis,
    My question was very simple.
    I just want to check if the input field contains the characters 'a-z' or 'A-Z'. If any character is present then say onBlur or onSubmit there should be an error message.
    Can you give me a formula for this requirements. Shall be glad if I get.
    Regards
    rewards point

  • FPM application - Not validating the Input at Review time

    Hello Guru,
    I am creating new FPM application from existing, as we have some issues in existing application. In existing application when I click on Review button it will fire below FPM event and validate the data and gives error message if any validation error.
    fpm.raiseReviewAndSaveEvent(IFPM.EVENT_REVIEW, IFPM.EVENT_SAVE,
    new VAC("Old DC Name", "Old Component Name" ));
    In my new application when I click on Review button it does not validate the data and even not display validation error messages. I have changed according to my new DC as below.
    fpm.raiseReviewAndSaveEvent(IFPM.EVENT_REVIEW, IFPM.EVENT_SAVE,
    new VAC("New DC Name", "New Component Name" ));
    My question is how FPM konws which fields it has to validate?
    Do I have to mention this information somewhere, if yes then how Can I put information for my new DC?
    Hope this helps to understand my requirements.
    Your help will be appreciated.
    Thanks,
    Ameet

    Hi,
    Please double check if MCU on FE server works well, when two participants are connected, the session is essentially peer-to-peer. When three or more participants are connected, the Application Sharing feature depends on the Front End Server Multi Point Control
    Unit (MCU) to provide the sharing stream to all parties.
    Please check if port 5065/TCP is available on Front End server.
    Please also troubleshooting with the help of Recommended Steps part in the link below:
    http://blogs.technet.com/b/nexthop/archive/2012/11/05/lyncmd-troubleshooting-lync-server-2010-application-sharing-internal-and-remote-scenarios.aspx
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • Work order should not update the fields in PR

    Hi  Gurus
    My requirements is that workorder should not updates the purchasing data fields in PR  do not go to the shoping cart. How can make it possible.
    Thanks in Advance

    Hi,
          I am not sure of your requirement clearly but check up the below user exits :-
    COZF0001 Change purchase req. for externally processed operation
    COZF0002 Change purchase req. for externally procured component
    or BADI :- IWO1_PREQ_BADI BAdI for Manipulation of P.Reqs from Orders + Networks ,SE18
    regrds
    pushpa

  • Results from a form submission does not keep the fields in order when I get the email

    I created a form and it works fine but when I get the email
    back the fields are out of the tab order or out of wack meaning
    they are not in order that I set the acceptabilities to.
    Is this something in the Action script I have to add and what
    would it look like or do I need to edit the CGI script?
    I can provide a link or script let me know.
    Thanks

    This is action script 3.0 Flash CS3
    Below is what I receive back after I test it but it is not in
    order. I guess I assumed that if the tab order is correct and the
    are layout in that order and the code in the form is in order it
    would come back the same way. Mostly I am trying to narrow down the
    problem and my guess is the cgi script or am I wrong? I have
    attached the code for the form.
    Thank You for you time
    Form email submission results:
    Below is what you submitted on Tuesday, February 19, 2008 at
    10:35:08
    list:
    phone:
    address:
    comments:
    city:
    state:
    zip:
    name:

  • Report query not returning the field value from external table

    hi
    I have an issue regarding reports. I have a query having 4 fields from external table and remaining from db tables. the report query returns all the fields from the db tables and only 2 fields from external table. but the same query if I tried in plsql developer it returns all the fields values.
    Can anyone please help me in this issue.
    Thanks and Regards
    kk

    Duplicate post?
    value not displaying in report whereas it returns in plsql developer
    value not displaying in report whereas it returns in plsql developer
    Please log a SR if you do not get any reply to your thread instead of creating new one.
    Thanks,
    Hussein

  • Could not find the fields in Flat file, But able to see the fields in receiver Communcication channel

    Hi All,
    My scenario is Proxy to file, After testing my scenario the flatfile is getting generated without any errors.
    I can able to see all the fields in receiver communication channel payload. But some fields are missing in flatfile which is generated after conversion.
    This is my structure below
    Record
    ---Header
          a
          b
          e
          g
    ---Trailer
          c
          d
    ---Details
          e
          f
    And here is my content  conversion below
    Header.fieldFixedLengths   2,4,6,7
    Header.endSeparator         'nl'
    Trailer.fieldFixedLengths     3,5
    Trailer.endSeparator           'nl'
    Details.fieldFixedLengths    6,7
    Details.endSeparator          'nl'
    Actually in header there are nearly 34 fields, I can able to see all the 34 fields in reciever CC, But in generated flat file I can able to see only first 30 fields remaing 4 are missing in flat file.
    it is like in the above structure In Header there are a,b,e,g fields.I am getting a, b fields e and f are missing in flatfile.
    Thanks in advance.
    Please suggest me the solution.
    Thanks & Regards,
    Satish

    Hi Satish
    As you said 4 fields values are missing out of 34. Are those fields values are coming as blank in the file or not at all coming.
    Ex:
    you have 4 fields a,b,e,g and in channels you have defined length as 2,4,6,7
    If values for fields a,b,e,g are coming as 1,22,33,44444 respectively then the flat file is generated as
    1-22--33----4444--- (Consider - as space here)
    Now if you say e and g value then is the flat file generated as
    1-22---------------
    or
    1-22--
    Regards
    Osman

Maybe you are looking for

  • Help moving files from G3 imac (OS 8.7)

    Howdy. I recently pulled the old imac ( 1999) out of the closet and gave it to my nine year old daughter . It does not have any way to transfer data other than a first generation USB port. I've been unable to find a flash drive ( powered or not) or a

  • Kernel Panic - Please Help!

    Hi all, I am having a problem with my Late 2009 27" iMac Intel Core i7. I am currently running the latest updated version of Lion (10.7.1). I have been having Kernel Panic problems for a while and, having searched through various forums, have been un

  • My desktop picture keeps changing after each log-out or shut down.  How do I fix this?

    I have a new MacPro, and I would like to stop my desktop photo from changing every time I shut down, or lock my computer.  It's truly annoying.

  • Debug ABAP consumer proxy -- which URL?

    Hi experts, I've a question concerning the URL to be used when debugging cunsumer proxies... So, I take transaction SICF on my ECC 6.0 backend system. In the menu Client --> Recorder --> Activate recording. There I just take the user I'm logged on wi

  • Real-Time Capture in Final Cut Express

    Hi All - I own a music venue, and we're considering adding video recording services (current we just offer audio). To reduce labor, I'm planning on a fixed mounted camera (brand/model TBD) from one of our lighting trusses (on the ceiling). We'd like