Web Analytics Made Easy -
StatCounter Help with Javascript Form posting to PHP then Insert into SQL - CodingForum

Announcement

Collapse
No announcement yet.

Help with Javascript Form posting to PHP then Insert into SQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Javascript Form posting to PHP then Insert into SQL

    Hello, Below I have my Small form:

    Code:
    <p id="join_our_mailing_list">Join our mailing list</p>
    			<form method="post" name="join" action="#" />
    			<input type="text" class="input_text" name="join_us_email" id="join_us_email" />
    			<input type="submit" value="submit" class="button join_us_button" />
    			</form>

    Then I have my JS to process this...

    Code:
    $(".join_us_button").click(function() {
    			
    		var email = $("#join_us_email").val();
    		var dataString = 'join_us_email='+ email;
    
    		if(email=='')
    			{
    				
    				
    				$('p#join_our_mailing_list').replaceWith("<p>Provide email</p>");
    			}
    		else
    			{
    				$.ajax({
    						type: "POST",
    						url: "join.php",
    						data: dataString,
    						success: function()
    										{
    											$('p#join_our_mailing_list').replaceWith("<p>Thank you</p>");
    										}
    			});
    	}
    return false;
    });
    });



    How and what can I do to allow this form to insert into SQL Database?

    I'd like to insert into SQL their emailaddress, IP, date and referral page....


    Thanks for anyone that can help!

  • #2
    Originally posted by BryanK97 View Post
    How and what can I do to allow this form to insert into SQL Database?

    I'd like to insert into SQL their emailaddress, IP, date and referral page....
    You will need a server side script like php, asp, jsp to submit the form data to. The server side script should then validate and sanitise the form data before inserting it into an sql statement that does the actual data insertion of the form data into a database table.

    Comment

    Working...
    X