PHP &

0 Cevap php

Herhangi bir kullanıcı formu doldurduğu kez aşağıdaki kod veritabanına şey eklemeden değil neden fikir? Ben gerçekten takdir ediyorum.

Teşekkür ederiz!

    if($_SESSION['loginSuccess']==1) {

        // ============================================================
        // = Create the table of current tasks stored in the database =
        // ============================================================
        $userID = $_SESSION['userID'];
        $result = mysql_query("SELECT * FROM Tasks WHERE 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 INTO 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>

0 Cevap