N mol
N mol

Reputation: 571

Reload page in php

While designing sign up page I wish to reload page if user has submitted anything wrong in the fill up boxes. How can I reload page after the user presses submit button with a wrong entry ? (while verifying expected content through php)

Upvotes: 0

Views: 247

Answers (2)

David
David

Reputation: 3821

You can use header() plus some _GET variables for telling the original page there were errors.

Form submit page:

<?php
   //.... lots of code validation
   if ($failed) {
      header('Location: http://path.com/to/your/site/original_form.php?error=1');
   }
?>

Form page:

<?php 
   if (isset($_GET['error']) {
      echo "there was an error! Please fix it!";
   }
?>

Upvotes: 2

jaibatrik
jaibatrik

Reputation: 7543

Try the following -

if (validation_failed) {
    header("Location: http://yourserver.com/signup.php");
} else {
    header("Location: http://yourserver.com/welcome.php");
}

PHP Header function

Upvotes: 0

Related Questions