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;
?>