Sorry for the lame question, but I'm teaching myself php and run into a problem that I can't think of a solution for at the moment. I have a HTML form that includes asking a user to enter in a password and then verify that password by typing it in again. The submit button then calls a php script that I'd like to check to see whether the two passwords were entered in the same and then either display one HTML page or another based on whether the passwords entered were the same or not.
A gentle nudge in the right direction would be appreciated if anyone can take the time to help.
Thanks in advance!!
Beginner Question - HTML and PHP - Sorry
Moderator: General Moderators
Re: Beginner Question - HTML and PHP - Sorry
Code: Select all
<?php
// All your other code...
if ($_POST['password'] == $_POST['password_verify']) {
header('Location: same-password.php'); exit();
} else {
header('Location: different-password.php'); exit();
}
// And the rest of your code...Re: Beginner Question - HTML and PHP - Sorry
thanks heaps someberry!! Much appreciated.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Beginner Question - HTML and PHP - Sorry
There should be no need for output buffering here (using the ob_* family of functions). That is a bandaid for writing unclean code in many cases. Redirects being one of those cases.
Also, when redirecting with a header call make sure to use full uris, not relative ones. The HTTP 1.1 spec states that a full URI is required. Plus it just makes good clean coding sense.
Also, when redirecting with a header call make sure to use full uris, not relative ones. The HTTP 1.1 spec states that a full URI is required. Plus it just makes good clean coding sense.