1 like 0 dislike
1.1k views
in Education & Reference by

1 Answer

0 like 0 dislike
by
 
Best answer

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

?>
by
0 0
great info..thnx.. :)

Related questions

0 like 0 dislike
2 answers 136 views
1 like 0 dislike
1 answer 1.1k views
0 like 0 dislike
1 answer 2.6k views
0 like 0 dislike
1 answer 138 views
0 like 0 dislike
1 answer 75 views
1 like 0 dislike
1 answer 524 views
0 like 0 dislike
1 answer 232 views
0 like 0 dislike
1 answer 16k views
0 like 0 dislike
1 answer 78 views
1 like 0 dislike
1 answer 121 views

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

...