Aphp73 Posted November 13, 2006 Share Posted November 13, 2006 Hey all, I'm a noob PHP programmer who is trying to make a Magic 8-ball application. I have a login form page that takes the user to the 8 ball after they enter there name. The next part I'm having problems starting. I don't have a clue as to how to keep the user at the 8-ball page. I could code this buy making a form on one page and moving the user to the answer page. I tryed using a function and call it using the onclick event of a button. I'm not sure if php even uses the onclick event of a html form. I'm going to use $_Session to do this application, but don't know how to keep the user at the 8-ball page after loggin in. Thanks for any help, its sorely needed. Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/ Share on other sites More sharing options...
fert Posted November 13, 2006 Share Posted November 13, 2006 you could use $_GET Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/#findComment-123796 Share on other sites More sharing options...
Aphp73 Posted November 13, 2006 Author Share Posted November 13, 2006 So the GET_ function will call from a form that is on the same page? I thought that was like POST, in that it calls a ID name from another page. Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/#findComment-124033 Share on other sites More sharing options...
obsidian Posted November 13, 2006 Share Posted November 13, 2006 It doesn't matter whether you use $_GET or $_POST. Those are both simply methods of passing information to the receiving page. Which page you are sent to is up to the [b]action[/b] of the form itself. If you leave it blank or use $_SERVER['PHP_SELF'], you'll send the form to the page itself. Then, you can use an if() statement to handle it. Try something like this:[code]<?php// Process if the form has been submittedif (isset($_POST['submit'])) { // form has been sent, use your processing here}// always output the form itselfecho "<h1>Ask a Question</h1>\n";echo "<form name=\"8Ball\" action=\"\" method=\"post\">\n";echo "<input type=\"text\" name=\"question\" />\n";echo "<input type=\"submit\" name=\"submit\" value=\"Ask!\" />\n";echo "</form>\n";?>[/code]Hope this helps Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/#findComment-124040 Share on other sites More sharing options...
emehrkay Posted November 13, 2006 Share Posted November 13, 2006 just set the form to go to itself.set a hidden variable in your form somehting like 'process'. then at the begining of the page check to see if $_POST['process'] exists $res = ''; if(isset($_POST['process'])){put your processing data here}display your output from the processing and then your form again$res = your results$form = your formecho $res.$form; Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/#findComment-124042 Share on other sites More sharing options...
Aphp73 Posted November 14, 2006 Author Share Posted November 14, 2006 Thanks! :) Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/#findComment-124356 Share on other sites More sharing options...
Aphp73 Posted November 16, 2006 Author Share Posted November 16, 2006 Thanks for the help, it's appreicated :) Link to comment https://forums.phpfreaks.com/topic/27063-magic-8-ball/#findComment-125392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.