MoFish Posted April 13, 2006 Share Posted April 13, 2006 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: threadive tryed using $thread = $_GET['thread']; before its submitted, but had no success.Thanks Again, MoFish[code] //if the user hits submitif (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 More sharing options...
predator12341 Posted April 13, 2006 Share Posted April 13, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7316-small-problem-with-variable/#findComment-26613 Share on other sites More sharing options...
bbaker Posted April 13, 2006 Share Posted April 13, 2006 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 https://forums.phpfreaks.com/topic/7316-small-problem-with-variable/#findComment-26615 Share on other sites More sharing options...
MoFish Posted April 13, 2006 Author Share Posted April 13, 2006 bingo, cheers fellas. Link to comment https://forums.phpfreaks.com/topic/7316-small-problem-with-variable/#findComment-26616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.