<?php
function getCurrentIP() {
        $ip = (getenv(HTTP_X_FORWARDED_FOR))
    ?  getenv(HTTP_X_FORWARDED_FOR)
    :  getenv(REMOTE_ADDR);
  return $ip;
}
//Variables for connecting to your database.
//These variable values come from your hosting account.
$hostname = "smoketemplate.db.11823497.hostedresource.com";
$username = "smoketemplate";
$dbname = "smoketemplate";

//These variable values need to be changed by you before deploying
$password = "Aseft8426!";
$usertable = "1test";
$yourfield = "type";

//Connecting to your database
mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);

//Fetching from your database table.
$query = "SELECT * FROM $usertable";
$result = mysql_query($query);

if ($result) {
    while($row = mysql_fetch_array($result)) {
        $name = $row["$yourfield"];
        echo "Name: $name<br>";
    }
}

$query = "INSERT INTO ".$usertable." SET type = 'Test externe', message = 'Test from ".getCurrentIP()."'" ;
	$result = mysql_query($query);
	if ($result) {
		echo "saved";
	}
?>