Zumo de Vidrio
Zumo de Vidrio

Reputation: 2091

Execute php code before going to index.html

I want to create a link inside a php code to redirect to the index.html page, I am able to achieve that with the following line:

echo "<a href='index.html'>Main page</a>";

But I want to execute another php code which simply removes the content of a file before going back to the index page.

I can execute my php code as I did to go to the index, I mean:

    echo "<a href='clear_config.php'>Clear configuration</a>";

But I haven't been able to execute both instructions within a same click (first execute clear_config.php and then go to index.html).

How can I do it?

By using redirection within php code I can get the expected result, but I'm just curious about if it is possible to do it with href tags since clear_config.php is also used in another places where doesn't need to redirect to index.html

Upvotes: 0

Views: 434

Answers (1)

praveen_programmer
praveen_programmer

Reputation: 1062

You can use

header('Location: index.html');

In your clear_config_and_go_to_page.php to redirect to other location.

Upvotes: 1

Related Questions