linus72982 Posted July 19, 2010 Share Posted July 19, 2010 I'm trying to make an OOP form handler but not having much success. I've done some detective work on the bug and have broken the code down to it's simplest form and it still doesn't work: <?php // ayam_userInput.php // This class directs and/or handles user input from any forms // on the site class userInput { function userInput() { header ("Location: http://www.MYDOMAIN.com/testpage.php"); } } ?> So if I submit a form with the action being to this script in a different file, it should send me straight to the page in the header. It doesn't, it actually points my browser to the page of the file (/ayam_userInput.php) and of course, it's blank. The actual code has some form handling, but if I can't even get past the class constructor...grief. Am I doing something wrong? Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/208140-problem-with-form-handler/ Share on other sites More sharing options...
KevinM1 Posted July 19, 2010 Share Posted July 19, 2010 Just because you point your form to ayam_userinput.php, that doesn't mean your class will magically instantiate. You still need to do that yourself. You may want to rethink your design in any event. You gain nothing by wrapping a header redirect in an object's constructor. Quote Link to comment https://forums.phpfreaks.com/topic/208140-problem-with-form-handler/#findComment-1088011 Share on other sites More sharing options...
linus72982 Posted July 19, 2010 Author Share Posted July 19, 2010 Thanks, I added an instantiation at the end of the class and it works. As for rethinking my design, as I said in my original post, I boiled the script down for simplicity, it actually has some form handling in the code, but erasing it did nothing to affect the error, so I snipped it out for posting on the forums. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/208140-problem-with-form-handler/#findComment-1088128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.