Time for action – retrieving data from the form post
When pressing
the save button, the form values are posted to the server. The form_save
function needs to retrieve these values and store them into the database. Let's look at how the different parts of this function work.
As the data is going to be used for updating the Cacti database, it's always a good idea to make it more secure by using the available mysql_escape_string
function:
// Retrieve the data from the form post /* Add hostId statement here */ if (isset ($_POST['longitude'])) { $s_dataLongitude = mysql_escape_string($_POST['longitude']); } if (isset ($_POST['latitude'])) { $s_dataLatitude = mysql_escape_string($_POST['latitude']); } if (isset ($_POST['contactAddress'])) { $s_dataContactAddress = mysql_escape_string($_POST['contactAddress']); } if (isset ($_POST['additionalInformation'])) { $s_dataAdditionalInformation = mysql_escape_string($_POST['additionalInformation']); }
The special $_POST
variable...