dotkpay Posted May 17, 2011 Share Posted May 17, 2011 Hello, For some time I have been wondering which one is a better means to transfer an error from a processing file back to the main page, for example a user fills in a wrong username or password at index.php which is submitted for processing to login.php. What is the best means to transfer the error "Wrong username or password" from login.php back to index.php for display, so far i was using a $_SESSION variable but i wonder how effective it can be. I was then told $_GET variables are a good choice as well, i dont think submitting a form to itself is a good solution. Please advice me on the best means to proceed with this. Thanx in advance Quote Link to comment https://forums.phpfreaks.com/topic/236604-error-printing-sessions-or-get/ Share on other sites More sharing options...
phppaper Posted May 17, 2011 Share Posted May 17, 2011 submit to itself with post Quote Link to comment https://forums.phpfreaks.com/topic/236604-error-printing-sessions-or-get/#findComment-1216348 Share on other sites More sharing options...
dotkpay Posted May 17, 2011 Author Share Posted May 17, 2011 submitting to the same file is suitable if the files are short and simple but we are talking about 300+ lines of code per file. Submitting to itself will make it over 500 lines, wont this slow execution at the server? Imagine if every file is about 200KB in size Quote Link to comment https://forums.phpfreaks.com/topic/236604-error-printing-sessions-or-get/#findComment-1216380 Share on other sites More sharing options...
phppaper Posted May 17, 2011 Share Posted May 17, 2011 you only include the checking username and password in your case within the same file, if success do redirect, if not echo error message then you dont have to worry about the transfer the error. The thing you want is that if error, you could still see the input form. Quote Link to comment https://forums.phpfreaks.com/topic/236604-error-printing-sessions-or-get/#findComment-1216382 Share on other sites More sharing options...
dotkpay Posted May 17, 2011 Author Share Posted May 17, 2011 So which is the best way of submitting a form to the same page, can I leave the action attribute blank or should use PHP_SELF? Quote Link to comment https://forums.phpfreaks.com/topic/236604-error-printing-sessions-or-get/#findComment-1216416 Share on other sites More sharing options...
JonnoTheDev Posted May 17, 2011 Share Posted May 17, 2011 doesn't matter Quote Link to comment https://forums.phpfreaks.com/topic/236604-error-printing-sessions-or-get/#findComment-1216419 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.