Jump to content

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

validate all form data with PHP, DO NOT use JS to validate any kind of user input as JS can be disabled, thus rendering your validation useless, thus allowing the user to enter anything that he/she desires into your form(s)

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.