Jump to content

Undefined Variable from ajax to POST


xtekuta

Recommended Posts

I have this ajax function in my PRS.php that whenever i select a value from dropdown, a text field will show an output based on the value which selected. In my console i see there was a POST everytime theres a select value from the drop down. But im getting an error 'Undefined Variable' in ff.php which fetching the POST value from PRS.php  Im new in jQuery so im stuck here in this problem. Any solution for this ? Thanks in advance.

Here is my code in PRS.php

<?php $drp = mysqli_query($conn,"SELECT productcode FROM products"); ?>
                          <td><select name="drpcode" onchange="getState(this.value)" class="form-control name_list"><?php  while ($dp = mysqli_fetch_array($drp)) { ?>
                            <option value="<?php echo $dp['productid']; ?>"><?php echo $dp['productcode']; ?></option><?php } ?></select></td>

                      <td><input type="text" id="brandss" name="brand" placeholder="Brand" class="form-control name_list" required  value=" "></td>

 

My code in ff.php

 

<?php
     require_once("conn.php");


      $id = $_POST['productid'];

         $query = mysqli_query($conn,"SELECT productbrand FROM products WHERE productid = '$id' ");

         while($rs = mysqli_fetch_array($query,MYSQLI_BOTH)) {
         $brand = $rs['productbrand'];

 }

echo $brand;

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.