似乎无法通过表单向我的数据库添加简单的用户输入

时间:2017-06-04 01:06:25

标签: php mysql

这很快。

我有一个表单,提交时应该将用户输入添加到我的数据库中。我有一个类似的形式运作良好但由于某种原因这个不起作用。

请原谅我的草率代码,但这是整个页面。出于某种原因观察'不会接受用户输入并在下一页显示它(showOne.php)。下一页只显示一个空白区域进行观察,我检查了数据库,当然观察区域没有任何内容。

我能看到的是一件简单的事情吗?我已经在这几天了,因为它与我在另一页上运作良好的另一种形式相同。

感谢您的任何见解。

<?php
//including the database connection file
include("config.php");
$activePage = "start.php";


if(isset($_POST['update'])) {  
    $id = $_POST['id'];
    $observation = $_POST['observation'];

    $result = mysqli_query($mysqli, "UPDATE tasks SET observation='$observation' WHERE id=$id");

header("Location: showOne.php?id=$id");
}

//getting id from url
$id = $_GET['id'];
//selecting data associated with this particular id
$result2 = mysqli_query($mysqli, "SELECT * FROM users WHERE id=$id ORDER BY id ASC");
$result = mysqli_query($mysqli, "SELECT * FROM tasks ORDER BY taskNumber ASC");


include_once "nav.php";
?>

<!doctype html>
<html lang="en">
<head>

<meta charset="utf-8">
<title>Pathfinder - A User Testing Dashboard</title>
<meta name="description" content="Pathfinder - A User Testing Dashboard">
<meta name="author" content="James Stables - Thurs April 13th 2017">

<link rel="stylesheet" href="core.css">

<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet">

<!--[if lt IE 9]>
<script     src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js">        </script>
<![endif]-->

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>


</head>
<body>
<header>
<a href="index.php"><h1 class="logo"><img src="images/logo.png">Pathfinder</h1></a>
<h4>User Testing Dashboard</h4>
</header>

<section class="nonav">
<div class="showAllUsers">
<table border='0'>
    <tr>
    <?php while($res = mysqli_fetch_array($result2))
    { ?>
        <td class="widthHundred no-border left"><h2><?php echo $res['nameFirst']; ?></h2></td>
    <?php } ?>

    </tr>
</table>

<table border='0'>
<thead>
<tr>
    <th>Image</th>
    <th>Category</th>
    <th>Task Number</th>
    <th>Task Name</th>
    <th>Observation</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td> 
</tr>
</thead>

<tbody>

<form name="start" method="post" action="start.php" enctype="multipart/form-data">
<tr>
    <td><a href="<?php echo $res['$image'];?>" data-lightbox="example-1" data-title="Task Number&nbsp;&nbsp;<?php echo $res['taskNumber'];?>">
    <img id="imageResize" src="<?php echo $res['image'];?>" /></a></td>
    <td><?php echo $res['category'];?></td>
    <td><?php echo $res['taskNumber'];?></td>
    <td><?php echo $res['taskName'];?></td>
    <td><input type="text" name="observation" value="<?php echo     $res['observation'];?>"></td>  
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>   
<?php } ?>

</tr>
<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>        
    <td><input type="hidden" name="id" value="<?php echo $_GET['id'];?>"><input type="submit" class="buttonUpdate right" name="update" value="Update"></td>
    <td><a class="buttonCancel right" href="tasks.php" onClick="return confirm('Cancel and go back?')">Cancel</a></td>
</tr>



</form>

</tbody>
</table>

</div>

</section>

<script src="js/lightbox-plus-jquery.min.js"></script>

<script>
lightbox.option({
  'resizeDuration': 200,
  'showImageNumberLabel': false,
  'fitImagesInViewport': true
})
</script>

</body>
</html>

0 个答案:

没有答案