i have a form in one page thet leads me to another page .

exemple:
when i want to delete a page in my cms , i am click on the icon that is leads me
to page called delete.php.

i want that when i click the icon the option will be in the same page as
for exemple: index.php=delete

how do i creating this option in the same page

Recommended Answers

All 3 Replies

A form can only have one action. If the form HTML is:

<form action="index.php?do=delete">

then that entire form must be processed by that action. (You can use some Javascript to circumvent that, but then it starts getting tricky.)

ok, but i want that Instead of having the delete.php
that i have all the delete file in my index.php file
and when i click the icon on the index file the function of delete from the data base
will be in the index .php insted of delete.php

Member Avatar for diafol

I strongly suggest you don't have this in the same file. Have your delete stuff in your delete page. Otherwise you end up placing the whole site into one page - not very good. Also, you can replay form submission on page refresh - again not good. So, always try to send your forms to other pages as opposed to the same one.

The usual approach is:

index.php (form) -> delete.php (do deletes) then header() -> index.php

However, you can use Ajax to do the server stuff and update your html without leaving the page (no refresh). Again this is a pretty common approach.

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.