Jump to content

[SOLVED] Equality of two fields?


ali_2kool2002

Recommended Posts

Hi can someone tell help me as the code below doesnt check properly if the two variables are the same, it keeps saying they are the

same even if the variables are different:

 


<?
$choosepass = 'a';
$confirmpass= 'df';
if('$choosepass' == '$confirmpass'){
?>	
	<script language="Javascript">
	alert ( "Passwords must be the same-Please try again")
	</script>
	<?
	}
	else{

?>	
	<script language="Javascript">
	alert ( "Passwords same")
	</script>
	<?
	}

?>

Link to comment
https://forums.phpfreaks.com/topic/48017-solved-equality-of-two-fields/
Share on other sites

You are checking to see whether the literal strings '$choosepass' and '$confirmpass' are equivalent, which they will never be. Get rid of the single quotes, and you'll be alright:

<?php
if ($choosepass == $confirmpass) {
// they're equal
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.