Jump to content

[SOLVED] Header redirect to previous page


jdadwilson

Recommended Posts

The variable $_SERVER['HTTP_REFERER'] sets a cookie? What about the other $_SERVER variables?

No I am not talking about $_SERVER['HTTP_REFERER']

What I am telling is page1.php sets Cookie and page2.php reads to cookie to understand whats teh previous page.

I didn't understand what you told may be keep that code in my_code.php

and then include_once('my_code.php') in all the files

 

The trigger to the code is from an anchor element. Using the href or the onclick both require a script. I would much like to put the code into a function in an include file and have it triggered by the anchor onclick event but I don't see how this can happen.

 

Any ideas...

include.php

<?php //this file is included in every page
function myFunction() {
   global $var1, $var2
   //do something
}
?>

 

your script that you will include the file into

<?php
include ('include.php'); //include your include file

if (!isset($_POST['submit'])) { //if the form has been submitted
  if ($_REQUEST['action'] == 'dosomething') { //if the form is asking to do something
    $dosomething = $_REQUEST['action']; //define the variable to be sent to the function
    myFunction($dosomething); //send your variable to your function to be done
  }
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.