php post 提交數據

先把JS的提交函數寫好,引入到test.php文件中(別說你不會……)。把函數綁到按鈕的onclick事件上,或者你用setInterval反復執行提交函數。

㈡ php怎麼把表單提交的數據放到資料庫中。

php資料庫操作主要分為5個步驟:1連接MYSQL 2連接到你的資料庫 3寫SQL語句 4運行sql語句 5關閉數版據庫
//第一步
$con = mysql_connect("localhost","root","123456789");
//第二步
mysql_select_db('rankingme',$conn);
//第三權步
$sql="insert into lili (name,sex,et,hobby,photo,tel,address,content,time) values ($name,$sex,$et,$hobby,$photo,$tel,$address,$content,$time)"
//第四步
mysql_query($sql);
//第五步
mysql_close($con);

㈢ 怎麼將表單中的數據提交到資料庫 php

一、php配置MySQL
1、將php安裝目錄下的php_mysql.dll和MySQL安裝目錄下的libmysql.dll文件拷貝至c:/windows/system32中;
2、配置php.ini
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
把上面四個。dll的最前面的;去掉
二、php表單提交至資料庫的實現過程
1、login.php頁面
<SPAN style="FONT-SIZE: 14px"><html>
<FORM method=post action=add.php>
Name: <INPUT name=username><BR>
Email: <INPUT name=email><BR>
<INPUT value=提交 type=submit name=submit>
</FORM>
</SPAN>
2、add.php頁面
<SPAN style="FONT-SIZE: 14px"><?php
include("conn.php");
?>
<?php
if(isset($_POST["submit"]))
{
$sql = "insert into users(username, email) values('$_POST[username]', '$_POST[email]')";
mysqli_query($conn, $sql);
echo "添加成功";
}
?></SPAN>
3、conn.php頁面
<SPAN style="FONT-SIZE: 14px"><?php
$conn = new mysqli("localhost", "root", "159357");
$conn->select_db("db_test");
//mysql_query("set name 'gb2312'");
$conn->set_charset("utf8");
?></SPAN>

㈣ php中按鈕怎麼提交數據到資料庫中

利用表單提交,範例代碼如下:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>無標題文檔</title>
</head>

<body>
<table>
<formname=""action="ip地址"method="post">(這里是新增的)
<tr>
<tdvalign="top"height="110">興趣特長:</td>
<td><textareaname="content"rows="6"class="textarea0"style="width:630px"></textarea></td>
</tr>
<tr>
<tdvalign="top">自我評價:</td>
<td><textareaname="content"rows="6"class="textarea0"style="width:630px"></textarea></td>
</tr>
<tr>
<tdcolspan="2"align="center"><inputtype="submit"value="提交"/></td>
</tr>
</form>(這里是新增的)
</table>
</body>
</html>

㈤ php怎麼獲取form表單提交的數據

一般是用post獲取提交的數據,如下實例:

<formname="form1"method="post">
<p>用戶名版:<inputtype="text"name="uname"/></p>
<p>密碼權:<inputtype="password"name="upwd"/></p>
<p><inputtype="submit"name="btn"value="提交"/></p>
<?php
if($_POST["btn"]){
echo'用戶名:'.$_POST["uname"].'<br>';//三體教程
echo'密碼:'.$_POST["upwd"];
}
?>
</form>

㈥ PHP怎麼獲取表單提交的數據啊

一、用file_get_contents以get方式獲取內容,需要輸入內容為:

1、<?php

2、$url='http://www.domain.com/?para=123';

3、$html = file_get_contents($url);

4、echo $html;

5、?>

二、用file_get_contents函數,以post方式獲取url,需要輸入內容為

1、<?php

2、$url = 'http://www.domain.com/test.php?id=123';

3、$data = array ('foo' => 'bar');

4、$data = http_build_query($data);

5、$opts = array (

6、'http' => array (

7、 'method' => 'POST',

8、 'header'=> "Content-type: application/x-www-form-urlencoded " .

9、 "Content-Length: " . strlen($data) . " ",

10、 'content' => $data

11、)

12、);

13、$ctx = stream_context_create($opts);

14、$html = @file_get_contents($url,'',$ctx);

15、?>

三、用fopen打開url,以get方式獲取內容,需要輸入內容為

1、<?php

2、$fp = fopen($url, 'r');

3、$header = stream_get_meta_data($fp);//獲取信息

4、while(!feof($fp)) {

5、$result .= fgets($fp, 1024);

6、}

7、echo "url header: {$header} <br>":

8、echo "url body: $result";

9、fclose($fp);

10、?>

四、用fopen打開url,以post方式獲取內容,需要輸入內容為

1、<?php

2、$data = array ('foo2' => 'bar2','foo3'=>'bar3');

3、$data = http_build_query($data);

4、$opts = array (

5、'http' => array (

6、'method' => 'POST',

7、'header'=> "Content-type: application/x-www-form-urlencoded Cookie:cook1=c3;cook2=c4 " .

8、"Content-Length: " . strlen($data) . " ",

9、'content' => $data

10、)

11、);

12、$context = stream_context_create($opts);

13、$html = fopen('http://www.test.com/zzzz.php?id=i3&id2=i4','rb' ,false, $context);

14、$w=fread($html,1024);

15、echo $w;

16、?>

五、用fsockopen函數打開url,以get方式獲取完整的數據,包括header和body,需要輸入內容為

1、?php

2、function get_url ($url,$cookie=false)

3、{

4、$url = parse_url($url);

5、$query = $url[path]."?".$url[query];

6、echo "Query:".$query;

7、$fp = fsockopen( $url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30);

8、if (!$fp) {

9、return false;

10、} else {

11、$request = "GET $query HTTP/1.1 ";

12、$request .= "Host: $url[host] ";

13、$request .= "Connection: Close ";

14、if($cookie) $request.="Cookie: $cookie ";

15、$request.=" ";

16、fwrite($fp,$request);

17、while(!@feof($fp)) {

18、$result .= @fgets($fp, 1024);

19、}

20、fclose($fp);

21、return $result;

22、}

23、}

24、//獲取url的html部分,去掉header

25、function GetUrlHTML($url,$cookie=false)

26、{

27、$rowdata = get_url($url,$cookie);

28、if($rowdata)

29、{

30、$body= stristr($rowdata," ");

31、$body=substr($body,4,strlen($body));

32、return $body;

33、}

34、 return false;

35、}

36、?>

㈦ PHP數據提交

資料庫中的該欄位是什麼類型的。看一下不是是這個原因

㈧ php表單怎樣提交到當前頁面,並用$_POST獲取其值

<?php

/**filename:index.php*/
header('content-type:text/html;charset=utf-8');

if(isset($_POST['submit'])){
print_r($_POST);//列印POST中的所有數據
die;
}

?>

<formactionmethod='post'>//不要寫action的值或寫當前文件名(index.php)就會提交到當前頁面
...
<inputtype='submit'name='submit'/>
</form>

㈨ PHP多條數據如何一起提交

參考如下
多個提交和一個提交的道理是相同的,只是一些細節上要注意。
提交一個,表單是:
<form>
<input type=text name=name>
<input type=text name=sex>
<input type=text name=age>
<input type=text name=address>
</form>
PHP存資料庫的語句是:
$sql="insert into tab(...) values ($_POST[...])";//省略欄位和值

那麼多個提交的方法一,表單是:
<form>
<input type=text name=name1><input type=text name=sex1><input type=text name=age1><input type=text name=address1>
<input type=text name=name2><input type=text name=sex2><input type=text name=age2><input type=text name=address2>
</form>
PHP存資料庫語句是:
$sql="insert into tab(...) values ($_POST[...1])";//省略欄位和值
mysql_query($sql);
$sql="insert into tab(...) values ($_POST[...2])";//省略欄位和值
mysql_query($sql);

上面方法一寫的例子是兩條,多條的方法相同,技巧就是輸出表單使用JS的循環,存檔的PHP代碼也可以循環,並且能夠判斷為空的就不提交,比如表單20條,只填了5條,就只存5條到資料庫。

方法二是使用數組,表單:
<form>
<input type=text name=name><input type=text name=sex><input type=text name=age><input type=text name=address>
<input type=text name=name><input type=text name=sex><input type=text name=age><input type=text name=address>
<input type=text name=name><input type=text name=sex><input type=text name=age><input type=text name=address>
</form>
PHP代碼是:
for ($i=0;$i<count($_POST["name"]);$i++)
if ($_POST["name"][$i]!='')
{
$sql="insert into tab(...) values ($_POST[...][$i])";//省略欄位和值
mysql_query($sql);
}
這樣表單可以寫任意多行,PHP裡面是數組,能夠自動獲取有多少數據。

㈩ 求助PHP如何POST提交數據

用PHP向伺服器發送HTTP的POST請求,代碼如下:

<?php
/**
*發送post請求
*@paramstring$url請求地址
*@paramarray$post_datapost鍵值對數據
*@returnstring
*/
functionsend_post($url,$post_data){
$postdata=http_build_query($post_data);
$options=array(
'http'=>array(
'method'=>'POST',
'header'=>'Content-type:application/x-www-form-urlencoded',
'content'=>$postdata,
'timeout'=>15*60//超時時間(單位:s)
)
);
$context=stream_context_create($options);
$result=file_get_contents($url,false,$context);
return$result;
}

使用的時候直接調用上面定義的send_post方法:

$post_data=array(
'username'=>'username',
'password'=>'password'
);
send_post('網址',$post_data);