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.

 

Link to comment
Share on other sites

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)
Edited by MiWi
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.