Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Submitted on August 12, 2015 at 12:36 PM

Section 1 (Text)

<?php
error_reporting(-1);
ini_set('display_errors', 'On');
?>
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxxx";
$dbname = "xxxx";

try {
    $dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    // set the PDO error mode to exception
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }
	$sth = $dbh->prepare("use accessibilita");
?>
<?php
switch ($_GET['action']) {
case 'add':
    switch ($_GET['type']) {
    case 'tages':
            $error = array();
            $nome = isset($_POST['nome']) ?
            trim($_POST['nome']) : '';
            if (empty($nome)) {
                $error[] = urlencode('Please enter a name.');
            }
            $cognome = isset($_POST['cognome']) ?
            trim($_POST['cognome']) : '';
            if (empty($cognome)) {
                $error[] = urlencode('Please select a lastname.');
            }
            $indirizzo = isset($_POST['indirizzo']) ?
            trim($_POST['indirizzo']) : '';
            if (empty($indirizzo)) {
                $error[] = urlencode('Please select a address.');
            }
            $civico = isset($_POST['civico']) ?
            trim($_POST['civico']) : '';
            if (empty($civico)) {
                $error[] = urlencode('Please select a number.');
            }
            $citta = isset($_POST['citta']) ?
            trim($_POST['citta']) : '';
            if (empty($citta)) {
                $error[] = urlencode('Please select a city.');
            }
            $prov = isset($_POST['prov']) ?
            trim($_POST['prov']) : '';
            if (empty($prov)) {
                $error[] = urlencode('Please select a county.');
            }
            if (empty($error)) {
                $stmt = $dbh->prepare("INSERT INTO tagesroma(nome, cognome, indirizzo, civico, citta, prov)
                VALUES (:nome, :cognome, :indirizzo, :civico, :citta, :prov)");
				$stmt->bindParam(':nome', $nome);
				$stmt->bindParam(':cognome', $cognome);
				$stmt->bindParam(':indirizzo', $indirizzo);
				$stmt->bindParam(':civico', $civico);
				$stmt->bindParam(':citta', $citta);
				$stmt->bindParam(':prov', $prov);
			$stmt -> execute();
        } else {
          header('Location:tages.php?action=add' .
              '&error=' . join($error, urlencode('<br/>')));
        }
        break;
    }
    break;
case 'edit':
    switch ($_GET['type']) {
                                      case 'tages':
                                      $error = array();
                                      $nome = isset($_POST['nome']) ?
                                      trim($_POST['nome']) : '';
                                      if (empty($nome)) {
                                      $error[] = urlencode('Please enter a name.');
                                      }
                                      $cognome = isset($_POST['cognome']) ?
                                      trim($_POST['cognome']) : '';
                                      if (empty($cognome)) {
                                      $error[] = urlencode('Please select a lastname.');
                                      }
                                      $indirizzo = isset($_POST['indirizzo']) ?
                                      trim($_POST['indirizzo']) : '';
                                      if (empty($indirizzo)) {
                                      $error[] = urlencode('Please select a address.');
                                      }
                                      $civico = isset($_POST['civico']) ?
                                      trim($_POST['civico']) : '';
                                      if (empty($civico)) {
                                      $error[] = urlencode('Please select a number.');
                                      }
                                      $citta = isset($_POST['citta']) ?
                                      trim($_POST['citta']) : '';
                                      if (empty($citta)) {
                                      $error[] = urlencode('Please select a city.');
                                      }
                                      $prov = isset($_POST['prov']) ?
                                      trim($_POST['prov']) : '';
                                      if (empty($prov)) {
                                      $error[] = urlencode('Please select a county.');
                                      }
                                      if (empty($error)) {
                                  $stmt = $dbh->prepare("UPDATE tagesroma SET nome=?, cognome=?, indirizzo=?, civico=?, citta=?, prov=? WHERE id=?"); // changed to WHERE id=?
                                  $stmt->execute(array($nome, $cognome, $indirizzo, $civico, $citta, $prov,$_GET["id"])); // added $_GET["id"] to the end        
                                  } else {
                                  header('Location:tages.php?action=edit&id=' . $_GET['id'] .
                                         '&error=' . join($error, urlencode('<br/>')));
                                  }
        break;
    }
    break;
}
?>

<html>
 <head>
  <title>Commit</title>
  <meta charset="UTF-8">
 </head>
 <body>
  <p>Done!</p>
<a title="Torna Indietro" href="admin.php">Torna Indietro</a>
 </body>
</html>