Jump to content


Photo

Small Problem With Variable


  • Please log in to reply
3 replies to this topic

#1 MoFish

MoFish
  • Members
  • PipPipPip
  • Advanced Member
  • 210 posts

Posted 13 April 2006 - 02:27 PM

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">
            <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

}


#2 predator12341

predator12341
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts
  • LocationCheshunt, Hertfordshire, England

Posted 13 April 2006 - 02:29 PM

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
[a href="http://www.sloganizer.net/en/" target="_blank"][/a]

#3 bbaker

bbaker
  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 13 April 2006 - 02:31 PM

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--]OR[!--colorc--][/span][!--/colorc--]
$thread = $_REQUEST['thread '];

#4 MoFish

MoFish
  • Members
  • PipPipPip
  • Advanced Member
  • 210 posts

Posted 13 April 2006 - 02:34 PM

bingo, cheers fellas.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users