hello everyone, i have a form, and onsubmit, reg_check() is called and a redirection is supposed to take place, which is not happening in my case, lol. ive been trying for a while and not getting anywhere, like the redirection would work if i called the function the body, which is not what i want..any ideas?
mmmm first off, the code works now.
i was trying to find a way to redirect to a php page to check if the username is already taken (checking the database). any better ideas?
You could do it a few ways. One way would be to put in a check in the php page your referring the submittal form to . As in - submit form, first php action is to check if the username is already taken and if so redirect back to the form with an error message , but in most browsers this would cause the form data to be lost and they have to start over.
The more modern and much better method would be to write an ajax function that does a call to a php page that checks for username existence, returns false or true. If it gets a true, return true then allow the form to submit, if false, return false then display an error message on the page and prevent form submittal.
I use jquery for most of my code as it helps with crossbrowser issues and frankly I'm a little weak on correct JS methods. I found an article addressing a similar question using jquery and php to do a similar function so you have sort of a visual to reference - http://stackoverflow.com/questions/3...can-i-get-jque
Originally Posted by user1991
mmmm first off, the code works now.
i was trying to find a way to redirect to a php page to check if the username is already taken (checking the database). any better ideas?
nice, but since now im working with php ill go on with it and get back to the ajax later cuz ive never worked with it before.
but now for the first option, thats what im doing already, now if the user is taken, u get a usertaken msg and back to the form. how about if the username is not taken? i want to go to the homepagewhich is easy, but more importantly, i want to insert the user data into the database, how do i do that if the submit does the redirect??
you would could the php to do the check if the usernaem exists, the check fails and put your redirect function there using the php method, and if the username doesnt exist then submit your data and perform a home page redirect after that
it doesnt have the other user data in order to submit them if the username is not taken, is there a way to post them or something?
and im not using the "action" of the form this way, just the onsubmit... isnt that .. weird? xD
it doesnt have the other user data in order to submit them if the username is not taken, is there a way to post them or something?
and im not using the "action" of the form this way, just the onsubmit... isnt that .. weird? xD
I'm confused as to why you would even want to do it in such a fashion. Maybe it would be better to pose your question in the php forum
yeah actually i got an idea to do it, ill try it out now. im sure what im doing now is not so "professional" but im just getting used to this passing variables from and to clientside/serverside so this helps.
thanks a lot for ur ajax suggestion ill check it out later cheers
Bookmarks