Jump to content

Search the Community

Showing results for tags '$session-set()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hi all, I want to process a form, and display an error message under certain conditions. I know there are other ways of doing this, but I kind of like the idea of using $session->set and $session->get to store and retrieve my error messages. This is the first time I have used $session->set(). Is this method ok? <?php $error = $session->get($errorMsg); echo $error; // Clear the session variable so it doesn't display again if the page is reloaded. $session->set($errorMsg, ""); // If the submit button is clicked, process the form. if($input->post->submit) { $test = $sanitizer->textarea($input->post->test); if($test==""){ $error = "Error: You left it blank!"; } elseif($test=="poop"){ $error = "Error: Poop is not allowed!"; } else { $error = ""; } $session->set($errorMsg, $error); $session->redirect('./'); // If the submit button hasn't been clicked, render the form. } else { echo "<form action='./' method='post'> <fieldset> <legend>Testing a form with validation...</legend> <div class='row'> <div class='large-12 columns'> <textarea name='test' rows='10'></textarea> </div> </div> <div class='row'> <div class='large-12 columns'> <button class='small' type='submit' name='submit' value='Send'>Test</button> </div> </div> </fieldset> </form> "; }
×
×
  • Create New...