Help needed in sending a form to javascript and then to PHP

3 replies
Hi friends

I'm trying to create a new user function so users can enter data and become a member of my site but it won't work. I have finished coding all the javascript and PHP script validation and sending to server code but I don't know how to join them like this:

'User submits form' --> 'javascript validates form' --> 'PHP validates and sends form values to database'


All I need to know is how to connect the different functions. How would I do this?

Thanks.
#form #javascript #needed #php #sending
  • Profile picture of the author kaido
    Why the heck are you trying to use javascript for this. You can do this all with php.
    1. User submits form
    2. Php checks it lets say (is the username available. or email already used)
    3. If username is registered validation ends and displays user "username not available"
    4. If data is valid insert into database (ofcourse do not forget to escape data before inserting it into database for security reasons)
    Signature

    {{ DiscussionBoard.errors[1759685].message }}
    • Profile picture of the author hhunt
      Originally Posted by kaido View Post

      Why the heck are you trying to use javascript for this. You can do this all with php.
      1. User submits form
      2. Php checks it lets say (is the username available. or email already used)
      3. If username is registered validation ends and displays user "username not available"
      4. If data is valid insert into database (ofcourse do not forget to escape data before inserting it into database for security reasons)
      Think client-side validation. In fact, it is a good practice to have a 3-layer system to ensure your public facing app is safe. Here's how I would go about it:
      1. Validate form with JavaScript
      2. Send to a DAO object on validation
      3. Run another validation on the received data
      4. Connect to database

      Remember that you can abort the operation at any point in that list.

      There you have it. What you need now it the full implementation.

      Good luck
      {{ DiscussionBoard.errors[1759969].message }}
  • Profile picture of the author kaido
    I dont see any point for client side validation ican just turn javascript off to bypass it. Ofcourse you can check it and ask client to turn javascript on. Ofcourse before any database request you should validate data again and escape unwanted characters for security reason.
    Signature

    {{ DiscussionBoard.errors[1767448].message }}

Trending Topics