edit.php

back


<?php

require_once('classes/selectClass.php');

// Includes the class file to select a row of data from the database.

$id=$_GET['id'];

// The primary key of the row to be selected is passed through URL and hence pulled through $_GET array.

$select=new selectClass();

// Creates new object of selectClass.

$select=$select->selectFunction($id);

// Passes the primary key, $id as an argument to the function selectFunction of class selectClass. 

$name=$select['name'];

// $name is pulled from the associative array $select

?>

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">

<!-- The above line links to the external stylesheet of w3.css -->

<title>A form for PHP OOP</title>

</head>

<body>

<div class="w3-container w3-blue w3-large">

<form name="form" method="post" action="editaction.php">

<!-- Data submitted to this form will be processed by editaction.php -->

Name:

<p><input type="text" name="name" value="<?php echo $name;?>" /></p>

<!-- The form is pre populated by its current value -->

<p><input type="hidden" name="id" value="<?php echo $id;?>"/></p>

<!-- We need to pass the primary key, $id to editaction.php in hidden form -->

<p><input type="submit" name="submit" />

<input type="reset" name="reset" /></p>

</form>

</div>

</body>

</html>