#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    21
    Rep Power
    0
    Hi all! I am very very new to PHP. I am quite good at perl, but php is killing me sometimes (have no books or docs)

    Anyway, as u see below i want to make a simple form with 2 fields. If correct data
    is written into those fields then "ITS OK" message should be printed. This "script" works (/me happy ) but i wonder if this is the "normal" way u people write forms and IF statements or is this just "i am glad it works script).

    I want to lear this the GOOD way and follow
    some "standards" in writing php code etc..

    Thx for help.
    _________________________________________
    <form action="index.php3" method="post">
    <input type=text name=FIELD1[] ><br>
    <input type=text name=FIELD2[] > <br>
    <input type=submit value=Go>
    <br>

    <?

    while(list($dummy,$value)=@each($FIELD1))
    if($value == hellothere)
    {
    print "ITS OK";
    }
    else{
    print "NOT OK";
    }


    while(list($dummy,$value)=@each($FIELD2))
    if($value == wzup)
    {
    print "ITS OK";
    }
    else{
    print "NOT OK";
    }
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    21
    Rep Power
    0
    btw....do u know any good sites with some good "how to learn" php documentation?

    thx again
  4. #3
  5. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    If you aren't actually returning multiple values for FIELD1 and FIELD2 (which it doesn't appear you are) there is no need to use an array and an EACH construct. Also, you need quotes around your string literals in the IF statements:

    <form action="index.php3" method="post">
    <input type=text name=FIELD1><br>
    <input type=text name=FIELD2> <br>
    <input type=submit value=Go>
    <br>

    <?

    if($FIELD1 == "hellothere")
    {
    print "ITS OK";
    }
    else{
    print "NOT OK";
    }

    if($FIELD2 == "wzup")
    {
    print "ITS OK";
    }
    else{
    print "NOT OK";
    }

Similar Threads

  1. (mysql_numrows($result) > 0) error! plz help.
    By mairaj in forum PHP Development
    Replies: 7
    Last Post: February 6th, 2004, 12:37 PM
  2. plz. urgent i need make download
    By masa4u in forum PHP Development
    Replies: 3
    Last Post: January 22nd, 2004, 02:59 PM
  3. simply MATHS, plz giv a hand~~
    By lummaomao in forum PHP Development
    Replies: 2
    Last Post: July 29th, 2003, 11:50 PM
  4. regular expression help plz
    By adil_mujeeb in forum PHP Development
    Replies: 1
    Last Post: July 19th, 2003, 06:11 AM
  5. plz help me
    By sheeba in forum PHP Development
    Replies: 2
    Last Post: June 29th, 2003, 10:51 AM

IMN logo majestic logo threadwatch logo seochat tools logo