|
-
Aug 28th, 2008, 11:47 AM
#1
Thread Starter
Junior Member
[RESOLVED] if - it always worked for me but this time not? what did i do wrong..
you can see it working here, that it doesn't work:
http://vba.lescigales.org/serialcheck.php
the code i used is this:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="serial" id="serial" />
</label>
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</form>
<?php
$a = "9d5e3ecdeb4cdb7acfd63075ae046672";
$b = "lol";
if($_POST['serial'] = "")
{
//do nothing, it's empty!
}
else
{
if($_POST['serial'] == $a or $b)
{
//Do something here to tell the dude he's allowed!
echo "allowed!";
}
else
{
echo "not allowed";
}
}
?>
</body>
</html>
it always says allowed..
thanks for helping..
- Shadows.
-
Aug 28th, 2008, 03:15 PM
#2
Re: if - it always worked for me but this time not? what did i do wrong..
change
if($_POST['serial'] == $a or $b)
to
if($_POST['serial'] == $a || $_POST['serial'] == $b)
You weren't comparing $b to anything.
Also, you need to restructure your code. You should never have something like
PHP Code:
if($_POST['serial'] = "") { //do nothing, it's empty! }
-
Aug 28th, 2008, 04:51 PM
#3
Thread Starter
Junior Member
Re: if - it always worked for me but this time not? what did i do wrong..
kool thanks ^^
did this:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="serial" id="serial" />
</label>
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</form>
<?php
$a = "9d5e3ecdeb4cdb7acfd63075ae046672";
$b = "lol";
if(!empty($_POST['serial']))
{
if($_POST['serial'] == $a || $_POST['serial'] == $b)
{
//Do something here to tell the dude he's allowed!
echo "allowed!";
}
else
{
echo "not allowed or empty";
}
}
?>
</body>
</html>
if !empty doesn't work tho it seems..
-
Aug 29th, 2008, 10:59 AM
#4
Re: [RESOLVED] if - it always worked for me but this time not? what did i do wrong..
I prefer isset.
PHP Code:
if(isset($_POST['serial']))
But if you mean "not allowed or empty" isn't appearing, it is because your else is linked to your
if($_POST['serial'] == $a || $_POST['serial'] == $b)
if, not your empty if.
The code should be
PHP Code:
if(!empty($_POST['serial'])) { if($_POST['serial'] == $a || $_POST['serial'] == $b) { //Do something here to tell the dude he's allowed! echo "allowed!"; } //end the post if } //end the empty if else { echo "not allowed or empty"; } //end the else
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|