FAQ: Introduction to PHP Form Validation - Rerouting

This community-built FAQ covers the “Rerouting” exercise from the lesson “Introduction to PHP Form Validation”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn PHP

FAQs on the exercise Rerouting

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Why don’t I use form action to accomplish this task?

1 Like

you mean the action attribute of the <form> element? How would you use that to accomplish this task?

So… I am having issues getting through PHP Form Validation… I don’t know what happened to the program for this lesson. I keep getting this error even though I’m only adding two (very simple) new lines of code:

“{“errors”:[{“detail”:“session not found”}]}”

Seems related to codecademy servers, i see multiple topics mentioning this problem

2 Likes

Oh, thank goodness; thank you, stetim94!

If you go to “HTML form handling in PHP” → “Using the action attribute”, the lesson explains how we can use this attribute to take the user to another page. I am also confused by this.

Why are you confused by this?

Ok, after some testing the thing is like this:

If you use this 2 lines…

header(“Location: success.html”);
exit;

it produces the same effect as using the action attibute on the form tag

form method=“post” action=“success.html”

Two different ways to accomplish something, that’s not new, one on the PHP side and the other in the HTML side, that is clear, but It would be good if the exercise also explains WHY are we using the php header method + exit; instead of the html tag attribute “action”, ot which are the advantages in using one or the other.

they are not the same.

doing the form with action attribute like so:

<form method="post" action="">

will send the form to the same page you came from (index.php). This will process the form data (and redirect or show error message)

doing action="success.html" will always show the success page (go over the front-end without processing in the back-end)

1 Like

Hi all,

Can someone help me to figure out how to reverse the hashed md5 password inside HTML docs?

Why would you want to do this?

@stetim94 Thanks for your reply. To solve an assignment I have to figure out it.

Which assignment?

The normal flow is to send the password to the server, hash the password and compare the hashes.

Here is a sample:
Assume: $md5 = $_GET[“md5”];
line of codes to iterate…
$password = $i1 . $i2;
Encrypting
$hash_md5 = hash(“md5”, $password );
if ($hash_md5 === $md5) {
$text = $password;
}
Here is HTML body

Original input: <?=htmlentities($text);?>

# The $text is to display user input

If the user input is hashed, it can be also reversed to see what the user entered. And how to use reverse in PHP, I cannot find out.

Again, why would you want to do this? un-hashing is really uncommon and bad practice, I can’t believe the assignment would force this upon you

A post was split to a new topic: Do we want these links followed from this site?

A post was split to a new topic: Displaying None