-3

I've tried alternative ways from similar questions but didn't get any good result. I've also tried var_dump($_POST) and isset() methods too. My code is:

<?php
function inputFILTER($data){
    $data = trim($data);
    $data = stripslashes($data);
    $data = strip_tags($data);
    $data = htmlspecialchars($data);
    return $data;
    }
    $question="";
if ($_SERVER["REQUEST_METHOD"] == "POST"){
    $str=$_POST['supportinput'];
    $question=inputFILTER($str);
    echo $question;
}
?>
aksu
  • 5,221
  • 5
  • 24
  • 39
RufatN
  • 3
  • 1
  • Hello @JohnConde I've tried all them but didnt get any happy result. Line: Notice: Undefined index: supportinput in ...\live.php on line 12 – RufatN Jan 09 '14 at 17:05
  • Can you show your html or form section here ! may be input name not the same – Krish R Jan 09 '14 at 17:07
  • " name="support_form" id="support_form"> The form is sent by Ajax Send method. – RufatN Jan 09 '14 at 17:09
  • where is your submit button and its action ? post your `showResult()` code. – Krish R Jan 09 '14 at 17:10
  • Hello @KrishR. It sends with Ajax code when on key down or up. It doesn't need submit button. – RufatN Jan 09 '14 at 17:14
  • Fine, post your `showResult()` function code here. – Krish R Jan 09 '14 at 17:15
  • function showResult(){ var xmlhttp; var formData=$("#support_form").serialize(); if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("result").innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","/respondeo/live.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("formData"); } – RufatN Jan 09 '14 at 17:17
  • 1
    change this `xmlhttp.send("formData");` into `xmlhttp.send(formData);` – Krish R Jan 09 '14 at 17:20

1 Answers1

0

Use this,

xmlhttp.send(formData);

instead of

xmlhttp.send("formData"); 

Javascript:

function showResult(){ 
    var xmlhttp; 
    var formData=$("#support_form").serialize(); 
    if (window.XMLHttpRequest) { 
           xmlhttp=new XMLHttpRequest(); 
     }else { 
             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
       xmlhttp.onreadystatechange=function() { 
             if (xmlhttp.readyState==4 && xmlhttp.status==200) {                                                      document.getElementById("result").innerHTML=xmlhttp.responseText; 
              } 
        }
       xmlhttp.open("POST","/respondeo/live.php",true);
       xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
       xmlhttp.send(formData); 
} 
Krish R
  • 22,583
  • 7
  • 50
  • 59