1 Replies - 563 Views - Last Post: 19 July 2011 - 05:30 PM

#1 thatgoogleguy  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 76
  • Joined: 26-May 11

JavaScript to PHP

Posted 15 July 2011 - 09:03 AM

Is there a simple way to copy form data using Javascript into PHP variables so that I can add them to my database? The reason I'm doing it this way because the form will already have on function which redirects a user to paypal to pay. I don't want multiple buttons so I'm using Javascript to copy the form data into php. the submit button will then save the javascript/php content into the database as well as take the user to paypal to pay.

Is This A Good Question/Topic? 0
  • +

Replies To: JavaScript to PHP

#2 bodom658  Icon User is offline

  • Villiage Idiom
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,123
  • Joined: 22-February 08

Re: JavaScript to PHP

Posted 19 July 2011 - 05:30 PM

Take a look at using PHP with JSON (And AJAX). (There's an entire api online)

In Javascript, we can pull the values out of a form via your preferred method. I like jQuery myself. something like:

var data = $('#my-form').serialize();

$.ajax({
    type: 'POST',
    url: '/path/to/file.php',
    data: data
});



And then handle it from the POST data over on the PHP side =)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1