PHP e la libreria MySqli

 

 

 

Esiste una documentazione ufficiale di PHP che fornisce informazioni dettagliate sia sugli approcci procedurali che su quelli orientati agli oggetti per interagire con MySQL tramite MySQLi. La documentazione ufficiale di PHP รจ un'ottima risorsa per comprendere sia gli aspetti procedurali che quelli orientati agli oggetti della libreria MySQLi.

Ecco i collegamenti alla documentazione PHP che descrivono i due approcci:

  1. Approccio Procedurale (mysqli procedural):

  2. Approccio Orientato agli Oggetti (mysqli object-oriented):

Questi link forniscono una descrizione dettagliata delle funzioni e dei metodi specifici di MySQLi, insieme ad esempi di utilizzo. Potrai trovare le corrispondenze tra le funzioni procedurali e i metodi orientati agli oggetti, oltre a una guida dettagliata sull'utilizzo di MySQLi in PHP.

 

XXX:

 1 <?php
 2 require_once('connect/cnDbLoc.php');
 3 $conn->select_db("Sql349735_1");
 4 session_start();
 5 if (isset($_POST['txUser']) && isset($_POST['txPsw'])) {
 6     $username = trim($_POST['txUser']);
 7     $password = trim($_POST['txPsw']);
 8 
 9         $Query="SELECT * FROM staf WHERE user='$username' AND pasw='$password'";
10         $result = $conn->query($Query);
11         if (!$result) die("Query Error: " . $conn->error); 
12         
13         $row = $result->fetch_assoc(); 
14         if ($row) {  
15                 $_SESSION['Stud']=$row['id_stf'];
16                 header("Location: dbTest.php");
17                 exit;   
18         }else {
19                 header("Location: connect/msgNeg.php");
20                 exit;
21         }       
22 }
23 ?>
24 
25 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
26 <html xmlns="http://www.w3.org/1999/xhtml">
27 <head>
28 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
29 <title>Livello 1</title>
30 <link rel="icon" href="https://www.cersil.it/jv/favicon.ico">
31 <link href="css/pag.css" rel="stylesheet" type="text/css" />
32 <link href="css/codice.css" rel="stylesheet" type="text/css" />
33 <style type="text/css">
34 body {
35         background-color: #073627;
36 }       
37 .stito2 {       font-family: "Times New Roman", Times, serif;
38         font-size: 16pt;
39         font-weight: bold;
40         color: #EDDA54;
41         text-align: center;
42         margin: 0px;
43         font-style: italic;
44 }
45 </style>
46 </head>
47 
48 <body>
49 <p>
50 <p class="stito2">Per accedere inserire:</p>
51 <p class="stito2">&nbsp;</p>
52 <form name="form1" method="post" action="">
53   <table border="0" align="center" cellpadding="0" cellspacing="0" style="background-color: #073627;">
54     <tr>
55       <td align="right"><span class="stito2">Username:</span></td>
56       <td width="10">&nbsp;</td>
57       <td align="center"><input type="text" name="txUser" style="width:150px; height:10pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"/></td>
58     </tr>
59     <tr>
60       <td align="right"><span class="stito2">Password:</span></td>
61       <td width="10">&nbsp;</td>
62       <td align="center"><input type="password" name="txPsw" style="width:150px; height:10pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"/></td>
63     </tr>
64     <tr>
65       <td height="30" align="right">&nbsp;</td>
66       <td width="10">&nbsp;</td>
67       <td align="center"><input type="submit" name="entra" id="entra" value="Entra" style="width:160px;" /></td>
68     </tr>
69   </table>
70 </form></p>
71 </body>
72 </html>
73 

 

CopiaQui