Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help needed in sending a form to javascript and then to PHP
Old 02-11-2010, 01:47 PM Help needed in sending a form to javascript and then to PHP
Skilled Talker

Posts: 53
Name: Wizzy
Trades: 0
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.
virtualmisc is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-11-2010, 03:00 PM Re: Help needed in sending a form to javascript and then to PHP
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
you need a create a php file put javascript methods and logics inside the head tag or use an external .js file. Then When javascript validation is done, you pass the values to php page using GET/POST method and retrieve in PHP using $_GET/$_POST methods. Then filter using your PHP codes and finally insert them into the database. I think this is what you wanted to know?
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Old 02-11-2010, 03:47 PM Re: Help needed in sending a form to javascript and then to PHP
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Id look into Ajax if i was you.

You could so summat like this:

Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
         <script language="javascript" type="text/javascript">
<!--
          function senddata() {

          var name = document.getElementById('username');
          $('#confirmation_div ').load("usersubmit.php?username=" + name);

          }
          //-->
</script>
Call senddata from your JS validation and put the users data in usersubmit.php?blaa=blaa&moo=moo etc.

Then
in usersubmit.php

do your stuff.

And whatever usersubmit returns it will then populate your div named confirmation_div with it..

For instance, In confirmation_div you could have your registration form.

Once the php script is called and all goes well you could

Echo "Welcome your now registered";

and this will replace the form with the above message ( all without a page reload or anything )


Hope this helps.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 02-11-2010 at 03:52 PM..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Reply     « Reply to Help needed in sending a form to javascript and then to PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19774 seconds with 12 queries