3raser Posted June 30, 2010 Share Posted June 30, 2010 The variable $choosen isn't getting the data from the form for some reason. <?php session_start(); ?> <style> a { color:black; font-weight:bold; } holder { width:600px; } table { width:600px; } </style> <?php session_start(); $session = $_SESSION['user']; mysql_connect($mysql_host, $mysql_user, $mysql_password); mysql_select_db($mysql_database); if(!$session) { echo "Sorry, you must be logged in to access this page!"; } else { $topic_title = $_POST['title']; $topic_message = $_POST['message']; $choosen = $_POST['select']; $topic_title = mysql_real_escape_string($topic_title); $topic_message = mysql_real_escape_string($topic_message); $ip = $_SERVER['REMOTE_ADDR']; $date = date("M-D-Y"); if(!$topic_title || !$topic_message || !$choosen) { echo "<center><div class='holder'><table border='1'><tr><td><center><form action='topic.php' method='POST'>Category:"; echo "<select name='select'>"; $sql = mysql_query("SELECT name FROM categories"); while ($row = mysql_fetch_assoc($sql)) { echo "<option value='". $row['id'] ."'>". $row['name'] ."</option>"; } echo "</select>"; echo "<br/><br/>Thread Title: <input type='text' name='title' maxlength='20'><br/><br/>Message: <br/><textarea name='message' rows='20' cols='35' maxlength='3000'></textarea><br/><br/><input type='submit' value='Post Thread'></form></center> <br/></td></tr></table></div></center>"; } elseif(strlen($topic_message) <= 15) { echo "<center><div class='holder'><table border='1'><tr><td><center>Sorry, you must have at least 15 characters in your topic message! <a href='topic.php'>Back</a></center> <br/></td></tr></table></div></center>"; } else { mysql_query("INSERT INTO topics VALUES ('', '$ip', '$date', '$session', '', '$topic_title', '$topic_message', '0')"); $id = mysql_insert_id(); mysql_query("INSERT INTO category_holder VALUES ('$choosen', '$id')"); echo $category; mysql_query("UPDATE users SET postcount = postcount + 1 WHERE username='$session'"); echo "<center><div class='holder'><table border='1'><tr><td><center>Posted! <a href='index.php'>Go home</a></center> <br/></td></tr></table></div></center>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/206238-variable-isnt-set/ Share on other sites More sharing options...
ChemicalBliss Posted June 30, 2010 Share Posted June 30, 2010 Its "Chosen", just for reference . $sql = mysql_query("SELECT name FROM categories"); while ($row = mysql_fetch_assoc($sql)) { echo "<option value='". $row['id'] ."'>". $row['name'] ."</option>"; } You are only selecting "name" from the table, "id" wont be in the result array. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/206238-variable-isnt-set/#findComment-1078985 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.