kirbyweb Posted October 28, 2009 Share Posted October 28, 2009 Someone is teaching me PHP and he is not on right now.He left me with this:and if you want a script to do something when someone clicks a certain button youd go like this<?phpswitch($_GET['action']){case 'testfunction': test_function(); break;}function Test_function(){if ($test==1)print "Ze test works!!!";elsedie ("Ze test isn't working");}?>then whenever the function opened if $test (a variable ) =1 it would say "Ze test works!!!" and if test equaledd anything else it would say "Ze test isn't working.then you could change whats in the Print quotes to change the message and change the $test variable to change what variable its checking. you could also change the =1 to another number or something like > or != which means doesn't equal.now to run this function you could go like thisprint "<form action='file.php?action=testfunction' method='post'><input type='submit' value=test function' /></form>";put that in your file (but outside your function) and it would make a button called "test function" and when clicked it would open the "test_function" functionCan someone help explain this? Thanks. Link to comment Share on other sites More sharing options...
thescientist Posted October 28, 2009 Share Posted October 28, 2009 Someone is teaching me PHP and he is not on right now.He left me with this:and if you want a script to do something when someone clicks a certain button youd go like this<?phpswitch($_GET['action']){case 'testfunction': test_function(); break;}function Test_function(){if ($test==1)print "Ze test works!!!";elsedie ("Ze test isn't working");}?>then whenever the function opened if $test (a variable ) =1 it would say "Ze test works!!!" and if test equaledd anything else it would say "Ze test isn't working.This is what is known as a conditional statement. You can use, if, eles, do, while and the such to have the script run based on whether or not certain variables or conditions are true false. It's a way of getting your script to react to certain conditions.http://en.wikipedia.org/wiki/Conditional_%28programming%29then you could change whats in the Print quotes to change the messageyup, or instead you could have the script execute additional code (instructions) based on what is being testedand change the $test variable to change what variable its checking. you could also change the =1 to another number or something like > or != which means doesn't equal.. yup, to count for multiple variables or specific conditionsnow to run this function you could go like thisprint "<form action='file.php?action=testfunction' method='post'><input type='submit' value=test function' /></form>";put that in your file (but outside your function) and it would make a button called "test function" and when clicked it would open the "test_function" functionCan someone help explain this? Thanks.in order to execute the script, you have to call it. A form is a way of calling to a server side script to get it do something. Have you tried putting this in a webpage and trying to see what happens? (you need a web server in order to get this to work properly) Link to comment Share on other sites More sharing options...
kirbyweb Posted October 28, 2009 Author Share Posted October 28, 2009 Still not getting this.He told me I can use notepad. Link to comment Share on other sites More sharing options...
thescientist Posted October 28, 2009 Share Posted October 28, 2009 yes you can. but php is a server-side language, and needs to be run from a server in order to execute, browsers can't do it. (the form can pass the its information to the php page, in this case file.php, where it will do what's in its script) you can setup a localhost setup on your computer which will let you simulate server actions. notepad will just let you write the code. Link to comment Share on other sites More sharing options...
kirbyweb Posted October 28, 2009 Author Share Posted October 28, 2009 yes you can. but php is a server-side language, and needs to be run from a server in order to execute, browsers can't do it. (the form can pass the its information to the php page, in this case file.php, where it will do what's in its script) you can setup a localhost setup on your computer which will let you simulate server actions. notepad will just let you write the code.Okay, how do I set up the the localhost thing? Please tell me I do not have to download anything. Link to comment Share on other sites More sharing options...
kirbyweb Posted October 28, 2009 Author Share Posted October 28, 2009 Can you teach me? the other person is not really able to teach me.I want you to teach me php if possible. Link to comment Share on other sites More sharing options...
thescientist Posted October 28, 2009 Share Posted October 28, 2009 depends. I think Windows has IIS, which you might need the install CD for. if not, this could probably get you going in the right direction, but requires a download (free I think).http://www.ehow.com/how_2069183_install-lo...er-windows.html\edit: for IIShttp://www.webwizguide.com/kb/asp_tutorial...s_winXP_pro.aspbut looks like you need XP Pro Link to comment Share on other sites More sharing options...
kirbyweb Posted October 28, 2009 Author Share Posted October 28, 2009 Is there a way I can search IIS? like is there a different name? Link to comment Share on other sites More sharing options...
thescientist Posted October 28, 2009 Share Posted October 28, 2009 well, it stands for Internet Information Server Link to comment Share on other sites More sharing options...
Synook Posted October 28, 2009 Share Posted October 28, 2009 Note you still need to download the PHP interpreter even if you already have IIS installed. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.