Changeset 413 for trunk/docs


Ignore:
Timestamp:
Oct 2, 2012 1:57:05 PM (12 years ago)
Author:
anonymous
Message:

Added header and footer to docs/examples. Updated message printing methods to include before, after, and gotohash options. Minor other fixes.

Location:
trunk/docs/examples/contact_form
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/examples/contact_form/contact.php

    r396 r413  
    5151if (!empty($_POST)) {
    5252    // Validate submitted data.
    53     $fv->notEmpty('name', sprintf(_("%s cannot be blank."), _("Name")));
    54     $fv->stringLength('name', 0, 255, sprintf(_("%s must be %d-to-%d characters in length."), _("Name"), 0, 255));
    55    
    56     $fv->notEmpty('email', sprintf(_("%s cannot be blank."), _("Email")));
    57     $fv->stringLength('email', 0, 255, sprintf(_("%s must be %d-to-%d characters in length."), _("Email"), 0, 255));
    58     $fv->validateEmail('email');
    59    
    60     $fv->notEmpty('message', sprintf(_("%s cannot be blank."), _("Message")));
    61     $fv->stringLength('message', 0, 32000, sprintf(_("%s must be %d-to-%d characters in length."), _("Message"), 0, 32000));
    62        
     53    validateInput();
    6354    if ($fv->anyErrors()) {
    6455        // Re-populate form values with the user data so they can make corrections.
     
    6859        $email = new Email(array(
    6960            'to' => $email_to,
    70             'from' => sprintf('%s <%s>', $frm['name'], $frm['email']),
     61            'from' => sprintf('%s <%s>', getFormData('name'), getFormData('email')),
    7162            'subject' => 'Contact form email',
    7263        ));
    7364        $email->setTemplate('contact.eml');
    7465        $email->replace(array(
    75             'name' => $frm['name'],
    76             'email' => $frm['email'],
    77             'message' => $frm['question'],
     66            'name' => getFormData('name'),
     67            'email' => getFormData('email'),
     68            'message' => getFormData('message'),
    7869        ));
    7970        // Send email!
     
    113104}
    114105
     106function validateInput()
     107{
     108    global $fv;
     109
     110    $fv->notEmpty('name', sprintf(_("%s cannot be blank."), _("Name")));
     111    $fv->stringLength('name', 0, 255, sprintf(_("%s must be %d-to-%d characters in length."), _("Name"), 0, 255));
     112   
     113    $fv->notEmpty('email', sprintf(_("%s cannot be blank."), _("Email")));
     114    $fv->stringLength('email', 0, 255, sprintf(_("%s must be %d-to-%d characters in length."), _("Email"), 0, 255));
     115    $fv->validateEmail('email');
     116   
     117    $fv->notEmpty('message', sprintf(_("%s cannot be blank."), _("Message")));
     118    $fv->stringLength('message', 0, 32000, sprintf(_("%s must be %d-to-%d characters in length."), _("Message"), 0, 32000));
     119}
     120
    115121?>
Note: See TracChangeset for help on using the changeset viewer.