I have this code for checking the username and ticket availability but something doesnt work well if someone can tell me whats the problem, this error shows me if i enter the right info Invalid Ticket or Receiver
here is the code:
<?php
if(isset($_POST['sendTicket'])) {
$ticketID = $_POST['ticketID'];
$ticketReceiver = $_POST['ticketReceiver'];
$ticket_id = getUserData('kladilnica', 'ticket_id');
$sender = getUserData('users', 'Username');
if(!empty($ticketID) && !empty($ticketReceiver)) {
$sql = "INSERT INTO ticket (senderName, receiverName, Date, ticketID, match1, match2, match3, match4, match5, match6, match7, match8, match9, match10, match11, match12, match13, match14, match15, match16, tip1, tip2, tip3, tip4, tip5, tip6, tip7, tip8, tip9, tip10, tip11, tip12, tip13, tip14, tip15, tip16, Bet, Gain, Odd)
SELECT Username, '".$ticketReceiver."', Date, ticket_id, match1, match2, match3, match4, match5, match6, match7, match8, match9, match10, match11, match12, match13, match14, match15, match16, tip1, tip2, tip3, tip4, tip5, tip6, tip7, tip8, tip9, tip10, tip11, tip12, tip13, tip14, tip15, tip16, Uplata, Dobivka, Odds FROM kladilnica WHERE ticket_id='".$ticketID."' AND `Username`='".$ticketReceiver."'";
$result = $conn->query($sql);
if($result === false) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
if($ticketReceiver == $sender) {
?>
<p>You cannnot send to yourself!</p>
<?php
} else {
if($conn->affected_rows > 0) {
?>
<p>Sended successfully</p>
<?php
} else {
?>
<p>Invalid Ticket or Receiver</p>
<?php
}
}
}
} else {
?>
<p>Can't leave empty</p>
<?php
}
}
?>