Hello guys,
I am able to update a record using PHP code, but what I would like to do is create an individual file in which it will hold my html form(or even php form).
I know my update code works, as I was able to change a students ‘forename’ from ‘Ann’ to ‘x’, but I would like to represent this by giving the admin the ability to use a form to update user’s that way.
Admin would be able to change the users Forename and Surname (obvs, later on it could grow into password, id etc)
Any help would be appreciated, I’m just going in circles.
p.s. ignore some of the //comments please, wrong wording.
Update.php
<form action="" method="post">
Forename:<input type="text" name="forename">
Surname: <input type="text" name="surname">
<input type="submit" name="update"></form>
<?php
// Connect to the student database
try {
// make the functions in myfunctions.php accessible to us
include ('connect_db.php');
// call the getConnection function we wrote that returns a database connection and store it in the variable $db
$db = getConnection();
// Set up the SQL to query the database to get the module levels
/*** INSERT data ***/
$count = $db->exec("UPDATE student SET forename='' WHERE forename=''");
/*** echo the number of affected rows ***/
echo $count;
/*** close the database connection ***/
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>