PHP Redirect Response

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:00
    with Leanna Pelham
  • 0:09
    Go back to the new pet form and fill it out again.
  • 0:20
  • 0:20
    It looks like it's still working.
  • 0:22
    Refresh a few times and check out pets.json.
  • 0:28
    Whoa, we have a lot of duplicate Fidos in our file.
  • 0:32
    Each time I refreshed, the form submitted and added my pet again.
  • 0:36
    Bad dog.
  • 0:38
    In the real world, we don't want users
  • 0:40
    to be able to create duplicate records accidentally or so easily.
Loading ...

PHP Redirect Response


As you use your form, you'll notice that after you submit the form, you just keep seeing the form again. If you keep submitting it, you'll end up with a bunch of duplicate records. That's no good. In this tutorial you will implement a redirect on the form submission to take the submitter to the home page, instead of back to the form, using the header() function. We'll explain what exactly a header is and how that relates to our HTTP requests.

Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.