wemustdesign Posted August 8, 2011 Share Posted August 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/ Share on other sites More sharing options...
AyKay47 Posted August 8, 2011 Share Posted August 8, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/#findComment-1254252 Share on other sites More sharing options...
wemustdesign Posted August 8, 2011 Author Share Posted August 8, 2011 My whole webiste is based around Google Maps and is loaded full of JS so if they do not have JS turned on they will only get a noscript error message Quote Link to comment https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/#findComment-1254257 Share on other sites More sharing options...
AyKay47 Posted August 8, 2011 Share Posted August 8, 2011 if you are determined to do this, seeing your code will definitely help to come up with the correct logic here Quote Link to comment https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/#findComment-1254289 Share on other sites More sharing options...
wemustdesign Posted August 8, 2011 Author Share Posted August 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/#findComment-1254311 Share on other sites More sharing options...
AyKay47 Posted August 8, 2011 Share Posted August 8, 2011 the image name? create a function and pass it as an argument to your js function.. Quote Link to comment https://forums.phpfreaks.com/topic/244213-sending-data-from-js-to-php-and-back/#findComment-1254412 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.