English 中文(简体)
投入箱的价值,没有形式?
原标题:Get value of input box, without a form?

是否有任何人知道,在没有形式的情况下,我如何能够获得投入箱的价值? 我想提一个提子,但我不想提交表格,而是想改变我的SQL数据库的数据。 可能这样一些?

$img1="WHAT DO I PUT HERE?"
$idx=1  
$sql="INSERT INTO games SET img1= $img1  WHERE id=$idx";  
$result=mysql_query($sql); 

我能否在一次“立克”活动中使用该守则? 投入箱的名称和名称为“img1”。

最佳回答

如果你不希望提交表格,则唯一实现这一目的的两种途径是点击与数据的联系,作为圆顶的查询参数,或利用宇宙航空研究开发机构向服务器发送数据。

更新:

Javascript,与往常一样。 您在网页上与“服务器之末”或文本中的任何内容链接或附加。 该书将把你的信息从投入领域取出,然后通过美国宇宙航空研究开发机构电话将其发送服务器。 大致如此(请注意,使用Mootools,因为这使生活变得比需要远距离电话:

 function clickHandler() {
     var img1 = $$("input[name= img1 ]")[0].value;

     var r = new Request.JSON({
          url:  http://yourserver.example.com/script.php ,
          method :  post ,
          onComplete : function(success) { alert( AJAX call status:   + (success ?  succeeded :  failed! ); },
          onFailure : function() { alert( Could not contact server ); },
          data :  img1=  + img1
     }).send();
}

在服务器上,有:

<?php

$img1 = mysql_real_escape_string($_POST[ img1 ]);
$idx=1;
$sql="INSERT INTO games SET img1= $img1  WHERE id=$idx";  
$result=mysql_query($sql);

echo (($result !== FALSE) ? 1 : 0);

你可能希望比这更加复杂,但这是非洲复兴开发银行申请的基础。 一些客户要求填写的单册,以及处理这些要求并按需要归还任何数据/软件的服务器的文字。

问题回答

Don t知道,你是否完全反对使用某种形式,或者不知道如何隐藏这种形式。

你可以制造一种隐蔽的形式,以 but子的点击来提交胎儿。

<form name="hidden-form" action="youraction.php" method="post">
<input type="hidden" name="submitme" value="I get submitted">
<input type="hidden" name="submitmetoo" value="I get submitted">
<input type="hidden" name="submitmeaswell" value="I get submitted">
<input type="hidden" name="dontleavemeout" value="I get submitted">
<input name="submit" type="submit" value="SUBMIT" />
</form>

然而,任何看着你的html的人都会看到这一点。

I guess this is what you looking for. this will only work if your html and php are on the same file...

<html>
<head>
</head>

<body>
<input type= text  id= user  placeholder= user >
</body>
</html>


<?php
$val = "
<script>
document.write(document.querySelector( #user ).value);
</script>
";
echo $val;
?>




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签