I am trying to get foreach data I am using jquery to submit the page without a refresh being required for some reason jQuery is not retrieving the foreach data, It needs to loop through each admin input field to see each data seperatly.
If it's not possible I won't use JQuery for this but thought I ask
PHP:
if(isset($_POST['admin_add']) AND is_array($_POST['admin_add'])) {
foreach($_POST['admin_add'] as $admin_add) {
if(strlen($admin_add) > 0) {
// $sql=mysql_query("insert into hobbies(hobby)values('$hobby')");
}
}
}
die('<h3>'.$admin_add.'<h3/>');
jQuery:
$(document).ready(function () {
var clan_url_string = window.location.search.substring(1);
// Make a function that returns the data, then call it whenever you
// need the current values
function getData() {
return {
clan_title_edit: $('#clan_title_edit').val(),
clan_des: $('#clan_des').val(),
admin_add: $('#admin_add').val(),
//remember_me: ($('#remember_me').is(':checked')) ? 1 : 0
}
}
$(window).load(function(){
$('#background_cycler').fadeIn(1500);//fade the background back in once all the images are loaded
setInterval('cycleImages()', 4000); // run every 4s
});
function loading(e) {
$('#loading_status').show();
}
function hide_loading(e) {
$('#loading_status').hide();
}
function success_message(e) {
$('#success_login').html("We're Just Signing You In");
}
function clearfields() {
$('#login-username').val(''); //Clear the user login id field
$('#login_password').val(''); //Clear the user login password field
}
function check(e) {
e.preventDefault();
$.ajax({
url: 'ajax/save_settings.php?'+clan_url_string,
type: 'post',
error: function () {
//If your response from the server is a statuscode error. do this!!!'
hide_loading(e);
$('#status_message').html('<b>Something Has Gone Wrong</b><br> Please Try Again Later');
},
beforeSend: function () {
loading(e);
},
data: {
clan_title_edit: $('#clan_title_edit').val(),
clan_des: $('#clan_des').val(),
admin_add: $('#admin_add').val(),
remember_me: ($('#remember_me').is(':checked'))
}, // get current values
success: function (data) {
//if your response is a plain text. (e.g incorrect username or password)
hide_loading(e);
$('#status_message').hide();
$('#status_message').fadeIn(1000).html(data);
}
});
}
// Don't repeat so much; use the same function for both handlers
$('#login_content').keyup(function (e) {
if (e.keyCode == 13) {
var username = $('#login-username').val();
check(e);
}
});
$('#submit_clan_settings').click(function (e) {
if (e.keyCode != 13) {
check(e);
}
});
There's the php and jquery
Thanks
Yes its SQL injection prone, havent fix this yet and I should be using
mysqli
or$db->
);