I'm just trying to get this simple php file to work:
<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>
Also, I can't figure out how to call a specific function in a form.
<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>
I think you were trying to do following
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.