Hi,

I was just wondering if php is able to do the 'page post back function' like asp.net ? If possible, can someone guide me along with it or any site recommendations for reading up will be greatly appreciated. Thank you. :)

Regards,
heels

Dani AI

Generated

As pointed out, using a self‑processing form is the straightforward way to accomplish the same end as an ASP.NET "postback." The big difference is that ASP.NET WebForms bundles a control lifecycle and ViewState for you; PHP is stateless, so you detect the incoming request and manage any state explicitly (sessions, hidden fields, or storage). For production sites that need the same UX, handle validation and state on the server side and use patterns that avoid duplicate submissions and security holes.

Practical checklist to apply immediately:

  • Detect whether the request is a form submission and validate all input on the server.
  • Sanitize and escape output to prevent XSS, and validate types/lengths for each field.
  • Use the Post/Redirect/Get (PRG) pattern after successful processing to prevent resubmits.
  • Protect form actions with a CSRF token stored in session and verified on submit.
  • Persist transient UI state via session or hidden fields if you need the page to "remember" controls between submits.
  • Consider a framework with form helpers if you want higher-level abstractions similar to WebForms.

Further reading: PHP form handling in the manual (PHP Forms Tutorial), the PRG pattern (Post/Redirect/Get), and CSRF mitigation guidance (OWASP CSRF Prevention Cheat Sheet). This covers the practical differences and safe ways to implement page postback behavior in PHP for .

Recommended Answers

All 2 Replies

You set the form's action to <?php echo $_SERVER['PHP_SELF'] ?> . The page will post back to itself.

You set the form's action to <?php echo $_SERVER['PHP_SELF'] ?> . The page will post back to itself.

AH, thank you. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.