using (isset($_POST['name'])) not working with only 2 things

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

using (isset($_POST['name'])) not working with only 2 things

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

should look more like

Code: Select all

isset && isset && ==
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

hmm

Post 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 ?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

Post 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)
Z3RO21
Forum Contributor
Posts: 130
Joined: Thu Aug 17, 2006 8:59 am

Post 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.
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

ty

Post by Mythic Fr0st »

Thanks, you fixed it ^_^
Z3RO21
Forum Contributor
Posts: 130
Joined: Thu Aug 17, 2006 8:59 am

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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
}
?>
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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']) {

    }
}
Post Reply