special "if" circumstance

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

special "if" circumstance

Post by malcolmboston »

ok very easy i believe, i have just never tried to do it and dont know how

heres what i want it to do

1) i have a login form
2) standard username and password config
3) IF a checkbox is checked i want it to save a cookie, if it isnt then i dont want it to

not sure how to do this, anyone point me in the right direction?
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

here's a rough code:

Code: Select all

<?php

if(isSet($_POST['imposted'])) {

if(!isset($_POST['username']) || empty($_POST['username']) || !isset($_POST['password']) || empty($_POST['password'])) {
print "you missed out fileds you dofus!";
exit;
}

// bla bla query

if($mysql_num_rows($bla_bla_result) == 0) {
print "you tryng to hack?........";
exit;
}

if(isSet($_POST['give_santa_a_cookie'])) {
// set cookie
}

header("Location: my_naked_pics.php");

} else {

}

?>
Im sure you won't use that ;). But hope it gives you some ideas...

-Nay
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

well i wont

im pretty sure the users wont appreciate the line

Code: Select all

print "you missed out fileds you dofus!";
[/qoute]

lol, thanks for the help anyway, ive never understood how to get PHP to make a condition from checkbox (or any form elements) state.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Sure they will, add some cocaine to the script. It's a b00m! ;)

-Nay
Post Reply