[英]I can't get the html form to run a php script
我只是想让这个简单的php文件起作用:
<html>
<head>
<title>Aarons Editor</title>
</head>
<body>
<form action="index.php" method="get">
<select name="page">
<option value="default"> </option>
<option value="file">File</option>
</select>
<input type="submit">
</form>
<?php
if (page == $_GET['file']){
echo "<h1>File</h1>";
}
else {
echo "<h1>not file</h1>";
}
}
?>
</body>
</html>
另外,我不知道如何在表单中调用特定函数。
<html>
<head>
<title>Aarons Editor</title>
</head>
<body>
<form method="post">
<select name="page">
<option value="default"> </option>
<option value="file">File</option>
</select>
<input type="submit" name="gog">
</form>
<?php
if($_POST['gog']){
if ($_POST['page'] == 'file'){
echo "<h1>File</h1>";
}
else {
echo "<h1>not file</h1>";
}
}
?>
</body>
</html>
我认为您正在尝试追踪
<html>
<head>
<title>Aarons Editor</title>
</head>
<body>
<!-- method="get" makes a form write attributes to url
ie. ?page=file or ?page=default
-->
<form action="index.php" method="get">
<select name="page">
<option value="default"> </option>
<option value="file">File</option>
</select>
<input type="submit">
</form>
<?php
// this checks if there is a parameter ?page set in url
if (isset($_GET['page'])) {
// this assigns a <select> value to variable $page
$page = $_GET['page'];
// this checks if selected value was 'file'
if ($page === "file") {
echo '<h1>'.$page.'</h1>';
} else { // this is if not
echo '<h1>not file</h1>';
}
}
?>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.