I am trying to insert data from an automated POST request into a database, but it is not inserting it and is throwing no errors. (None in error log) Code:
<?php
function getBetween($content,$start,$end){
$r = explode($start, $content);
if(isset($r[1])) {$r = explode($end, $r[1]);
return $r[0]; } return''; }
file_put_contents("outputfile.txt", file_get_contents("php://input"), FILE_APPEND );
$cip = $_POST['ipaddr'];
$cid = $_POST['id'];
$conn = mysqli_connect('localhost', '********', '*******');
$sql = "INSERT INTO slso (asid, ips) VALUES ('$cid', '$cip')";
mysqli_query($conn, $sql); mysqli_close($conn);
?>
The content of outputfile.txt is this:
ipaddr=192.168.0.4&id=8&endipaddr=***.**.230.62&id=8&end
However no data is ever inserted into the database. Am I making a simple mistake that I am not noticing?
mysqli_query.mysqli_php.net/manual/en/function.mysqli-connect.php requires 4; are you not choosing a database? Once you've done that, domysqli_query($conn, $sql) or die(mysqli_error($conn));<?php error_reporting(E_ALL); ini_set('display_errors', 1);then the rest of your code, to see if it yields anything also.ipaddr=192.168.0.4&id=8&endipaddr=***.**.230.62&id=8&endsuggests a GET method, yet you're using two POST arrays. Your question is unclear. Post your HTML form.