Session Start: Tue Oct 03 12:06:04 2000
*** Now talking in #netsurprise
*** Topic is 'WEBMASTERS ONLY!!! Welcome To the NetSurprise Adult Webmaster ChatRoom! WEBMASTERS ONLY!!'
*** Set by SurpriseBot on Sun Oct 01 23:00:22
-SurpriseBot- Welcome - Net Surprise IRC - thud.net channel #netsurprise
*** TD-atvet is now known as TDavid
furball!
TD, did you get your shots yet?
:)
Hey TDavid!
hehe
I made it this time. LOL
right on, thanks for coming :)
we're talking form input and loops today
NP. :) Glad I could make it this time. :)
*** CrEaToR has joined #netsurprise
i think the advanced lesson this week has brought up some interesting conversation about functions and when and when not to use them
Ahh... yeah, I saw the first post in the advanced lesson. Gotta stop back and do some more reading.
(And post my own code. :))
from my perspective functions should be used to eliminate repetitive actions and streamline code, but if in the main body of the code you are doing nothing but calling functions, well i'm not sure that is entirely correct. It will work, but I'm thinking why not just have the body of the code without the function call
*** Andy has joined #netsurprise
I remember one of my profs in college said that the best program was one where the main function simply called other functions. Top down design and all that. :)
*** TiBo has joined #netsurprise
but if you think about that for a minute, why would one do that in a small program?
I agree. :) Like you, I use functions to stop repetition and streamline but other than that...
in a gigantic program that is executed by only a few people that makes sense, but in a smaller program that is itereated thousands of times i think it brings extra overhead
Now, here's a good point. :) Functions add speed/memory overhead.
*** Chris has quit IRC (QUIT: User exited)
*** WillyB has joined #netsurprise
so if we were just calling a function for convenience, well ... it is probably a bit on the wasteful side
Functions are good form. They make your code easy to read and maintain when you go to update them after a long period of time.
I have to go to the store... but didn't want to be late.. if I talk while I'm gone it's not me
Yes, functions do make your code easier to read BUT at the same time, over functioning your code is a bad thing too.
*** tia has joined #netsurprise
Just like overnormilizing a database is a BAD thing.
hi all
Hi Tia
i guess that is my point. It's like candy ... you eat too much your teeth fall out :)
Hi Tia
hello tia :)
Willy, I always assume that if you're talking, it's not you. LMAO
* FurBall ducks
if you look at the code that zuzy posted it makes for excellent discussion about code optimization
* WillyB slaps FurBall around a bit with a large trout
I don't much care about using functions or not using them I just like to be a contrarian.
* FurBall ducks the trout and watches as it hits TiBo upside the head
Whoops. there I go again causing trouble. LMAO
I try not to look TD unless I'm stupmed, but now I'll have to go check it out
Back in the days before the torut who'd have ever thought they'd be glad to get smacked by a trout?
(basic) TO-DO ASSIGNMENT: Write a script to submit a username and password to enter a page.
LOL@TiBo
here is the link to the code in question: http://adultnetsurprise.com/learning_center/help_board/Forum26/HTML/000003.html
EEWWWW!!!! YUCK!!
Too many functions IMHO
here is the code we can work on optimizing:
$total=$username.$password;
if ($total == "") {
echo "Please enter your username and password.
";
die;
}
(PAUSE for flood)
if ($username == "") {
echo "Form Incomplete:
You must enter a username.";
die;
}
if ($password == "") {
echo "Form Incomplete:
You must enter a password.";
die;
}
Now how can we go about doing this form checking without all this repetition and NOT using a function
Whoops! wrong one. :)
?
we'll get to the other one, furball :))
btw, zuzy, not picking on you if you are reading these workshop logs :) This is an excellent example for optimization and I am glad you posted :)
* TDavid makes workshop log note
*** _Splitz_ has joined #netsurprise
anybody got any ideas?
<_Splitz_> I got ideas
Well, we can't use PHP's variable variables yet can we. :)
<_Splitz_> I'm not sharing them
* FurBall walks over to Splitz and shakes him around a bit to get his ideas out.
we're doing a workshop, splitz, come back when you are :)
hehe
*** CoolHand has joined #netsurprise
<_Splitz_> FurBall, HELL NO! ;)
*** CoolHand is now known as Cool`Hand
Well, one way would be this:
if ($username = "" || $password = "") {
echo "Form Incomplete:
You must enter a username or password.";
die;
}
This has the advantage of NOT telling the "hacker" which of the username/password is incorrect. :)
logical OR, yes :)
<_Splitz_> bbl, I'll distract yuns too much
how about echoing back instead of dying and repopping the form
*** _Splitz_ has quit IRC (QUIT: User exited)
if((!$username) OR (!$password)) {
$error = 'Username or Password field left blank>';
}
*** WillyB is now known as WillyBrb
echoing back what? The rest of the form? It's getting displayed either way isn't it?
nope, because the idea was to allow them to be allowed inside on the same page with the login
it was a bit of a tricky assignment, but demonstrates how you can display multiple content on a single page without needing to include or require other scripts
if the user/pass is good you let them into the content, if it is bad, you pop the form with the error
can u get viruses in zip files?
the login form
OK... however, with the code that Zuzy posted, the form gets displayed first and then the PHP code gets displayed.
yes, and it is incorrect
OK. :) My misunderstanding then. :)
Write a script to submit a username and password to enter a page. If the username and password does not match the variable hardcoded in the script show the login form again with an error message. The password field should be private so that as you type you'll see ****. This should all be one self-contained script with NO include() or require() files
that is the entire to-do assignment
*** WillyBrb has quit IRC (Ping Timeout)
do alot of you run pay sites?
maybe i will add a pay sites section to my site
we are in the middle of a workshop Cool`Hand
workshop?
grrrr
Cool`Hand, this is a workshop on PHP.
ah ok sorry
is that just tonight?
boy, i wish i had ops in this channel hehe so i could change the topic :)
:)
surprisebot, change the topic!! hehe :)
there is a schedule for the workshops at www.adultnetsurprise.com
ok, back to the discussion ...
as you can see the form should be embedded inside a conditional
i like the idea of populating a variable named $error
if $variable is populated they always get the form OR if the hidden form doesn't indicate it is a login
er if $error is populated that is
:)
and if it is a login and they match the hardcoded login info then they get the content
all on one page
*** ConePup has joined #netsurprise
hi pup
// define correct login
$correct_username = 'test';
$correct_pass = 'test';
if($action == "login") {
// proceed with verifying password
}
?>
hi TDavid
cya later all
*** Cool`Hand has quit IRC (QUIT: User exited)
Next we can test for blank forms all in one if statement using the logical OR instead of using multiple ones. Let's do that next:
if((!$username) OR (!$password)) {
$error = 'Username or Password field left blank>';
}
else {
*** Andy has quit IRC (Connection reset by peer)
next we verify if the password and username match
if(($username == $correct_username) AND ($password == $correct_password)) {
// this is where we escape and show content
?>
Congrats you have logged in correctly!
*** ConePup has quit IRC (QUIT: User exited)
if the username wasn't correct then we have another error situation
} else {
$error = 'Username or Password invalid';
}
*** TiBo is now known as TiBo-brb
Umm, shouldn't your first else be an elseif?
nope, because this is inside the whether or not the username/pass is valid
*** WillyB has joined #netsurprise
if they both don't match they didn't provide the correct username/pass
K. Then you're missing a close curly somewhere. :)
we are also still inside the $action="login" conditional
yes, you are correct, that is next
K. Jumping the gun am I. LMAO
that is the end of the $action"login" ... but very perceptive! :))
} // end of $action="login"
Umm, no. We need to have a close curly to close the second if statement.
*** zuzy has joined #netsurprise
hmmm, did something get cut off?
I think it did. :(
bummer!
you need one more close curly right before } else {
i'll post to the bbs in its entirety
*** legaldoc has joined #netsurprise
(by the way, for the logs, a close curly is '}')
Hi zuzy.. your ears musthave been ringing
huh?
hi zuzy, we're working on your code right now :) trying to make it shorter for you
Hi by the way
Hi Zuzy!
oh my i just go here no idea what you talked about
ok, i will start from the beginning with that code ...
// define correct login
$correct_username = 'test';
$correct_pass = 'test';
if($action == "login") {
// proceed with verifying password
}
*** floppy has joined #netsurprise
remove that squiggily
Howdy ;)
hi floppy
hi floppy
// define correct login
$correct_username = 'test';
$correct_pass = 'test';
if($action == "login") {
// proceed with verifying password
there we go hehe
OK! :)
now we are inside the $action loop
inside here we will test the username and password if they are blank first
*** legaldoc has quit IRC (QUIT: User exited)
if((!$username) OR (!$password)) {
$error = 'Username or Password field left blank>';
} else {
// does password and username match?
if(($username == $correct_username) AND ($password == $correct_password)) {
// this is where we escape and show content
?>
Congrats you have logged in correctly!
} else { // keeping those brackets in order now we know they didn't login correctly
$error = 'Username or Password invalid';
}
lastly we need to close the $action = "login" conditional
} else { // ok we need to make $error say that the user should please login because it's the first time in
*** tia has quit IRC (QUIT: User exited)
$error = 'Please Login';
?> // escape php to print the login
// restart php to close the else loop
echo($error);
} // close else
now you have a self-contained script with 3 parts changing one variable to be an error or a login message and not using functions
and the content can be maintained on the same page and PHP will either print the login or content or redisplay the login based on a match of the hardcoded login/pass info
that's a lot better of cause, thanks
i will post this to the bbs as well for you, zuzy, but i am glad you posted the code :) it makes for great study :))
*** CrEaToR has quit IRC (Connection reset by peer)
Well well if you can't be a good sample be a dandy bad one
classes are more fun that way
*** CrEaToR has joined #netsurprise
are we going into sending e-mail next week?
LOL
I really want to make a mailing list for my sites
yes :)
oh, fun!
*** idahoen has joined #netsurprise
man, is the net screwy today or is my system at 1% resources
willyb you having some system resource probs?
net's probably messed up willyb. :(
ok the complete code is posted on the BBS
http://adultnetsurprise.com/learning_center/help_board/Forum26/HTML/000003.html
Actually, sys is at 51%, but it takes a while for my typing to show up on the line down here
that should make it easier to follow then all the line breaks and the annoying inserted between it lol
willyB, have you had a chance to mess with the forms yet, bro?
does this mean I missed most of the class?
well it will all be in the logs for you :)
did you have some other questions about this week's material, feel free to ask :)
or prior week's material as well
no I sure haven't TDavid.. it's been a busy week-end here.. I
say pacific is minus what GMT?
've read the lesson twice so it wont be long :)
7 I think zuzy
thanks well got to run make dinner see you all next time hoplully i'll get here earlier
see ya zuzy :)
*** zuzy has quit IRC (QUIT: User exited)
gmt-8 = pacific
*** Chris has joined #netsurprise
TDavid, i think you're still missing a close curly somewhere around the } else { $error = "username invalid" lines. I dont' think you're closing the login code.
bye zuzy
did you check the bbs, furball?
Yes I did.
I may be wrong though. :)
count the } and the { and see if they match :)
I ll get to it tommrow and catch up TD :)) good day for it tommrow skidder broke and they shiped the wrong part
I did. I come up one close short. :)
*** Steve is now known as Steve-Away
Hi willyB
i get 6 } and 6 {
bummer floppy
maybe you are missing the one long line ... AND ($password == $correct_password)) {
kind of easy to miss that one
WillyB!!! Whats up pilgrim?
Hi ya snikks
i came up with 5 { at first when just counting now hehe and then I spotted that one, furball
I got 7 and 6 TD
:)
7 what? hehe
{ or }
Hmm... I'm throwing it into an editor now. :)
*** Chris has quit IRC (QUIT: User exited)
Snikks, just gettin down of my high horse and walking on the ground for a while :) hehehe
heaven knows im not perfect, might be a bug here, this is on the fly coding hehe :)
lol
you have to read that with a John Wayne accent floppy hehehe
but for the logs we should get it right, so let me know furball if they don't match up
lmao
you got it Willy
I always do willy
* floppy snikks definatley does lol
7 {
:) hehehe
Will do. Checking it now. :)
anyone know how to stop that knocking on icq when some one new is online other that turn down the volume ??
actually this raises a good point about nested conditionals, they can be a bit tricky at times
Yup. There's a missing curly.
I get a parse error on line 21. which is this: } else {
$error = 'Please login';
}
* Snikks_Wurkz sticks a pot seed under the space bar of floppys keyboard while he isn't looking and runs and hides
haha
really
:)
it does
1 in second block, 4 in 3rd block and 2 in last block TD {'s
hehe
*** trouble has joined #netsurprise
trouble!!!!
hey Snikks
:)
: )
* floppy ut oh now we a re all in trouble
Hi trouble :)
trouble is good for the mind and body :))
getting caught in trouble is not!
lol
*** Da_MoBu has joined #netsurprise
hi all
hi Da_MOBu
TW licked her head to toe this morning
lol
OK. Here we go. :)
hehehehe
hi willyb
i cant get any good traffic :-( grr... i dunno whats wrong
here's code that works.
// define correct login
$correct_username = 'test';
$correct_pass = 'test';
if($action == "login")
{
// proceed with verifying password
if ((!$username) OR (!$password))