Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. pagina DB.php
  2. <?
  3.     $host = "host:porta"; //database location
  4.     $user = "Username"; //database username
  5.     $pass = "password"; //database password
  6.     $db_name = "nomeDB"; //database name
  7.     $link = mysql_connect($host, $user, $pass);
  8.     if (!$link)
  9.     {
  10.         die('impossibile connettersi: ' . mysql_error());
  11.     }
  12.     $db_selected = mysql_select_db($db_name, $link);
  13.     if (!$db_selected)
  14.       {
  15.       die ("impossibile usare questo DB : " . mysql_error());
  16.       }
  17. ?>
  18.  
  19. Pagina elaborazione.php
  20. <?
  21.     include "DB.php"
  22.  
  23.     $nome = $_POST['Nome'];         /// VALORE 1 "Nome"
  24.     $cognome = $_POST['Cognome'];           /// VALORE 2 "Cognome"
  25.     mysql_query("insert into nometabella (
  26.     nome,
  27.     cognome
  28.     ) Values
  29.     '"+$nome+"','"
  30.     +$cognome
  31.     +"')");
  32.     location()
  33. ?>
  34.  
  35.  
  36. pagina Form.php
  37. <form action="elaborazione.php" method="POST">
  38.    
  39. <label>Nome</label>
  40. <input type="text" name="Nome"></input>         <!-- VALORE 1 "Nome"   -->
  41.  
  42. <label>Cognome</label>
  43. <input type="text" name="Cognome"></input>          <!-- VALORE 2 "Cognome" -->
  44.  
  45. <input type="Submit"></input>
  46. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement