Inserting data from scope to PHP variable with ajax request - php

I'm searching for a way to insert scope data from inputs to a php variable, this is how my code look:
HTML:
<div class="form-group" ng-app="Filter" ng-controller="InsertFilter">
<form>
<label for="limit">Limit:</label>
<input type="text" class="form-control" id="limit" name="limit" ng-model="limit">
<label for="page">Page:</label>
<input type="text" class="form-control" id="page" name="page" ng-model="page">
<label for="from">From:</label>
<input type="date" class="form-control" id="from" name="from" ng-model="from">
<label for="to">To:</label>
<input type="date" class="form-control" id="to" name="to" ng-model="to">
<button type="submit" class="btn btn-default" style="margin-top: 15px;">Show Report</button>
</form>
Ajax request in angular:
var FilterApp = angular.module('Filter', []);
FilterApp.controller('InsertFilter', function($scope, $http) {
$http.post("/api/data-dashboard.php").then(function(response){
$scope.limit = /* ??? */;
});
});
data-dashboard.php:
if (empty($_POST["from"])) {
$from = date('Y-m-d');
} else {
$from = $_POST["from"];
}
if (empty($_POST["to"])){
$week = time() + (7 * 24 * 60 * 60);
$to = date('Y-m-d', $week);
} else {
$to = $_POST["to"];
}
if (empty($_POST["page"])) {
$page = 1;
} else {
$page = $_POST["page"];
}
if (empty($_POST["limit"])) {
$limit = 10;
} else {
$page = $_POST["page"];
}
Thanks for all kind responses.
*should I transfer input to json format ?

To Collect all details form Angular HTTP Request use
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$from = request->from;
And pass parameter to $http.post
$http.post("/api/data-dashboard.php",{from:$scope.from}).then(function(response){});

Related

jQuery AJAX Update and Show/Hide Div

Need some help doing my update Ajax call. What I want my code to do is to show when on click my update form and pass the data from the form to my update via AJAX. So far the form isn't showing on click nor is the update working. Everything else seems to be working right except for that.
index.php
<?php include 'includes/header.php' ?>
<div class="main" id="maincontent">
<div class="main-section">
<div class="add-section">
<form action="app/add.php" method="POST" autocomplete="off">
<?php if(isset($_GET['mess']) && $_GET['mess'] == 'error'){ ?>
<label for="title">To Do*</label>
<input type="text" id= "title" name="title"
style="border-color: #ff6666"
placeholder="This is required" aria-label="You need to create a to do!"/>
<label for="month">Month</label>
<input type="text" id="month" name="month" placeholder="Month Not Required" aria-label="Enter a month if needed"/>
<label for="year">Year</label>
<input type="text" id="year" name="year" placeholder="Year Not Required" aria-label="Enter a year if needed"/>
<button type="submit" aria-label="Enter"> &plus; </button>
<?php }else{ ?>
<label for="title">To Do*</label>
<input type="text" id= "title" name="title" placeholder="Enter a To Do" aria-label="Enter a To Do"/>
<label for="month">Month</label>
<input type="text" id="month" name="month" placeholder="Enter Month [1-12]" aria-label="Enter month if needed for your to do"/>
<label for="year">Year</label>
<input type="text" id="year" name="year" placeholder="Enter Year [yyyy]" aria-label="Enter a year if needed for your to do"/>
<button type="submit" aria-label="Enter"> &plus; </button>
<?php } ?>
</form>
</div>
<?php
$todos = $conn->query("SELECT * FROM todos ORDER BY id DESC");
?>
<div class="show-todo-section">
<?php if($todos->rowCount() <= 0){?>
<div class="todo-item">
<div class="empty">
<p>Enter a To Do!</p>
<img src="img/f.jpg" alt="Notebook" width="100%" height="175px" />
</div>
</div>
<?php } ?>
<?php while($todo = $todos->fetch(PDO::FETCH_ASSOC)) { ?>
<div class="todo-item">
<span id="<?php echo $todo['id']; ?>" class="remove-to-do" aria-label="Delete"><i class="fa fa-trash" style="font-size:18px"></i></span>
<span id="<?php echo $todo['id']; ?>" class="update-to-do" aria-label="Edit">
<i class="fa fa-pencil" style="font-size:18px"></i></span>
<?php if($todo['checked']) { ?>
<input type="checkbox" data-todo-id="<?php echo $todo['id']; ?>" class="check-box" checked />
<h2 class="checked"><?php echo $todo['title'] ?></h2>
<?php }else{ ?>
<input type="checkbox" data-todo-id="<?php echo $todo['id']; ?>" class="check-box">
<h2><?php echo $todo['title'] ?></h2>
<?php } ?>
<br>
<small>Created: <?php echo $todo['date_time'] ?> </small>
<div style="display:none;" class="update"><?php include 'updateForm.php'?></div>
<!---->
</div>
<?php } ?>
jQuery
<script>
$(document).ready(function(){
$('.remove-to-do').click(function(){
const id = $(this).attr('id');
$.post("app/remove.php",
{
id: id
},
(data) =>{
if(data){
$(this).parent().hide(600);
}
}
);
});
$(".check-box").click(function(e){
const id = $(this).attr('data-todo-id');
$.post("app/check.php",
{
id: id
},
(data) =>{
if(data != 'error')
{
const h2 = $(this).next();
if(data === '1'){
h2.removeClass('checked');
}else{
h2.addClass('checked');
}
}
}
);
}); /* */
$(".update-to-do").click(function(e){
const id = $(this).attr('id');
var title = $(this).attr('id'); //find
var month = $(this).attr('id');
var year = $(this).attr('id');
$.post("app/update.php",
{
id: id,
title: title,
month: month,
year : year
},
(data) =>{
//alert(id);
if(data != 'error')
{
var x = document.getElementsByClassName(".update");
if(form.hide()){
form.show();
}else{
form.hide();
}
}
}
);
});
});
updateForm.php
<div class="add-section">
<form action="app/update.php" method="POST" autocomplete="off">
<?php if(isset($_GET['mess']) && $_GET['mess'] == 'error'){ ?>
<label for="id" style="display:none;"></label>
<input type="hidden" id= "id" name="id" value="<?php echo $_GET['id']; ?>" aria-label=""/>
<label for="title">To Do*</label>
<input type="text" id= "title" name="title"
style="border-color: #ff6666"
placeholder="This is required" aria-label="You need to create a to do!"/>
<label for="month">Month</label>
<input type="text" id="month" name="month" placeholder="Month Not Required" aria-label="Enter a month if needed"/>
<label for="year">Year</label>
<input type="text" id="year" name="year" placeholder="Year Not Required" aria-label="Enter a year if needed"/>
<button type="submit" aria-label="Enter"> &plus; </button>
<?php }else{ ?>
<label for="id" style="display:none;"></label>
<!--<input type="hidden" id= "id" name="id" value="<?php //echo $_GET['id']; ?>" aria-label="id"/> -->
<label for="title">To Do*</label>
<input type="text" id= "title" name="title" placeholder="Enter a To Do" aria-label="Enter a To Do"/>
<label for="month">Month</label>
<input type="text" id="month" name="month" placeholder="Enter Month [1-12]" aria-label="Enter month if needed for your to do"/>
<label for="year">Year</label>
<input type="text" id="year" name="year" placeholder="Enter Year [yyyy]" aria-label="Enter a year if needed for your to do"/>
<div class="pad"></div>
<button type="submit" aria-label="Enter"> &plus; </button>
<?php } ?>
</form>
</div>
update.php
<?php
if(isset($_POST['id'])){
require '../includes/conn.php';
include 'func.php';
$id = $_POST['id'];
echo $id;
$title = $_POST['titleUp'];
$month = $_POST['monthUp'];
$year = $_POST['yearUp'];
$dateMonth;
$futureDate;
if(empty($id))
{
header("Location: ../updateForm.php?id=" . $id . "mess=error");
}
else
{
if( (!empty($title)) && (empty($month)) && (empty($year)) )
{ //need to filter 0 so its registered as not empty
$title = validTitle($title);
$stmt = $conn->prepare("UPDATE todos(title) VALUE(?) WHERE id=?");
$res = $stmt->execute([$title, $id]);
if($res)
{
header("Location: ../index.php");
}
else
{
header("Location: ../updateForm.php?id=" . $id . "mess=error");
}
$conn= null;
exit();
}
else if( (!empty($title)) && (!empty($month)) && (empty($year)) )
{
$title = validTitle($title);
$month = validMonth($month);
$dateMonth = dateMonth($month);
$year = date("Y");
$futureDate = futureDate($dateMonth, $year);
$stmt = $conn->prepare("UPDATE todos (title, future_datetime) VALUES (?,?) WHERE id=?");
$res = $stmt->execute([$title ,$futureDate, $id]);
if($res)
{
header("Location: ../index.php");
}
else
{
header("updateForm.php?id=" . $id . "mess=error");
}
$conn= null;
exit();
}
else if( (!empty($title)) && (!empty($month)) && (!(empty($year))))
{
$title = validTitle($title);
$month = validMonth($month);
$dateMonth = dateMonth($month);
$year = validYear($year);
$futureDate = futureDate($dateMonth, $year);
$stmt = $conn->prepare("UPDATE todos (title, future_datetime) VALUES (?,?) WHERE id=?");
$res = $stmt->execute([$title ,$futureDate, $id]);
if($res)
{
header("Location: ../index.php");
}
else
{
header("Location: ../updateForm.php?id=" . $id . "mess=error");
}
$conn= null;
exit();
}
else
{
header("Location: ../updateForm.php?id=" . $id . "mess=error");
}
}
}
else
{
header("Location: ../updateForm.php?id=" . $id . "mess=error");
}
?>
You are POSTing to the page but checking for GET.
Good manual pages to read:
Handling external variables
Example:
$.post("app/update.php",
{
id: id
alert(id);
},
That will send a POST to the app/update.php script you have which contains the following:
<?php
// $GET is not the same as $_GET
if(isset($GET['id'])){
require '../includes/conn.php';
include 'func.php';
$id = $GET['id'];
echo $id;
This will not work given that you are POSTing but looking incorrectly at $GET (which should be $_GET).
To fix change the following lines to:
<?php
if($_POST['id']){
require '../includes/conn.php';
include 'func.php';
$id = $_POST['id'];
echo $id;
Please note that $GET and $_GET aren't the same things, nor are $POST and $_POST.

$_POST value returns blank/empty

I do have a form where the user can retrieve the data depending on the dates selected. Here's what I have:
<form class="form" method="post">
<div class="form-row">
<div class="form-group col-md-2 col-5">
<label class="col-form-label col-form-label-sm" for="From">From</label>
<input type="date" class="form-control" id="fromDate" name="fromDate" value="<?php echo (new DateTime('first day of this month'))->format('Y-m-d');?>">
</div>
<div class="form-group col-md-2 col-5">
<label class="col-form-label col-form-label-sm" for="To">To</label>
<input type="date" class="form-control" id="toDate" name="toDate" value="<?php echo (new DateTime('today'))->format('Y-m-d');?>">
</div>
<div class="form-group col-md-1 col-2">
<label class="col-form-label col-form-label-sm text-white" for="Search">Search</label>
<input type="button" class="btn btn-success btn-block" id="submit" name="submit" value="Submit" onclick="getResult()">
</div>
</div>
</form>
<div id="data_result"></div>
On the same page, I have a script below:
<script>
function getResult(){
var fm = $('#fromDate').val();
var to = $('#toDate').val();
$.ajax({
method: 'POST',
url: 'chart-data/card-sales.php',
data: { fm:fm, to:to },
success: function(data) {
$('#data_result').html(data);
}
});
}
</script>
And finally, my chart-data/card-sales.php file:
<?php
// db settings
$hostname = 'localhost';
$username = 'root';
$password = 'password';
$database = 'accounts';
// db connection
$con = mysqli_connect($hostname, $username, $password, $database) or die("Error " . mysqli_error($con));
$fm = '';
$to = '';
if(isset($_POST['fromDate'],$_POST['toDate']))
{
$date1 = strtr($_POST['fromDate'], '/', '-');
$fm = date('Y-m-d',strtotime($date1));
$date2 = strtr($_POST['toDate'], '/', '-');
$to = date('Y-m-d',strtotime($date2));
} else {
var_dump($_POST);
}
echo'<div id="data_result">
<h6>
<span class="text-danger">'.$fm.'</span> to
<span class="text-danger">'.$to.'</span>
</h6>';
$sql="SELECT * FROM sales WHERE date >='$fm' and date <= '$to'";
foreach ($con->query($sql) as $row) {
echo'//table contents';
};
echo '</div>';
?>
The thing is, $fm and $to returns an empty value (1970-01-01) that is why I couldn't get the proper data I need while the var_dump($_POST); returns array(2) { ["fm"]=> string(10) "2021-01-01" ["to"]=> string(10) "2021-01-26" }. So I think the main problem here is that I cannot get the input value from my form. Why is that so?
The problem is that you're not using the correct indexes on $_POST.
You should use the same indexes that you sent in the ajax: fm and to.
Change this:
if(isset($_POST['fromDate'],$_POST['toDate']))
{
$date1 = strtr($_POST['fromDate'], '/', '-');
$fm = date('Y-m-d',strtotime($date1));
$date2 = strtr($_POST['toDate'], '/', '-');
$to = date('Y-m-d',strtotime($date2));
} else {
var_dump($_POST);
}
To this:
if(isset($_POST['fm'], $_POST['to']))
{
$date1 = strtr($_POST['fm'], '/', '-');
$fm = date('Y-m-d',strtotime($date1));
$date2 = strtr($_POST['to'], '/', '-');
$to = date('Y-m-d',strtotime($date2));
} else {
var_dump($_POST);
}
P.S: Yo should take a look about SQL injection and prepared queries as #Strawberry suggested.
I encourage you to change to an object-oriented aproach using PDO
As you send in your ajax call, data: {fm: fm, to: to} this is what to use.
Try to change:
if (isset ($_POST['fromDate'], $_POST['toDate']))
{
$date1 = strtr($_POST['fromDate'], '/', '-');
...
$date2 = strtr($_POST['toDate'], '/', '-');
...
}
by
if (isset ($_POST['fm'], $_POST['to']))
{
$date1 = strtr($_POST['fm'], '/', '-');
...
$date2 = strtr($_POST['to'], '/', '-');
...
}

Wordpress wp_mail function error in template via ajax

I have created a WordPress template which has the capability of sending emails via ajax and the wp_mail function. The everything is okay apart from the wp_mail function which gives a false response and therefore the email is not sent. I have tried researching for a possible solution for almost a week now but no success. Below is my code, hope you can help me figure out where the issue is.
The error displayed is on this line
throw new Exception('Failed to send email. Check AJAX handler
fruu.');
located in the functions.php file.
template functions.php file
wp_enqueue_script('jquery');
function makeBooking() {
try {
if (empty($_POST['start']) || empty($_POST['names']) || empty($_POST['email']) || empty($_POST['bphone']) || empty($_POST['adult']) || empty($_POST['child'])) {
throw new Exception('Bad form parameters. Check the markup to make sure you are naming the inputs correctly.');
}
if (!is_email($_POST['email'])) {
throw new Exception('Kindly enter a valid email.');
}
$e = explode(" - ", $_POST['start']);
$date1 = new DateTime($e['0']);
$date2 = new DateTime($e['1']);
$diff = $date2->diff($date1)->format("%a");
if(($diff < '2') ? $s='': $s='s');
if (($_POST['adult'] < '2') ? $ss = '' : $ss = "s");
if ($_POST['child'] == 'no') {
$cs = "No Children";
} else {
if ($_POST['child'] < '2') {
$cs = "1 Child";
} else {
$cs = $_POST['child'].' Children';
}
}
if ($_POST['req'] == '') {
$req = "";
} else {
$req = " \n\nSpecial Request: ".$_POST['req'];
}
$subject = 'New Booking Request from: '.$_POST['names'];
$headers = 'From: '.$_POST['names'].' <'.$_POST['email'].'>';
$send_to = "booking#mysite.com";
$message = "Booking Duration: ".$diff." day".$s." from ".date("l M dS, Y", strtotime($e['0']))." to ".date("l M dS, Y", strtotime($e['1']))." \n\nBooking Party: ". $_POST['adult'] . " Adult".$ss." and ".$cs.". \n\nContact Number: +" . $_POST['bphone']."".$req;
if (wp_mail($send_to, $subject, $message, $headers)) {
echo json_encode(array('status' => 'success', 'message' => 'Contact message sent.'));
exit;
} else {
throw new Exception('Failed to send email. Check AJAX handler fruu.'); //THIS IS THE ERROR THAT IS RETURNED BY THE SCRIPT
}
} catch (Exception $e) {
echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
exit;
}
}
add_action("wp_ajax_makeBooking", "makeBooking");
add_action('wp_ajax_nopriv_makeBooking', 'makeBooking');
The Form
<form class="contact modal-form" name="contact" id="booking_form">
<input type="hidden" name="form_send" value="send" />
<input required class="col-lg-12 form-control" name="start" id="start" placeholder="Duration of Stay" type="text">
<input required class="col-lg-12 form-control" name="end" id="end" value="" placeholder="Departure Date" type="text">
<input required class="form-control col-lg-12" name="names" id="names" value="" placeholder="Full Names" type="text">
<input required class="form-control col-lg-12" name="email" id="email" value="" placeholder="Email Address" type="email">
<input required class="form-control col-lg-12" name="bphone" id="bphone" value="" placeholder="Phone Number (e.g 2547xx 123xx4)" type="tel">
<select required style="" class="col-lg-12 form-control" name="adult" id="adult">
<option selected="selected" value="">Adults</option>
<?php
echo '<option value="1">1 Adult</option>';
$i = '2';
while ($i < '11') {
$k = $i;
echo '<option value="'.$k.'">'.$k.' Adults</option>';
$i++;
}
?>
</select>
<select required style="" class="col-lg-12 form-control" name="child" id="child">
<option selected="selected" value="">Children</option>
<?php
echo '<option value="no">No Children</option>';
echo '<option value="1">1 Child</option>';
$i = '2';
while ($i < '11') {
$k = $i;
echo '<option value="'.$k.'">'.$k.' Children</option>';
$i++;
}
?>
</select>
<textarea class="form-control col-lg-12" name="req" id="req" placeholder="Special Request"></textarea>
<input type="hidden" name="action" value="makeBooking" />
<button class="btn btn-success" type="submit" id="sendBooking"><i class="fa fa-spinner fa-pulse fa-fw hide fa-2x" id="sending"></i><span id="text" class=''>Send</span></button>
</form>
jQuery Code and please note I have left out the code with the data validation rules
$('#sendBooking').click(function(e) {
$.ajax({
url:"/wp-admin/admin-ajax.php",
type:'POST',
dataType: 'JSON',
data:$("#booking_form").serialize(),
cache: false,
success: function(data){
show_ok(data);
},
error: function(){
$("#sending").addClass("hide");
$("#text").removeClass("hide");
$("#sendBooking").removeClass("disabled");
$("#msg_not_sent").removeClass("hide");
}
});
e.preventDefault();
});
Thanks in advance.
Make sure all serialize data you are getting in ajax call.if require use PHP unserialize function:
parse_str($_POST["data"], $_POST);
Then change
$send_to = "booking#mysite.com";
to your actual email and check it again.
I discovered the source of my error after weeks of research. So, the issue is based on PHP rather than the code. As it turns out, the from address has to be similar to the domain name, that is, if the domain name is example.com, the from address has to be email#example.com. If the from address is name#email.com, the connection will be closed by the server automatically.

Not inserting null values

I am trying to insert multiple values in the todo input of the form. but if i do not input a value to any input the null value is inserted in the database. This is my controller action:
public function actionAdd()
{
if (Yii::$app->request->isAjax) {
$request = Yii::$app->request;
$add = new Project();
$add->project_name = $request->post('project');
$add->deadline = $request->post('deadline');
$add->profile_id = $request->post('profile_id');
$add->project_status = "Running";
$add->save();
$getlast = Yii::$app->db->getLastInsertId();
$todo = $request->post('todo');
if (isset($todo)) {
foreach ($todo as $to) {
$add = new Todo();
$add->todo_name=$to;
$add->status="Running";
$add->project_id=$getlast;
$add->save();
}
}
echo json_encode(TRUE); die;
}
echo json_encode(FALSE);die;
}
the form is:
<form class="formclass" method="POST" action="<?php echo Yii::$app->request->baseUrl;?>/todo/add/" role="form" id="register-form" novalidate="novalidate">
<label> Project Name: </label> <input type="name" name="project" class="form-control" placeholder="Project Name" required><br><br>
<input type="hidden" name="profile_id" value="<?php echo $profile_id;?>">
<label> Todo: </label><br>
<textarea type="text" name="todo[]" placeholder="Todo Description..."></textarea>
<div id="dynamicInput">
<span class="glyphicon glyphicon-plus" onClick="addInput('dynamicInput');"></span>
</div><br>
<label> Project Deadline:</label><br>
<input type="date" name="deadline"><br><br>
<button type="submit" class="btn btn-default">Add Project</button><BR><BR>
</form>
And the jquery is:
var counter = 1;
var limit = 10;
function addInput(divName)
{
if (counter != limit)
{
var newdiv = document.createElement('div');
newdiv.innerHTML = "<br><textarea type='text' name='todo[]' placeholder='Todo Description...'></textarea>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}
Could be you problem is related to the validation rules ..
for check this and only for debugging try use $add->savel(false)
$add = new Todo();
$add->todo_name=$to;
$add->status="Running";
$add->project_id=$getlast;
$add->save(false);
if in this case the rows are inserted the check for validations rule (eventually comment temporary) .. for find the wrong rules or condition

Not able to submit multiple forms on single html page

I have problem with forms on one file.
The problem is that when I click submit ... it submits the first form data instead of the form that the person filled even though as you can see from the code below that I specified a certain id for each form.
I am using a php file to submit the data to mysql
here is my code:
case 'upd_chpt':
if($_POST['does'] == 'upd_chpt')
{
$chId = $_POST['chId'];
$name = $_POST['name'];
$nums = $_POST['nums'];
$mngs = $_POST['mang'];
$ch_trans = $_POST['ch_trans'];
$ch_down = $_POST['ch_down'];
$ch_translate = $_POST['ch_translate'];
$ch_clean = $_POST['ch_clean'];
$ch_editor = $_POST['ch_editor'];
if(!empty($chId) && !empty($name) && !empty($nums) && !empty($mngs) && !empty($ch_trans))
{
$mnG = explode(',' , $mngs);
$qup = $db->query("UPDATE chapter SET ch_name = '".$name."', chapter_num = '".$nums."', manga_id = '".$mnG[0]."', manga_title = '".$mnG[1]."', manga_name = '".$mnG[2]."', ch_down = '".$ch_down."', ch_translate = '".$ch_translate."', ch_clean = '".$ch_clean."', ch_editor = '".$ch_editor."', ch_trans = '".$ch_trans."' WHERE ch_Id = '".$chId."' ");
if($qup)
{
echo "updated successfully";
}
else
{
echo "erorr ";
}
}
else
{
echo "please fill all the fields !";
}
}
break;
html code :
<form id="edit_{$ch[ch].ch_Id}">
<input type="hidden" name="chid" value="{$mn[mn].ch_Id}" />
<label>chapter number</label>
<input type="text" id="chaptr" name="chaptr" value="{$ch[ch].chapter_num}" class="short" />
<label>chapter title </label>
<input type="text" id="name" name="name" value="{$ch[ch].ch_name}" class="short" />
<label>manga related to chapter</label>
<select id="mansga" name="manga">
{section name='mn' loop=$mng}
<option value='{$mng[mn].mn_Id},{$mng[mn].mn_title},{$mng[mn].mn_name}' {if $mng[mn].mn_Id==$ch[ch].manga_id}selected="true" {/if}>
{$mng[mn].mn_name}
</option>
{/section}
</select>
<label>chapter link</label>
<input type="text" id="ch_down" name="ch_down" value="{$ch[ch].ch_down}" class="short" />
<label>all credit goes to</label>
<input type="text" id="ch_trans" name="ch_trans" value="{$ch[ch].ch_trans}" class="short" />
<label>translated by</label>
<input type="text" id="ch_translate" name="ch_translate" value="{$ch[ch].ch_translate}" class="short" />
<label>cleaned by</label>
<input type="text" id="ch_clean" name="ch_clean" value="{$ch[ch].ch_clean}" class="short" />
<label>edited by</label>
<input type="text" id="ch_editor" name="ch_editor" value="{$ch[ch].ch_editor}" class="short" />
<label><input type="submit" class="submit" value="تعديل" /></label>
</form>
javascript :
$('[id^=edit_]').submit(function(){
var id = $(this).attr('id').split('_')[1];
var name = $('#name').val();
var nums = $('#chaptr').val();
var mang = $('#mansga').val();
var ch_trans = $('#ch_trans').val();
var ch_down = $('#ch_down').val();
var ch_translate = $('#ch_translate').val();
var ch_clean = $('#ch_clean').val();
var ch_editor = $('#ch_editor').val();
$.post("action.php", {does: 'upd_chpt' ,ch_trans:ch_trans, ch_down:ch_down, ch_translate:ch_translate , ch_clean:ch_clean , ch_editor:ch_editor , chId:id , name: name, nums: nums, mang:mang},function(m){
alert(m);
});
return false
});
can this code be changed ? and be only php + html without javascript ! ... because I think that id="" is the problem
the mistake was on the second line
{$mn[mn].ch_Id} should be {$ch[ch].ch_Id}

Categories