There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot computer connection crash css dell drive driver drivers email error ethernet excel explorer firefox firefox 3 freeze hard drive internet internet explorer itunes laptop linux malware monitor network networking outlook outlook 2003 outlook express password printer problem problems ram router security slow software sound trojan usb virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: PHP Conditional problem


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Firestone's Avatar
Computer Specs
Member with 32 posts.
 
Join Date: Dec 2006
Experience: Advanced
16-Feb-2007, 11:06 PM #1
Solved: PHP Conditional problem
I wrote this php code,

PHP Code:
<?php
$User 
$_POST["uname"];
$Pass $_POST["pass"];
if (
$User "tyler" && $Pass "lambeth")
{
echo 
"You are now logged in!";
}
else
{
echo 
"Incorrect user name or password, please try again.";
}
?>
And it always displays "You are now logged in!" no matter what you enter. Anyone know whats wrong?
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
16-Feb-2007, 11:16 PM #2
A few simple errors:

you need to add 2 = signs in the if() statment, like this:
PHP Code:
if ($User == "tyler" && $Pass == "lambeth"
Try that, and see if it works.
Firestone's Avatar
Computer Specs
Member with 32 posts.
 
Join Date: Dec 2006
Experience: Advanced
17-Feb-2007, 12:11 AM #3
Re:
That was the problem thanks. It always seems like its the easiest thing, and I completely over look it...
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
17-Feb-2007, 01:00 AM #4
Quote:
Originally Posted by Firestone
That was the problem thanks. It always seems like its the easiest thing, and I completely over look it...
Don't worry, I always do that

Just remember, you need to use 2 ='s in a conditional statement (==), just one won't work.

Glad it worked mate.
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,197 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
17-Feb-2007, 01:17 AM #5
== means "equal to"
= means "represents"

Just keep that in mind for the future

There's also === which means "identical to"
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:23 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.