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
https://forums.phpfreaks.com/topic/7316-small-problem-with-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.