Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Php: Password not match and Password is empty

$
0
0
Hi!!! I am a beginner in PHP and we are ask to create a fields with passwords.

The code for password fields is:
<input type="password" name="Password1">
<input type="password" name="Password2">

As you can see there are two passwords, it is to verify if the password does match or not...
I get the concept and i use if-else statement but if the user does click the submit button it should print a phrase "Password is empty", if the user inputs the password but they do differ when the user input, it should print a phrase "Password not match", but if the user has correctly input both the passwords field then it should print the users password.

Here is my code:
<?php 
		if ($_POST['Password1'] != $_POST['Password2'])
			echo " Password not match. ";
		else if ($_POST['Password1'] == $_POST['Password2'])
			echo $_POST['Password1']; 
		else if (isset ($_POST['Password1']))
			echo " Password is empty. ";

?>


First one states password not match, second is to echo the user's password if they are equal, lastly to echo it if the password is not set.
I tried to run it but it functions the first and second only. the third one doesnt work!! if i dont set or input a password it doesnt show anything on the browser.. so that only means the third one is malfunction!!

Any help will be appreciated.. thank you.. :)/>

Viewing all articles
Browse latest Browse all 51036


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>