Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6018069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:13:14+00:00 2026-05-23T03:13:14+00:00

all. I’ve been thinking about a design decision for a PHP form and I’d

  • 0

all.

I’ve been thinking about a design decision for a PHP form and I’d like some input from people smarter than I am.

Here are the basics: I have a user input form which lets people register a chapter for a school. I’m doing input validation on the form fields, which lets me a) sanitize the data and b) validate the input. I then intend to send an email to the user who registered (as their email address will be submitted in the form) and write their information into a MySQL database.

Right now, I’ve got the data validation portion (and the requisite error messages) set up through POST, and the page is posting back to itself for the validation. This seemed logical to me as I could easily retain sanitized user input and display errors (for required fields, datatypes, whatnot). If all required fields are filled and the data is valid, I would like to redirect the user to a thank you page with extra information.

(Sorry I’m so verbose. I need to work on that.)

Thing is, I would like to separate the validation logic and the database write/email logic completely, if possible. My initial idea was to redirect to a thank you page if all fields were valid, but now I’m thinking that the thank you page should actually contain the logic to write to the DB, send an email, and then print the thank you message. This would, however, complicate things and involve passing POST data to another page without using GET. Although I’ve never had to do anything like this before (I’m fairly new to PHP), this is apparently possible (see here, here, and here) and there are multiple ways to accomplish this.

The question, though – should I even be trying to separate this logic in separate PHP pages? Every programming instinct tells me “hell yes, do it, it’s a logical separation of responsibility”….but is this best practice for form handling in PHP? Can anyone with more PHP experience elaborate on the pros and cons of doing something like this, and their experiences? How would you do it?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:13:15+00:00Added an answer on May 23, 2026 at 3:13 am

    What you’re referring to (if you don’t already know) is the basis of MVC pattern design. In this case, I’d probably go a step further and separate the database and email logic from the Thank You page. You can perform these actions in your Model, and redirect upon success from your Controller to display the correct View.

    It can take a while to get used to this concept, so if it is difficult to grasp at first, I’d suggest starting off with a PHP framework that forces MVC file separation, like Codeigniter or CakePHP. This can help you think about where your code belongs.

    Check out this document for an excellent primer on MVC patterns in PHP, and read about the pros and cons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All I know about the constraint is it's name ( SYS_C003415 ), but I
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
All, I wanted to know how I could pass a $variable from view, for
All, Below is the simple code that updates the field with input entered by
All the articles I've found via google are either obsolete or contradict one another.
All the recent VisualSVN Server posts made me want to check it out. I
All front-end developers know the pain of coding for Firefox, then viewing our then
All I want is to be able to change the color of a bullet
All throughout an application wherever error messages (or other user messages) are used I
All I want is to update an ListViewItem's text whithout seeing any flickering. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.