Page 1 of 1
using (isset($_POST['name'])) not working with only 2 things
Posted: Sat Dec 02, 2006 7:57 pm
by Mythic Fr0st
Sadly, comparing email and confirm email, and password and confirm password, is not working
The problem is that, if I type g, for e-mail, and giorgjaeroigjaoigjeaoigjaojig, for confirm e-mail, it echo's Your E-mail's match, when they dont, same for password
( They worked before putting isset there, but not now, however I need isset)
this is the code
Code: Select all
if (isset($_POST['email1']) && $_POST['email1'] == isset($_POST['email2']) && $_POST['email2'])
{
echo " <b>Your e-mail's match.</b> <br/>";
}
else
{
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your e-mail\'s do not match.<br/></i></font>';
$bool[1]=false;
}
if someone can tell me where the problem in the email is, i'll probably be able to figure out pw's
- Thanks
Posted: Sat Dec 02, 2006 8:00 pm
by feyd
hmm
Posted: Sat Dec 02, 2006 8:20 pm
by Mythic Fr0st
Like this?
Code: Select all
if (isset($_POST['email1']) && isset($_POST['email2']) == $_POST['email1'] && $_POST['email2'])
{
echo " <b>Your e-mail's match.</b> <br/>";
}
else
{
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your e-mail\'s do not match.<br/></i></font>';
$bool[1]=false;
}
still the same, if I type greoi as the email & goiegjjoheo as the confirm e-mail, it says they match
However, if I leave both blank, it says "Incorrect e-mail" like it should"
and If I leave 1 blank & the other with text, it says "Incorrect e-mail" like it should"
However, with both in their it doesnt work O_O
any idea's ?
Posted: Sat Dec 02, 2006 8:23 pm
by volka
Just translate
if (isset($_POST['email1']) && isset($_POST['email2']) == $_POST['email1'] && $_POST['email2'])
to (more or less) plain english.
"If there is _POST[email1] and there is _POST[email2] euqals _POST[email1] and _POST[email2] is true"
Sounds strange? It does.
Exactly what do you want it to test?
Posted: Sat Dec 02, 2006 8:26 pm
by Mythic Fr0st
if the text in e-mail box is equal to the text in confirm e-mail box
( checking to see if both e-mails are same value, IE abc = email, abc = confirm email)
Posted: Sat Dec 02, 2006 9:11 pm
by Z3RO21
Code: Select all
if ( ( isset($_POST['email1']) && $_POST['email1'] != NULL ) && ( isset($_POST['email2']) && $_POST['email2'] != NULL ) && $_POST['email1'] == $_POST['email2'] ) {
//They are all set, not NULL, and match.
} else {
//Error here
}
This is my guess at what you are trying to do.
ty
Posted: Sat Dec 02, 2006 9:25 pm
by Mythic Fr0st
Thanks, you fixed it ^_^
Posted: Fri Dec 15, 2006 12:28 pm
by Z3RO21
Glad I could help, I have gotten pretty good with control structures learning AJAX. Also make sure to do some value checking on the user input.
Posted: Fri Dec 15, 2006 2:47 pm
by RobertGonzalez
Mythic Fr0st, maybe next time you could write it out then translate it to code...
If email1 is set AND email1 is not equal to the null character AND email 2 is set AND email2 is not equal to the null character AND email1 equals email2
Code: Select all
<?php
if (
isset($_POST['email1']) &&
$_POST['email1'] != null &&
isset($_POST['email2']) &&
$_POST['email2'] != null &&
$_POST['email1'] == $_POST['email2']
)
{
// Carry on with what you want to do
}
?>
Posted: Fri Dec 15, 2006 2:57 pm
by Ollie Saunders
Remember a nest is a synonym for &&. If your conditions get too long and confusing, break them up:
Code: Select all
if (isset($_POST['a']) && isset($_POST['b'])) {
if ($_POST['a'] == $_POST['b']) {
}
}