PHP & MySQL INSERT INTO problem -
any ideas why following code not adding database once user fills out form? i'd appreciate it.
thank you!
if($_session['loginsuccess']==1) { // ============================================================ // = create table of current tasks stored in database = // ============================================================ $userid = $_session['userid']; $result = mysql_query("select * tasks userid = '$userid'"); echo "<div id=\"draggable\" class=\"ui-widget-content\"><table border='5'><tr class=\"ui-widget-header\"><td><u>task name:</u></td><td><u>class:</u></td><td><u>due date:</u></td><td><u>task type:</u></td></tr>"; echo $_session['userid']; while($row = mysql_fetch_array($result)) { $taskname = $row[1]; $class = $row[2]; $taskduedate = $row[3]; $tasktype = $row[4]; echo "<tr><td>'$taskname'</td><td>'$class'</td><td>'$taskduedate'</td><td>'$tasktype'</td></tr>"; } echo "</table>"; function addnewtask ($name, $class, $duedate, $type) { mysql_query("insert tasks values ('$userid','$name', '$class', '$duedate', '$type')"); } if($_post['taskname'] != null) { addnewtask($_post['taskname'], $_post['class'], $_post['duedate'], $_post['duedate']); } ?> <!-- <img border="1" alt="new" src="/newtask.png" id="newtask" onmouseclick="showtaskfield"/> --> <p><form name="newtask" method="post" action="index.php" id="newtask"><br> task name: <input name="taskname" type="text"> (necessary)<br> class: <input name="class" type="text"><br> due date: <input name="duedate" type="text" id="datepicker"><br> type: <input type="submit"></p></div>
try getting rid of ' around variables in insert statement. if nothing echoing mysql_error()
.
Comments
Post a Comment