SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    katonah
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation What's Wrong With This Code?

    <?php
    if (isset($_POST['email'])){
    if ($dbemail == $email) {
    echo 'email is good'
    }
    if ($dbpassword == $password) {
    echo 'password is good'
    }} ?>

    what i want it to do is
    if 'email' is set in the post array
    and if the database email is equal to the form email echo "email is good"
    if the database password is equal to the form password echo "password is good"

    but this code makes the whole page blank out!

  2. #2
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no comment on the first part of the code. Just do not know.

    I would end the echo statement with a ;

    and I would, during testing, put in some else statements to give the code someplace to go if things are not right.

  3. #3
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is the script getting $email and $password from ?
    Unless you have register gloabals on (which you shouldn't) it won't get those variables automatically from the form.

    You need to compare with $_POST['email'] and $_POST['password'] or copy the $_POST variables to normal variables if you prefer.

    I assume you already have $dbemail and $dbpassword.

    You should also be securing those variables, by adding slashes (if magic quotes is off) and removing invalid characters.

  4. #4
    &lt;!-- Insert thoughts here --&gt; pitcher17's Avatar
    Join Date
    Apr 2004
    Location
    The great white north
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    minor thing but in your code you are missing the semi-colons at the end of the two echo lines.

    --just noticed that edshucks said the same thing --
    never mind..
    The more time I save by not planning and documenting,
    the more time I have left to debug.


  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    I assume you have already set $dbemail, $dbpassword as the row from your database, and set $email and $password as your posted variables?!

    Also just thinking about it, do you have your error reporting on?
    This code (as mentioned above) should have thrown up at leaset two parse errors.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think $email and $password should be $_POST['email'] and $_POST['password']


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •