php - Statement returning an empty string -



php - Statement returning an empty string -

i confused why when create ajax phone call php script, returns empty string. believe checking in php , if empty should trigger notif msg. triggering success msg if string coming empty. in post section of firebug, can see inputs beingness posted right values , if alert serialize data, beingness posted correctly.

how can check if php receiving data? have tried print_r, var_dump nil displayed in console. grateful if point out error. many thanks

jquery

$(function() { $.validator.setdefaults({ errorclass: 'form_error', errorelement: 'span', ignore: ":hidden:not(select)", errorplacement: function(error, element) { error.appendto(element.siblings('span')); } }); $("#usrrecycle").validate({ rules: { rcyrequested: { required: true }, rcyservice: { required: true }, rcydept: { required: true }, rcyaddress: { required: true }, rcyqty: { required: true, number: true }, rcydatepicker: { required: true, date: true } }, messages: { rcyrequested: { required: '* required: must come in name' }, rcydept: { required: "* required: must select department" }, rcyaddress: { required: "* required: must select client address" }, rcyservice: { required: "* required: must select service level" }, rcyqty: { required: "* required: must come in quantity", number: "* quantity amount must number. ie, 200" }, rcydatepicker: { required: "* required: must come in delivery recycle date", date: "* must come in date in format: 07/10/2014" } }, submithandler: function() { if ($("#usrrecycle").valid() === true) { var info = $("#usrrecycle").serialize(); alert(data); $.ajax({ type: "post", url: "rcy.php", data: data, datatype: 'json', success: function(data) { if (data.opp == 'error') { console.log(data.qty); notif({ msg: '<br />error! ' + '<b><font color="red">' + data.qty + '</font></b>' + ' not submitted.<br /><br /> must come in amout.<br /><br />' + 'please right error , seek again.' + 'thank you.', type: "boxdstrerror", position: "center", width: 490, height: 75, multiline: true, timeout: 8000, opacity: 0.8, fade: 10, }); } else { console.log(data.qty); $("#usrrecycle").get(0).reset(); $("#rcydept").trigger("chosen:updated"); $("#rcyaddress").trigger("chosen:updated"); notif({ msg: "your submission successfull." + '<br /><br />' + '<b><font color=\"black\">' + data.qty + '</font></b><br /><br />' + ' entry submitted database.<br />thank you.', type: "boxdstrsuccess", position: "center", width: 490, height: 75, multiline: true, timeout: 8000, opacity: 0.8, fade: 10, }); } } }); } } }); });

php - rcy.php

<?php session_start(); // test vars jquery form $status = mysql_real_escape_string($_post['status']); $company = mysql_real_escape_string($_session['kt_idcode_usr']); $requested = mysql_real_escape_string($_post['rcyrequested']); $activity = mysql_real_escape_string($_post['rcyactivity']); $address = mysql_real_escape_string($_post['rcyaddress']); $service = mysql_real_escape_string($_post['rcyservice']); $date = explode('/', $_post['rcydatepicker']); $newdate = $date[2].'-'.$date[1].'-'.$date[0]; $authorised = mysql_real_escape_string($_session['kt_name_usr']); $dept = mysql_real_escape_string($_post['rcydept']); $array = array(); $array = $_post['rcyqty']; $outstring = ''; foreach ($array $qty) { $qty = mysql_real_escape_string($qty); // if $qty empty, send output outstring display notif error msg if ($qty == " ") { $outstring .= $qty . ' '; } } if ($outstring) { // if there numbers in string, there error duplicates $error = array('opp' => "error", 'qty' => $outstring); // qty have text notif msg // important, have changed json output utilize opperation (opp) indicate // in javascript if there error or not $output = json_encode($error); echo $output; exit(); } // execute success if $outstring empty (no exit();) foreach ($array $qty) { $outstring .= $qty . ' '; $qty = mysql_real_escape_string($qty); } $json = array('opp' => 'insert', 'qty' => $outstring); $result = json_encode($json); echo $result; ?>

html

<div class="fieldset"> <h1><span>enter quantity reqd</span></h1> <p> <input id="rcyqty" name="rcyqty" type="text" required="required" style="width:250px; height:30px;" /><span></span> <a href="javascript:void(0)" class="removeclass"></a> <a style="margin-left: 14px;" href="javascript:void(0)" class="tooltip" title="please come in quantity of boxes/sacks require.">help</a> </p> </div>

php jquery ajax

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -