Advertisement
Guest User

server.php

a guest
Feb 26th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php
  2.  
  3.     // server.php
  4.     //
  5.    
  6.     // Imposta qua le variabili per l'accesso al database
  7.     $host = 'localhost'; // Cambia questa variabile se diversa
  8.     $user = 'root'; // Cambia questa variabile se diversa
  9.     $pass = 'root'; // Cambia questa variabile se diversa
  10.     $database_name = 'tutorial_mysql';  // Cambia questa variabile se diversa
  11.  
  12.     if($_POST['invia']){
  13.  
  14.         $dato = $_POST['dato'];
  15.  
  16.         $conn = mysql_connect($host, $user, $pass) or die (mysql_error());
  17.  
  18.         mysql_select_db($database_name, $conn) or die (mysql_error());
  19.  
  20.         mysql_query(" INSERT INTO test (id, valore) VALUES (NULL, '$dato') ") or die(mysql_error());
  21.  
  22.         // Questa รจ la funzione che una volta eseguita la query ti reindirizza alla pagina che vuoi.
  23.         // Devi sostituire http://www.example.com/ con l'indirizzo della pagina
  24.         header('Location: http://www.example.com/');
  25.     }
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement