Jump to content

Sending Data from JS to PHP and back


wemustdesign

Recommended Posts

I have created a form, basically this is the data flow

 

- Form.php

 

Passes the data to

 

- Functions.js

This validates the data etc

 

If valid passes the data to

 

- updateDatabase.php

Adds the values from the form to the database

 

Now I want to display the data on the original form page (form.php). I have tried the get 'Functions.js' to pass the data back to 'form.php' but can't get it working.

 

Can anyone reccomend a way to do this or can point me in the direction of a related tutorial?

 

Link to comment
https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/
Share on other sites

form.php

(just a normal form)

 

functions.js


$(".submitLocation").click(function() {
    var name = $("#name").val();
    var dataString = 'name=' + name;

$.ajax({
type: "POST",
			    			
url: "updateDatabase.php",
   data: dataString,
    success: function(){
$('.success').fadeIn(200).show();			
}
});



 

updateDatabase.php

this is just a simple php file which inserts the data sent

 

Basically what I want is to add a 'step 2' of the form. This is where the user can add photos to the listing. To do this I need to get the 'name' that the user submitted in form.php.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.