Jump to content

Small Problem With Variable


MoFish

Recommended Posts

hello. I'm trying to add the variable $thread to my database, however when i click submit the value disapears as it is stored in the URL. I have used $thread throught the rest of my page fine, its just this section im just having problems with. I cant figure out how i can add its value of it to the database.

my url looks like the following : page=viewforum&thread=Thread1 and im trying to add the Thread1 section to the database.

how do i go around doing this?

im getting the following notice, because thread does not equal anything when its submitted.

Notice: Undefined index: thread

ive tryed using $thread = $_GET['thread']; before its submitted, but had no success.

Thanks Again, MoFish

[code]        
//if the user hits submit

if (isset($_POST['submit'])){

// set data to a variable
    $data = $_POST['data'];
    
//set the sql query            
        $sql= ("INSERT INTO `forum_data` (`POSTER`, `DATA`, `DATE`, `FORUM_THREAD`) VALUES ('$member', '$data', '$date', '$thread')");
          
// perform the query
       $result = mysql_query($sql);

//display success message
       echo "Succesfully Added\n";

} else {
        
?>

<form method="post" action="index.php?page=viewforum">
      <table width="100%" border="0">
            <tr>
                  <td width="67" valign="top">Message</td>
                  <td width="443"> <input name="data" type="Text" width="500px" height="200px"></td>
            </tr>
      </table>
<input type="Submit" name="submit" value="Post Message">
</form>

<?php

}
[/code]
Link to comment
Share on other sites

To get the "thread" info from the URL, you need to use $_GET or $_REQUEST

$thread = $_GET['thread ']; [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--][i]OR[/i][!--colorc--][/span][!--/colorc--]
$thread = $_REQUEST['thread '];
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.