SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: What's Wrong With This Code?
-
Jan 19, 2005, 18:25 #1
- Join Date
- Jan 2005
- Location
- katonah
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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!
-
Jan 19, 2005, 18:40 #2
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.Ed Shuck
www.noevalley.com
-
Jan 19, 2005, 18:58 #3
- 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.
-
Jan 19, 2005, 19:14 #4
-
Jan 20, 2005, 05:32 #5
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- 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.....
-
Jan 20, 2005, 06:03 #6
- 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