Page 1 of 1

special "if" circumstance

Posted: Wed Jan 07, 2004 7:20 am
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?

Posted: Wed Jan 07, 2004 7:55 am
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

Posted: Wed Jan 07, 2004 7:57 am
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.

Posted: Wed Jan 07, 2004 11:29 am
by Nay
Sure they will, add some cocaine to the script. It's a b00m! ;)

-Nay