我希望有一个Php脚本允许我从另一个文件中的HTML替换变量。
<html>
<head>
<title>insertion de données en PHP :: partie 1</title>
</head>
<body>
<table border="0" align="center" cellspacing="2" cellpadding="2">
<tr align="center">
<td>nom</td>
<td><input type="text" name="number"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>
这是我的HTML表单,我只想在单击“确定”时,“数字”字段值将是我的变量$ Number = 30;
的新值,该值位于另一个文件conf.php中
你知道我怎么做吗?
答案 0 :(得分:1)
将此添加到您的html
<form method="get" action="conf.php" enctype="multipart/form-data">
conf.php
$number= $_GET['number'];
答案 1 :(得分:1)
在原始文件中:
<html>
<head>
<title>insertion de données en PHP :: partie 1</title>
</head>
<body>
<form method="post" action="conf.php">
<table border="0" align="center" cellspacing="2" cellpadding="2">
<tr align="center">
<td>nom</td>
<td><input type="text" name="number"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>insertion de données en PHP :: partie 1</title>
</head>
<body>
<form method="post" action="conf.php">
<table border="0" align="center" cellspacing="2" cellpadding="2">
<tr align="center">
<td>nom</td>
<td><input type="text" name="number"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>
然后,在'conf.php'中你会有一行:
答案 2 :(得分:0)
<form action="/path/to/conf.php" method="post">
<table border="0" align="center" cellspacing="2" cellpadding="2">
<tr align="center">
<td>nom</td>
<td><input type="text" name="number"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
conf.php:
$number = $_POST['number'];
答案 3 :(得分:0)
<html>
<head>
</head>
<body>
<form action="conf.php" method="post">
<input type="text" id="number" name="number"/>
<input type="submit" />
</form>
</body>
</html>`
在conf.php页面
<?php
$Number = $_POST["number"];
echo($Number );
?>