Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set up GET error if http headers includes $variables?

In register.inc.php i have this code

   header("Location: ../register.php?u=".$ref."&error=passwordcheck&uid=".$username."&mail=".$email."&name=".$name);
   exit();

and in register this line

   if ($_GET["error"] == "&error=passwordcheck&uid=&mail=&name=") { ?>
                     <div class="alert alert-danger alert-dismissible fade show" role="alert">
            Passwords dont match!

Usually it works but on this page the alert is not showing up to the user if the passwords dont match. What am i doing wrong?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this is the header in case of error in frontend

mydomainname.com/register.php?u=0&error=passwordcheck&uid=test1&mail=test1@gmail.com&name=test

edit: I feel ashamed asking such an easy question when i have solved much harder issues.

>Solution :

You have not understood HTTP query string parsing.

Here’s how it works: the query strings are separated using &, so:

?u=0&error=passwordcheck&uid=test1&mail=test1@gmail.com&name=test

is split into:

  1. u = 0
  2. error = passwordcheck
  3. uid = test1
  4. mail = test1
  5. name = test

So, use:

   if ($_GET["error"] == "passwordcheck") { ?>
                     <div class="alert alert-danger alert-dismissible fade show" role="alert">
            Passwords dont match!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading