0

I am creating a messaging system in my website. I have a GET variable that I retrieve from the URL which indicates which user the inputted message should be sent to. I store this variable (messagesTo = $_GET['id']) in a form (with the message body and the logged-in user's id) and once the message is clicked, theoretically the included page should be called and the message should be stored in a DB based on the form's data.

URL w/ user's id inside of it

Form page (directMessages.php)

Instead, it says I get an error with the $_GET['id']. I have an error check and the message in the URL says that there is no value for $_GET['id']. No message is being sent to the database.

directMessages Included page (directMessages.inc.php)

Functions page for direct (dmFunctions.inc.php)

  • 1
    Welcome to Stack Overflow! Relevant code and error messages need to be included in your question *as text*, [not as pictures of text](https://meta.stackoverflow.com/q/285551/328193). Just linking to screen shots makes it more difficult for people to help you. To learn more about this community and how we can help you, please start with the [tour] and read [ask] and its linked resources. – David Dec 12 '22 at 19:40

1 Answers1

-1

You're not outputting the hidden values in your form (directMessages.php), ie:

<input name="messagesTo" type="hidden" value="<?php $_GET['id'] ?>">

should be

<input name="messagesTo" type="hidden" value="<?php echo $_GET['id']; ?>">

Basically you need to echo the value for it to be present in the HTML.

cOle2
  • 4,725
  • 1
  • 24
  • 26