Entry
How do I compare two variables that have been assigned text strings to make sure they match?
Apr 28th, 2000 22:20
Jerry Yoakum, Matt Williams, unknown unknown,
I believe that this question can be best answered with an example.
========================================================================
<html>
<head>
<title>Comparing strings</title>
</head>
<body>
<h3>How to compare two variables that have been assigned text strings
to make sure they match.</h3><p>
<?php
$strName = "Name"; // replace "Name" with data from the name textbox
$strPassword = "Name"; // same as above except use password textbox
if ($strName == $strPassword) {
echo "Your password cannot be your name.";
} else {
echo "Your new account is ready.";
}
?>
</body>
</html>
========================================================================
Output:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
How to compare two variables that have been assigned text strings to
make sure they match.
Your password cannot be your name.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Output with $strPassword = "something else":
------------------------------------------------------------------------
How to compare two variables that have been assigned text strings to
make sure they match.
Your new account is ready.
------------------------------------------------------------------------