At first I have to enter two Accountnames in the website.
My tablename is 'account'.
The rows are id, username and recruiter.
The lines are
7, Janis, 0
and
4, testlol, 0.
I want to 'connect' two users. In the first line - the line of Janis - have to change his 'recruiter' into the value of the other user.
So the result should looks like:
7 | Janis | 4
and
4 | testlol | 7
...
In my php script I wrote
<?php
$servername = "localhost";
$username = "name";
$password = "test";
$dbname = "db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql1 = "UPDATE account SET recruiter=??? WHERE username=\"" . $_POST["account1"] . "\"";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
What do I have to write instead of the ??? for updating it with the other user's id?
It's from this form:
<form action="handler.php" method="post" >
<p>Account Nr.1:</p><input class="input" type="text" name="account1" value="">
<p>Account Nr.2:</p><input class="input" type="text" name="account2" value="">
<p></p><input class="button" type="submit" name="submit" value="Bestätigen">
</form>