stockton Posted July 9, 2007 Share Posted July 9, 2007 I have created a system using PHP & Javascript that works OK except that I want a neat display of error messages. Error messages caught at the client are displayed in a Javascript alert, which is fine. But errors caught at the server are not as well displayed and therefore I thought that I would ask if anyone has produced a "popup error message page" that would look similar to a Javascript alert but would originate at the server. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 9, 2007 Share Posted July 9, 2007 I dont think you are really going to find a good way of doing this. Any sort of pop-up message to the user would have to be given by reloading the page with a particular variable defined(e.g. : yoursite.com/yourscript.php?errors=yes&errormsg=incorrect user name or password) To then produce the pop up you would have to have php echo some javascript. Therefore, if the user doesn't have javascript turned on, then they wont ever see the error message. As far as i can see, there will always have to be alternative error messages for people who do not have javascript turned on. However, it may be that you could you ajax to test for any errors that the php script would generate(such as an incorrect username/password) and display them nicely for users with javascript. Quote Link to comment Share on other sites More sharing options...
stockton Posted July 9, 2007 Author Share Posted July 9, 2007 Javascript is not an issue as this system is intranet and the users have been told by their managment to use IE only and anyway I check that Javascript is enabled at logon time. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 9, 2007 Share Posted July 9, 2007 Ok, so if javascript is definately being used, then you could use ajax to load a php script to do all the server side error checking. If there are no errors, you can submit the form to another php page(which will not need to do any error checking), to deal with the data. If there are errors, alert the user and do not submit the form. Quote Link to comment Share on other sites More sharing options...
stockton Posted July 9, 2007 Author Share Posted July 9, 2007 That was about where I had got to except that I was going to call the server side PHP directly and it could echo the error message(with a tag to show this is an error) and if no error carry on normally. Quote Link to comment 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.