FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php: if else or somethink else





traxion
i got a form make (to sign in) and now i want it to have a few rules, like all fields must be not empty, the passwoords must be the same ... etc. etc.

i made it with if else

Code:

  if    ($_POST['nickname'] == $_POST['clean'])       { echo "Je moet je Nickname invullen<BR>"; }
  else                                       { echo "";
  if    ($_POST['email'] == $_POST['clean'])           { echo "je moet je Emailadres invullen<BR>"; }
  else                                       { echo "";
  if    ($_POST['voornaam'] == $_POST['clean'])       { echo "je moet Voornaam invullen<BR>"; }
  else                                         { echo "";
  if    ($_POST['achternaam'] == $_POST['clean'])       { echo "je moet Achternaam invullen<BR>"; }
  else                                        { echo "";
  if    ($_POST['passwoord'] == $_POST['clean'])       { echo "je moet Wachtwoord invullen<BR>"; }
  else                                         { echo "";
  if($_POST['passwoord'] == $_POST['passwoord2'])       { echo "je aanvraagd wordt nou verzonden<BR>";    }}}}}}
  else                                         { echo "je moet je ww invullen";}


now i get for the the last check a error with out it every think goes good
does anybody of u see what is wrong or does anybody got a better wat to make somethink like this.
jasperlevink
get rid of that last else.
You can also delete the echo ""; stuff
What's the error you get?
traxion
Parse error: parse error, unexpected T_ELSE in /home/traxion/domains/traxion.frih.net/public_html/resistance/bewerken.php on line 26

is mine error line 26 is:
else { echo "je moet je ww invullen";}


ow my mistake i for got the last echo text. i add it to my first post
jasperlevink
Those 6 }}}}}} should be 5 }}}}}
That should do it...
traxion
it gaves the same error

if im counting right it must be 6 }

there are 6 think it must complete to i close them all in one so 6 }
jasperlevink
I can't see it this fast.

But one tip:

manage your ifs like this:

if (bool) {
if (bool) {
if(bool) {
statements
}
else {
statements
}
}
else {
statements
}
}


Then its much easier to check wheter all the } and {'s are right!
It must be a missing } or a missing ;.

Grtz.


edit: I understand it now.
You have to place the else {echo "je moet je ww invullen"} in front of the last }'s

IN het nederlands: PHP heeft geen idee waarbij die laatste else hoort!
Je hebt namelijk de if's die om de laatste if staat al afgesloten en daarmee deze ook!
traxion
whuuaa jaah

it works
thnx man that was it, thnx

about the way how i made it
for me in a big screen is this for me a better way to keep it readable for me




thnx again!
Related topics
Aprender a Usar un Include.
Blad w generowaniu strony.
Some php probs..need some help plzz!
Can frames be a good choice? What then?
php page-refresh/redirect/boot help needed please
Layout gap problems with Javascript/PHP Combo
Layout Gap PRoblems with PHP/Javascript Combo
Question about something
[ HELP] Problems with PHP and Perl
Two PHP Errors
upload pics and make a thumbnail out of uploaded pics.
Uploading files. Condition to continue...
Please help about this..
Forms
Placement of Brackets in php code
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.