Jump to content

[SOLVED] overwritten VAR - must be something silly


pstanbra

Recommended Posts

I pass a variable in a url as ?brick=1

At the next page I set the variable brickID as (I would hope, "1)

The page has a form posting to itself. When i get into this page - 1 is displayed on the page but if i

resubmit and post to self again - the 1 dissappears so i guess its overwriting the value - i dont get it.

Any ideas what ive done wrong

 

<?php

global $brickurl;

$brickurl = $_POST[on0];

if (!empty ($_GET["brick"]))

{$brickID = $_GET["brick"];}

 

 

?>

 

echo $brickID

 

wow thats some messy code, no offence or anything. try this:

 

<?php
$brickurl = $_POST['on0'];

if(!empty($_GET['brick'])){
$brickID = $_GET['brick'];
}

echo $brickID;
?>

 

not sure if that will fix your problem, because it may lie somewhere else. you may need to post more code.

here is my full code:

 

all you got to remember is a url passes a variable as ?brick=1

 

 

 

<?php 
global $brickurl;
global $txn;
$brickurl = $_POST[on0];

if (!empty($_GET['brick']))
{$brickID = $_GET['brick'];}

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>

<H2>add advert </H2>


<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  <p>

  <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</p>
  <p> </p>
  test;  <?php echo $brickID;echo $brickurl;?>
  
  <p> </p>
  <p>
    <label>website
    <input name="on0" type="text" value="http://" size="84" maxlength="84" />
    </label>
</p>
  <p> </p>
</form>
</body>
</html>

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.