Issue
I am trying to write an admin panel and I use 3 different PHP files: create.php, edit.php and remove.php.
Is there any way to merge all of them into one PHP file?
<?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');
?>
Solution
Here is a better idea. Make an index.php file which contains:
<?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.";
?>
So when you access the link for example: http://example.com/index.php?action=create this will include create.php file in the index.php etc..
Answered By - Sayed
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.