Vote count: 0
My player message system isn't working. You start on the Diplomacy page which lists the player nations. Once a player nation is selected they are sent to the send message page which shows any messages between themselves and the nation selected. It also gives them a message box to write their own message to send. Here is the code.
if(isset($_POST['message']) && !empty($_POST['message'])){
$sender = $_GET['nation'];
$receiver = $_GET['receiver'];
$random_number = rand();
$message = $_POST['message'];
$type = $_GET['type'];
$check_con = mysql_query("SELECT `hash` FROM `message_group` WHERE (`user_one`='$sender' AND `user_two`='$receiver') OR (`user_one`='$receiver' AND `user_two`='$sender')");
if(mysql_num_rows($check_con) ===1){
$get_hash = mysql_fetch_assoc($check_con);
$hash = $get_hash['hash'];
mysql_query("INSERT INTO messages (group_hash, from_id, message, seen) VALUES('$hash','$sender','$message','0')");
echo "<p>Message Sent!</p>";
}else{
mysql_query("INSERT INTO message_group (user_one, user_two, hash) VALUES('$sender','$receiver','$random_number')");
mysql_query("INSERT INTO messages (group_hash, from_id, message, seen) VALUES('$random_number','$sender','$message','0')");
echo "<p>Conversation Started!</p>";
}
}
?>
<form method="POST" action="index.php?page=gc3025/send_beta.php&game=<?php echo $game; ?>&type=<?php echo $type; ?>&nation=<?php echo $nations_id; ?>&user=<?php echo $user_id; ?>&receiver=<?php echo $receiver_id; ?>">
<table>
Enter Message:
<tr>
<td></td>
<td><textarea name='message' rows='7' cols='60'></textarea></td>
</tr>
<td><input type='submit' value="Send Message" /></td>
</table>
</form>
If under FORM ACTION I link the page to itself it works but you have to refresh the page to see the new message which also resends the message. If the FORM ACTION goes to the previous page then it does not INSERT the message into the table on the server.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
php, sql INSERT TO not working when ACTION links to another page
Aucun commentaire:
Enregistrer un commentaire