ok, I am studying the program editor...
I have write some code to make call to my server in mysql for a login routine with ADO...
This is the code I have used and it functions well...
[code for connection to MySQL 5.3 with parameters renamed...]
$cn = new COM("ADODB.Connection") or die("CANNOT START ADO");
$cnstr = "DRIVER={MySQL ODBC 5.3 Unicode Driver}; Port=3306;DATABASE=DBTEST;UID=username;PWD=password;";
$rs = new COM("ADODB.Recordset");
$rs1 = new COM("ADODB.Recordset");
[/code]
Code: Select all
<?php
// Chiudo la connessione al DATABASE
// $cn->Release();
$cn->Close();
$cn = null;
if (isset($_SESSION["DBSTATUS"])){
$_SESSION["DBSTATUS"]="DB CLOSED OK..";
}
?>
the function from the page to make the call
[function]
function Seleziona(pagina) {
document.<?php echo $FormName?>.action = pagina;
document.<?php echo $FormName?>.submit();
return true;
}
function AccessoAlSistema(U,P) {
var datiform="?username="+U;
datiform = datiform + "&password="+P;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var risposta=this.responseText;
var lista = risposta.split(";");
if (lista[0]=="0")
{
Seleziona(lista[2]);
}
else
{
document.getElementById("msg").value = lista[1];
}
}
};
xhttp.open("GET", "logon.php"+datiform, true);
xhttp.send();
}
[/code functions]
and the code php on the server
Code: Select all
<?php
$Table="user";
// CONNESSIONE AL DATABASE
include('Connessione.php');
session_start();
//$userid="vic53";
//$password="merlino";
$username=$_GET["username"];
$password=$_GET["password"];
$SQL="select * from users where username='".$username."'";
$rs1->Open($SQL,$cn);
if ($rs1->eof == false)
{
$pw=$rs1->Fields["password"]->value;
if ($pw==$password) {
echo "0;Login eseguito [".$username."]...;Homepage.php;";
$_SESSION['username']=$username;
}
else
{
echo "1;password errata in accesso al sistema...".$userid.";Index.php;";
}
}
else
{
echo "2;dati errati in accesso al sistema... ;Index.php;";
}
$rs1->Close();
include("Disconnessione.php");
?>
Now i am writing the first page for my site...
thanks fro the answer
ciao from Italy
Vincenzo