I have a problem with site based on php and tpl files, I'm a beginner with php but I think the problem is due to something like javascript or ajax. I added an addon (then it should already work perfectly) consists of two files tpl, a php file (for the user) and 2 php files (for the admin side). In admin side I have a settings page with different forms to complete: when I click on Save (type = "submit") the information entered in the form should be added to the database, but instead appears the loading image and continues indefinitely. I have no idea what it might depend on what is due or the problem, or if it depends on the php file or tpl files.
I thought that the problem could depend on this piece of code(I also removed verifyajax() but the problem remained):
if ($input->p['do'] == 'save_settings') {
verifyajax( );
$ht_statistics = $input->pc['ht_statistics'];
$ht_showlastwinners = $input->pc['ht_showlastwinners'];
$ht_lastwinners = $input->pc['ht_lastwinners'];
$ht_profit = $input->pc['ht_profit'];
$ht_win = $input->pc['ht_win'];
$ht_cost = $input->pc['ht_cost'];
if (!is_numeric( $ht_lastwinners )) {
serveranswer( 0, 'Error: Insert number' );
}
if (!is_numeric( $ht_profit )) {
serveranswer( 0, 'Error: Insert number' );
}
if (!is_numeric( $ht_win )) {
serveranswer( 0, 'Error: Insert number' );
}
$upd = $db->query('UPDATE settings SET value=\'' . $ht_statistics . '\' WHERE field=\'ht_statistics\'' );
$upd = $db->query('UPDATE settings SET value=\'' . $ht_showlastwinners . '\' WHERE field=\'ht_showlastwinners\'' );
$upd = $db->query('UPDATE settings SET value=\'' . $ht_lastwinners . '\' WHERE field=\'ht_lastwinners\'' );
$upd = $db->query('UPDATE settings SET value=\'' . $ht_profit . '\' WHERE field=\'ht_profit\'' );
$db->query('UPDATE settings SET value=\'' . $ht_cost . '\' WHERE field=\'ht_cost\'' );
$upd = $db->query('UPDATE settings SET value=\'' . $ht_win . '\' WHERE field=\'ht_win\'' );
serveranswer( 1, 'Settings were updated' );
thanks to the help that you give me, and I apologize if the problem is trivial to you but for me as a beginner it is hard to find, if you need I add all the files that make up the addon.
EDIT
I tried to print the query by entering print_r but I could not find anything, maybe something wrong.
I used the browser console that gave me these answers: mozilla:
expected 'none' or url but found 'alpha('. error in parsing value for 'filter'. declaration dropped
chrome:
POST http://www.example.com/admin/modules/head_tail.php 404 (Not Found)
jquery.min.js:2
send jquery.min.js:2
p.extend.ajax jquery.min.js:2
p.(anonymous function) ?view=addon_modules&module=head_tail:83
addonfrm ?view=addon_modules&module=head_tail:126
onsubmit
seeing the chrome error console I think the problem is in another php file and it is due to this code fragment in javascript:
<script type="text/javascript">
function addonfrm(id){
$(\'#\'+id).l2block();
httplocal = \'/admin/modules/head_tail.php\';
var jqxhr = $.post(httplocal,$("#"+id).serialize(), function(data) {
if(data.status == 0){
$("#"+id).l2error(data.msg);
$("#"+id).l2unblock();
}else if(data.status == 1){
$("#"+id).l2success(data.msg);
$("#"+id).l2unblock();
}
}, "json");
return false;
}
</script>
the problem may be due to the .js files? I installed several add-on, and all of them have this problem.