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!
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hey guys I'm using PhP 5 on apache, I'm having issues with the isset function and I was wondering if it was disabled or not heres the code I'm using.
if(isset($_POST['bkquiz']))
{
print("hello to basics");
print("<BR>");
print("bkquiz");
}
now if I did this right this will take the bkquiz button through the post method of my form and see if its set or not. If its set it will do the rest of the code if not it does nothing. I know the buttons set since its doubling as a hyper link like so.
<FORM METHOD ="POST">
<A HREF = "http://localhost/test.php"><INPUT TYPE ="button" NAME ="bkquiz" VALUE ="Practice"></A>
<A HREF = "http://localhost/test.php"><INPUT TYPE ="button" NAME ="bkquiz1" VALUE ="Timed"></A>
</FORM>
dont mind where the links are pointing thats simply for testing purposes Ideally they wil go to seperate links. What I'm overall trying to do here is send a named value to another part of my program that will then pull questions from a specific catagory for testing in this case the catagories are bkquiz and bkquiz1 for testing reasons. This section I made just to test the form and if the function I wrote is feasible at all for retrieving the catagory. The rest is simply tweaking my SQL code which is way easier.
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hmmm... I've never seen button wrapped within <A HREF>
try this
<FORM METHOD ="POST" ACTION="test.php">
<INPUT TYPE ="submit" NAME ="bkquiz" VALUE ="Practice">
<INPUT TYPE ="submit" NAME ="bkquiz1" VALUE ="Timed">
</FORM>
Instead of two buttons, i'd probably suggesst using radio buttons for user to pick option.
problem with that solution is I would need customized pages for each catagory rather than one generic one with a variable containing the catagory which is what I'm trying to accomplish. What I have right now is a "timed" quiz php file and a "practice" quiz php file. What I want to do is submit a variable to one or the other of these pages and pull the right questions from there. thats why the buttons are encapsulated in hyperlinks when its finished each will take you to a different page and then pull the right data. I'm trying to keep from having like a dozen pages of repetative code if possible.
that might work the underlying problem remains isset dosent "do" anything atm. I"ve never been able to get this function to enter into the condtions statements.
because with the <a href> buttons you are not POSTING anything, therefor, POST will not have any values. you have to submit the form to make the POST values there, that is why you should make them submit buttons and not link buttons.
<input type="submit" <--- this is what you want. have the form action goto the test.php page or whatever
<HTML>
<FORM METHOD ="POST" ACTION ="http://localhost/relay.php">
<INPUT TYPE ="radio" NAME ="bkquiz" VALUE ="Practice">Practice
<INPUT TYPE ="radio" NAME ="bkquiz" VALUE ="Timed">Timed
<INPUT TYPE ="submit" NAME ="submit" VALUE ="Submit">
</FORM>
</HTML>