当我点击某个按钮时,我试图让另一个页面出现,我基本上知道该怎么做,但这次我遇到了麻烦。我有以下代码:
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<!--See siin all tekstiväli-->
<H3>Minu küsitlused </H3>
<hr>
<br>
<br>
<br>
<ol>
<?php
include_once 'init/init.funcs.php';
$result = mysql_query('SELECT * from katse_kysimustik_pealkiri');
while($row = mysql_fetch_assoc($result)) {
$titles[] = $row['pealkiri'];
}
foreach($titles as $title) {
?>
<li>
<?php echo $title ?>
<form action='Minu_kysitlused_1.php'>
<input type="button" name = "saada" value="saada">
<input type="button" value="tulemused">
<input type="button" value="lõpeta ennetähtaegselt">
<input type="button" value="X">
</li>
</form>
<?php
}
?>
</ol>
</body>
</html>
<?php
if(isset($_POST['saada'])){
echo "<meta http-equiv='refresh' content='0;url=http://localhost/Praks/saada.html'>";
}
?>
一切都很好但是当我点击按钮'saada'时没有任何反应。我该怎么做才能让saada.html出现在这次点击上?
答案 0 :(得分:1)
替换这个:
<form action='Minu_kysitlused_1.php' method="post">
缺失:
method="post"
答案 1 :(得分:0)
试试这样 头函数必须是第一个发送为HTML的东西,否则它将无法正常工作
<?php
if(isset($_POST['saada'])){
header( "Location : localhost/Praks/saada.html");
die();
}
?>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<!--See siin all tekstiväli-->
<H3>Minu küsitlused </H3>
<hr>
<br>
<br>
<br>
<ol>
<?php
include_once 'init/init.funcs.php';
$result = mysql_query('SELECT * from katse_kysimustik_pealkiri');
while($row = mysql_fetch_assoc($result)) {
$titles[] = $row['pealkiri'];
}
foreach($titles as $title) {
?>
<li>
<?php echo $title ?>
<form action='Minu_kysitlused_1.php'>
<input type="button" name = "saada" value="saada">
<input type="button" value="tulemused">
<input type="button" value="lõpeta ennetähtaegselt">
<input type="button" value="X">
</li>
</form>
<?php
}
?>
</ol>
</body>
</html>
第二种方法
<form action="your-url">
<input type="submit" name="Submit" value="saada"/>
</form>
答案 2 :(得分:0)
为什么尝试使用meta标记 你只需要标题(&#34; location:yourpagename&#34;);
就像下面的
if(isset($_POST['saada'])){
header("Location:http://localhost/Praks/saada.html");
}
答案 3 :(得分:0)
第一次,如果没有通过POST传递的数据,我不明白你为什么要使用表单标签来调用页面?
无论如何,在您的foreach cicle中,您可以使用一个非常简单的链接集合:
foreach($titles as $title) {
echo $title;
echo '<a href="page1.php">Link 1</a>';
echo '<a href="page2.php">Link 2</a>';
echo '<a href="page3.php">Link 3</a>';
echo '<a href="page4.php">Link 4</a>';
}
此解决方案太干净了。 再见 马可