如何合并 create.php、remove.php、edit.php
How to merge create.php, remove.php, edit.php
我正在尝试编写一个管理面板,我使用了 3 个不同的 PHP 文件:create.php
、edit.php
和 remove.php
。
有什么办法可以将它们全部合并到一个 PHP 文件中吗?
<?php
include 'connection.php';
$id = $_POST['id'];
$soru = $_POST['soru'];
$cevap = $_POST['cevap'];
if (!$_POST['submit'] ) {
echo "Please fill out the form";
} else {
mysql_query("INSERT INTO sss (soru,cevap,ID) VALUES ('$soru','$cevap','$id') ") or die(mysql_error());
header('Location:admin.php');
}
?>
<?php
include 'connection.php';
$id = $_POST['id'];
$soru = $_POST['soru'];
$cevap = $_POST['cevap'];
if (!$_POST['submitSoru'] ) {
echo "Please fill out the form";
} else {
mysql_query("UPDATE sss SET soru = '$soru' , cevap = '$cevap' WHERE ID = '$id' ") or die(mysql_error());
header('Location:admin.php');
?>
这是一个更好的主意。创建一个 index.php
文件,其中包含:
<?php
$action = $_GET['action'];
if ($action == 'create') {
include('create.php');
} elseif ($action == 'remove') {
include('remove.php');
} elseif ($action == 'edit') {
include('edit.php');
} else
echo "This page does not exist.";
?>
因此,当您访问 link 时,例如:http://example.com/index.php?action=create
这将在 index.php
等中包含 create.php
文件。
我正在尝试编写一个管理面板,我使用了 3 个不同的 PHP 文件:create.php
、edit.php
和 remove.php
。
有什么办法可以将它们全部合并到一个 PHP 文件中吗?
<?php
include 'connection.php';
$id = $_POST['id'];
$soru = $_POST['soru'];
$cevap = $_POST['cevap'];
if (!$_POST['submit'] ) {
echo "Please fill out the form";
} else {
mysql_query("INSERT INTO sss (soru,cevap,ID) VALUES ('$soru','$cevap','$id') ") or die(mysql_error());
header('Location:admin.php');
}
?>
<?php
include 'connection.php';
$id = $_POST['id'];
$soru = $_POST['soru'];
$cevap = $_POST['cevap'];
if (!$_POST['submitSoru'] ) {
echo "Please fill out the form";
} else {
mysql_query("UPDATE sss SET soru = '$soru' , cevap = '$cevap' WHERE ID = '$id' ") or die(mysql_error());
header('Location:admin.php');
?>
这是一个更好的主意。创建一个 index.php
文件,其中包含:
<?php
$action = $_GET['action'];
if ($action == 'create') {
include('create.php');
} elseif ($action == 'remove') {
include('remove.php');
} elseif ($action == 'edit') {
include('edit.php');
} else
echo "This page does not exist.";
?>
因此,当您访问 link 时,例如:http://example.com/index.php?action=create
这将在 index.php
等中包含 create.php
文件。