Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote 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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •