Jump to content


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


Small Problem With Variable

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

//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">
                  <td width="67" valign="top">Message</td>
                  <td width="443"> <input name="data" type="Text" width="500px" height="200px"></td>
<input type="Submit" name="submit" value="Post Message">



Share this post

Link to post
Share on other sites
to send a value in php through the url do this

<form method="post" action="<? echo "index.php?page=".$Variable_Here."";?>">

that should set it out for you ok

Share this post

Link to post
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 '];

Share this post

Link to post
Share on other sites


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.