Get ID from PHP URL and use in a query
<p>I've put certain values like a user id into the url e.g /index.php?id=1 in previous PHP files.</p>

<p>I have a HTML form that has an action like this:</p>

<pre><code>    &lt;form name="staffResponse" method="post" action="respond_ticket.php?id=&lt;?php echo $_GET['id']; ?&gt;"&gt;
</code></pre>

<p>Which when you go to respond_ticket.php and simply echo the value for the id and look at the URL it does it successfully. Whats more the data that I am posting to that file is also done without problem. However I want to then write that information to a table but it does not seem to work.</p>

<p>Here is the respond_ticket.php file</p>

<pre><code>&lt;?php
include 'database/db.php';

$id = $_GET['id'];

$staffResponse = $_POST['staffResponse'];

$sql = "INSERT INTO tickets (staffResponse) VALUES ('$staffResponse') WHERE id='$id'";
$result = mysqli_query($connection, $sql);

if ($result === TRUE) {
echo '&lt;p&gt;Response ' . $staffResponse . ', has been added&lt;/p&gt;';
}
else {
echo '&lt;p class="warning"&gt;Unable to respond&lt;/p&gt;';
}

?&gt;
</code></pre>

<p>The db.php file has all the necessary information for connection to the database i.e name password etc. It also opens the question there too.</p>

<p>I keep just getting the warning message that I wrote.</p>