...

View Full Version : Help with Javascript Form posting to PHP then Insert into SQL



BryanK97
08-23-2011, 06:23 AM
Hello, Below I have my Small form:


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




$(".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!

webdev1958
08-23-2011, 06:36 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum