11-03-2013, 10:58 AM
اضافة سجل جديد
اما كود php
الدروس متاخرة قليلا لاني بدات في تعلم mysqli لاني قرات ان php ستستغني على mysql
PHP كود :
var test:TDynamicSA;
list:TStringList;
begin
// test:=split(IdHTTP1.Get('http://127.0.0.1/exemple_02/active.php?hdd=123'),'|');
//if test[0]='MSG' then
//ShowMessage(test[2]);
//---------------------
list:=TStringList.Create;
list.Add('add=membre') ;
list.Add('hdd=hhhh') ;
list.Add('user=delphi') ;
list.Add('windows=win7') ;
list.Add('cntry=USA') ;
IdHTTP1.Post('http://127.0.0.1/exemple_02/active.php',list) ;
list.Free;
end;
اما كود php
PHP كود :
if(isset($_POST['add'])){
InsertMembre();
echo 'Insert_Membre';
}
PHP كود :
//-------------------------------------------------------------------------
function con(){return new mysqli('localhost', 'root', '', 'delphi');}
//-------------------------------------------------------------------------
function InsertMembre()//<<<
{
$mysqli = con();
$date = date("Y-m-d H:i:s");
$ip =$_SERVER["REMOTE_ADDR"];
$stmt = $mysqli->prepare("INSERT INTO membres(ip,hdd,user,windows,date,cntry) VALUES (?, ?, ?, ?, ?,?)");
$stmt->bind_param('ssssss',$ip,$_POST['hdd'],$_POST['user'],$_POST['windows'],$date,$_POST['cntry']);
$stmt->execute();
$stmt->close();
}

