所以我有与此类似的PHP代码
<?php
//some code here
?>
<form>
<input />
</form>
根据此示例,我想获取输入的内容以在PHP中进一步使用和/或在所需的输入中插入来自PHP代码的一些变量,我该如何执行此操作?
答案 0 :(得分:1)
您可以从HTML表单将数据发布到php
<?php
// data is available in php POST array
var_dump($_POST);
// create a var to hold the post data
$sNameOfPostVar = "";
// if posted, set the var to the value of the posted content
if(isset($_POST['NameOfPostVar'])){
$sNameOfPostVar = $_POST['NameOfPostVar'];
}
?>
<!-- current action is blank to send to same page as php script -->
<form method='post' action=''>
<input name='NameOfPostVar' value='<?php echo $sNameOfPostVar;?>' />
</form>