0

I am sorry for the stupid question, I realize that what I want to do must be extremely simple, but I can't find my way to do it.

I learned basic programing, mostly front end, and enough php to interact with databases and other basics. I can use jquery, javascrip, ajax, no problem in normal situations. But I am not fluent at all in using object-oriented php and I work on a Yii environment.

I have a contact form on the website I'm working on and it works perfectly sending the data to the database. Now I have to re-create the same form, and use it on a pop up box, but I have no idea how to do the php validation and saving to the database in that situation. I've always used Ajax and I tried it, but apparently you need special synthax with ajax on Yii that I am not familiar with.

So is there any way to have the php validation and saving being performed without ajax, (and without the form submitting that refreshes the page and closes the lightbox)?

  • If you are doing php, server-side, validation without refreshing the page you need to use ajax. – Danny Oct 09 '13 at 13:24
  • Did you mean you don't want the form to submit data to server with ajax nor simple post with page refresh? What else left? WebSocket -_- – Prashank Oct 09 '13 at 13:24
  • What about reloading page after submitting form, then automatically opening "lightbox" again to show result? – Māris Kiseļovs Oct 09 '13 at 13:26
  • Thank you for your replies, I just wanted to know if there wasn't other option I haven't thought about. That's all. My php validation and saving works perfectly when the form is submiting, my issue is the lightbox closing. Then I went to jquery and My Jquery validation also works perfectly, but the ajax part will not work because you need special synthax for the framework. So the validation is done, but the data is never actually submited.... I will keep on looking for tutorials of ajax on Yii, thanks you! – user2862929 Oct 09 '13 at 14:20
  • Show us what you have, form model, controller and view please. then maybe we can give you some more specific advice. – jmarkmurphy Oct 09 '13 at 20:14

2 Answers2

2
Community
  • 1
  • 1
0

After everything I tried, because I don't know the Yii framework enough to use ajax in their synthax, I found a way to make my form work with simple jQ. I have an empty onsubmit attribute on my form, that will change to "return false" if there are errors in the js validation, keeping the page from refresh and showing the errors. And if there aren't errors the form will submit the info to php validation then save to the database and all the php will be executed and the lightbox will re-open with the success message.