There is a form in which the user enters a number and, according to the condition that applies to the number, a list of addresses is displayed. I would like to save data that is returned via AJAX. The code on the page, which has the form:
index.php
<script>
$(document).ready(function() {
$("#phone").keyup(function() {
var number = $("#phone").val();
$.ajax({
url: "t_fetchaddr.php",
type: 'POST',
data: 'number='+number,
cache: false,
}).done(function(html) {
$('#results').html(html);
});
});
});
<script>
<form action="insert_temp.php" method="POST">
<input type="text" name="phoneno" id="phone" value="" />
<div id="results"></div>
<button class="button btn btn-primary btn-large" type="submit" name="submit" value="submit">Submit</button>
</form>
on t_fetchaddr.php page
$val = $_REQUEST['number'];
$sql2 = "SELECT * FROM user_address where number='".$val."' ";
$result2 = mysqli_query($con, $sql2);
if (mysqli_num_rows($result2) > 0)
{ ?>
<div class="span6" >
<div class="span3">
<? while($row2 = mysqli_fetch_assoc($result2))
{ ?>
<input type="radio" name="old_address" value="<? echo $row2['address']; ?>" ><? echo $row2['address']; ?><br>
<? } ?>
</div>
</div>
<? } ?>
code on insert_temp.php
$old_address = mysqli_real_escape_string($con, $_POST['old_address']);
echo $old_address;
Everything works fine until the address is displayed by number, but when I submit the form, it does not go to the background. I tried echo $old_address, but received nothing. The other input values on the index page inside the form are going to the backend, but value that is being fetched from t_fetchaddr.php page is not getting carriedcan anyone tell me where I made a mistake.
source
share