Affichage des articles dont le libellé est php. Afficher tous les articles
Affichage des articles dont le libellé est php. Afficher tous les articles

samedi 9 janvier 2016

php, sql INSERT TO not working when ACTION links to another page

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.

asked 1 min ago

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

jeudi 16 juillet 2015

Cannot query MongoDb on producer endpoint



Cannot query MongoDb on producer endpoint

SSRS 2010 - Report header missing on txt export



SSRS 2010 - Report header missing on txt export

Inserting javascript into div



Inserting javascript into div

.NET5 on OSX - C# errors in DNVM shell (so close..)



.NET5 on OSX - C# errors in DNVM shell (so close..)

Doxygen not parsing out reference link in markdown



Doxygen not parsing out reference link in markdown

Getting output from a PHP shuffle and INSERT into new database table



Getting output from a PHP shuffle and INSERT into new database table

how to parse nested json array in java



how to parse nested json array in java

Aggregate function repeats values



Aggregate function repeats values

Setup e2e tests with jenkins protractor and grunt



Setup e2e tests with jenkins protractor and grunt

creating a website for machine design calculations



creating a website for machine design calculations

Phonegap Pinlock, Html5 layer/Java layer makes a difference?



Phonegap Pinlock, Html5 layer/Java layer makes a difference?

confusion of char* str="ab", str and &str



confusion of char* str="ab", str and &str

ExtJS--submit date as timestamp



ExtJS--submit date as timestamp

Block until API result cached, then re-instantiate API class



Block until API result cached, then re-instantiate API class

getting values outof a loop (Clojure)



getting values outof a loop (Clojure)

Can you perform dialog navigation on a child window?



Can you perform dialog navigation on a child window?

GET working with Postman, but not with Ajax?



GET working with Postman, but not with Ajax?

Counting Frequencies Using (logical?) Expressions



Counting Frequencies Using (logical?) Expressions

How to execute two procedures or commit inside one to execute a INSERT in a table in part 1 of the script and use the table in part 2



How to execute two procedures or commit inside one to execute a INSERT in a table in part 1 of the script and use the table in part 2