I administrate a database with 3 main tables for a training company: course providers, lecturers and graduates.
I have to create a database admininstration page with insertion, modification and search features. I am using php with mysql.
I wanted everything to happen in the index.php (do not know if this is the best sollution) and created a couple of variables to determine the content display in the admin page. After clicking the "providers insertion page" it sets via GET insertion type to 0 (0-providers, 1-lecturers, 2-graduates) and then the user is given a form where he should write the number of entries he wants to insert, set via POST the insertion_count variable.
After this the user enters the information, submits, I set the variable "inserted" to 1 via input type="hidden", post. The next step is verification, the inserted data is fetched from the sql and the user is given the possibility to modify any entry. If it clicks on the modify button, it sends via hidden post the "modify_id" variable (the id from the sql table of the entry to be modified) and is now given the ability to correct the errors. He can accept the changes for this and then for all the entries and gets back to the home page.

The problem with this is that I have a big number of if's and navigation between the code's acollades becomes difficult as the page grows.
I'd have something like:

if isset($_POST['insertion_type']){
if isset($_POST['insertion_count']){
if isset($_POST['inserted']){
if isset($_POST['modify_id']){
if isset($_POST['finish']){...
}
else ...
}
else ...
}
else ...
}
else ...
}

Is there a way to make this better?

Thank you

Hi,

Split it on each as each menu index.

i.e :
students.php?m=add
students.php is student area index and the file access is add.php

It works i hope

can you explain what does add.php do? if I include everything about students in students.php what is add.php needed for? or is add.php a collection of functions for all the "add" operations in the site and students.php contains all the conditions and calls to that?
or you meant only the variable that contains the type of modification?
thank you.

No. its not a variable. Its the page link.

students.php is the page of Students index Page, It shows default page for student.
if anyone click on add menu its url is (student.php?m=add).it shows add.php file instead of default page in students.php

thanks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.