on Index.php
<?php
if($_POST['id1']=='add')
{
$data=$_POST['user'];
$ch = curl_init();
$user="ssss";
$pwd=$data;
curl_setopt($ch,CURLOPT_URL, "http://127.0.0.1/curl/data.php/?");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&pwd=$pwd");
$buffer = curl_exec($ch);
if(empty ($buffer))
{ echo " buffer is empty "; }
else
{ echo $buffer; }
curl_close($ch);
}
?>
<form name="data" id="data" method="post">
<input type="text" value="" id="user" name="user" />
<input type="submit" name="id1" id="id1" value="add" />
</form>
on data.php
<?php
mysql_connect("localhost","user","pwd") or die(mysql_error());
mysql_select_db("DBname") or die("not connected to db");
$arr_insert = array(
"user" => $_POST['user'],
"pwd" => $_POST['pwd']
);
insertData($arr_insert,ADMIN);
########### USED TO FIRE THE INSERT QUERY
function insertData($arr, $tableName) {
$query = "";
if(! is_array($arr) ) {
die("ERROR: Invalid Operation.");
}
foreach($arr as $key => $value ) {
$query .= "`$key`='$value',";
}
$query = " insert into $tableName set ".substr($query, 0, -1);
mysql_query($query) ;
return mysql_insert_id(); ######## RETURNS LAST INSERTED ID
} # END OF FUNCTION
?>