Jump to content

Redirect ,avoid sql query on refresh,header don't work


tycy

Recommended Posts

Ok first of all i have this code at the final of my insert and update code.

 

if (!mysql_query($sql,$conn))
  {
  die('Error: ' . mysql_error($conn));
  }
  else{
 header("Location: finalmsj.php?finalmsj=".$hiwu."");
}
mysql_close($conn);
}

In the finalmsj.php i have a part of a code.and the variables $hiwu and another 3 somewhere in page with the context.

if(isset($_GET['finalmsj'])){
$finalmsj = $_GET['finalmsj'];

So now how i can call the $hiwu variable thru GET,it's kind of tricki for me this $_GET and maybe now i can understand it.

 

I looking for the internet and i try something like this but doesn't work.Always the msj is from $hiwa variable even in the link i have something different and BTW. when the insert or update is done,the msj appear and the link look like this.

 

http://192.168.0.15:888/phone/adm/finalmsj.php?finalmsj=

 

it suppose to be 

 

http://192.168.0.15:888/phone/adm/finalmsj.php?finalmsj=hiwa or something after equal sign ( = )

 

if(isset($_GET['finalmsj'])){
$finalmsj = $_GET['finalmsj'];
  if($finalmsj = $hiwa){
echo $hiwa;
  }
  elseif($finalmsj = $hiwu){
echo $hiwu;
    }
  elseif($finalmsj = $aboutusa){
echo $aboutusa;
    }
elseif($finalmsj = $aboutusu){
echo $aboutusu;
    }
}

I know the above code is wrong but i can find something helpful.

 

Thx for any help.

 

First of all you're using the mysql extension which is deprecated so I'd look into changing to mysqli at a minimum. 

 

That said. Code aside, from what I read. $hiwu doesn't exist when you do the header redirect. 

 

When you do the redirect you need to pass through a value for finalmsj, then on the next page take action based off of that value. 

 

 

For example, set header to finalmsj.php?finalmsj=somedata

 

Then in finalmsj.php page have logic to detect if finalmsj is somedata do ...

 

Also your if statements are wrong. 

 if($finalmsj = $hiwa)

There you would be setting $finalmsj to $hiwa. When checking if a variable matches another you'd use two ==

if($finalmsj == $hiwa)

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.