This is my HTML form:
<form action='buddy_update.php'>
<input type='text' name='buddy1' required='' placeholder='Player ID / E-mail'>
<input type='hidden' name='id' value=''%".$id."%''>
<input type='submit' value='Request Buddy #1!'>
</form>
This is my PHP on buddy_update
<?php
include 'credentials.php';
$id=$_GET['id'];
$buddy1=$_GET['buddy1'];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$id=$_GET['id'];
$buddy1=$_GET['buddy1'];
$sql = "UPDATE buddy SET buddy1_id = '".$buddy1."' WHERE main_player = '".$id."'";
if (mysqli_query($conn, $sql)) {
echo $id;
echo $buddy1;
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
$buddy1 comes through absolutely fine but $id doesn't.
For what it's worth I have also changed the value='' to a plain text input on the HTML form and it still doesn't work. The output in the PHP form is still blank.
EDIT No idea why I've defined variables twice! Took the one out but still same problem