Hi., I want to update an entry that ive selected from a table.
Everything is running but the data does not update>
This is the code of the Table where I select the data.
This is the code for the page where I input the new data
and this is where the update happens
Can anyone review my code especially on the update query Ive probably missed out something . Thanks in advance.
Everything is running but the data does not update>
This is the code of the Table where I select the data.
<?php $conn=mysql_connect("localhost","root",""); if(!$conn) { die('could not connect!' . mysql_error()); } mysql_select_db("people", $conn); $result = mysql_query("SELECT * FROM usersinfo"); ?> <table> <tr> <td>Recent Posts</td> </tr> <?php while($row = mysql_fetch_array($result)) : ?> <tr> <td><?php echo $row['USERNAME']; ?></td> <td><?php echo $row['LASTNAME']; ?></td> <td><?php echo $row['FIRSTNAME']; ?></td> <td><?php echo $row['MI']; ?></td> <td><?php echo $row['COMPANY']; ?></td> <td><?php echo $row['POSITION']; ?></td> <td><?php echo $row['DEPARTMENT']; ?></td> <!-- and so on --> <td> <form action="delete.php" method="post"> <input type="hidden" name="delete_id" value="<?php echo $row['ID']; ?>" /> <input type="submit" value="Delete" /> </form> <form action="modifypage.php" method="post"> <input type="hidden" name="modify_id" value="<?php echo $row['ID']; ?>" /> <input type="submit" value="Modify" /> </form> </td> </tr> <?php endwhile; ?> </table>
This is the code for the page where I input the new data
<?php echo"<form name='myForm' action='modify.php' method='post'>"; echo"<br>"; echo "Lastname: <input type='text' name='ace_firstname'>"; echo"<br>"; echo "Firstname: <input type='text' name='ace_lastname'>"; echo"<br>"; echo "Midlename: <input type='text' name='ace_middlename'>"; echo"<br>"; echo "Company: <input type='text' name='ace_project'>"; echo"<br>"; echo "Position: <input type='text' name='ace_department'>"; echo"<br>"; echo "Department: <input type='text' name='ace_position'>"; echo"<br>"; echo "id: <input type='hidden' name='ace_id' value='" . $modify . "'>"; echo"<br>"; echo "<input type='submit' value='Submit'>"; ?>
and this is where the update happens
<?php $MODfirstname=$_POST["ace_firstname"]; $MODlastname=$_POST["ace_lastname"]; $MODmiddlename=$_POST["ace_middlename"]; $MODproject=$_POST["ace_project"]; $MODdepartment=$_POST["ace_department"]; $MODposition=$_POST["ace_position"]; $MODid = ($_POST['ace_id']); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("people", $con); mysql_query("UPDATE usersinfo SET LASTNAME='" . $MODlastname . "', FIRSTNAME='" . $MODfirstname . "', MIDDLENAME='" . $MODmiddlename . "', PROJECT='" . $MODproject . "', DEPARTMENT='" . $MODdepartment . "', POSITION='" . $MODposition . "' WHERE ID=' " . $MODid . " '"); mysql_close($con); ?>
Can anyone review my code especially on the update query Ive probably missed out something . Thanks in advance.
