pstanbra Posted February 16, 2007 Share Posted February 16, 2007 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 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 16, 2007 Share Posted February 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
only one Posted February 16, 2007 Share Posted February 16, 2007 <?php $_GET['brick']; if($brick==NULL){ echo "error"; }else{ echo "$brick"; } ?> that what u want? Quote Link to comment Share on other sites More sharing options...
only one Posted February 16, 2007 Share Posted February 16, 2007 in you form action do you have action=page.php?brick=$brick ? Quote Link to comment Share on other sites More sharing options...
pstanbra Posted February 16, 2007 Author Share Posted February 16, 2007 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> Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 16, 2007 Share Posted February 16, 2007 try replaceing this: <?=$_SERVER['PHP_SELF']?> with this: <?=$_SERVER['REQUEST_URI]?> Quote Link to comment Share on other sites More sharing options...
pstanbra Posted February 16, 2007 Author Share Posted February 16, 2007 WOOAAAHH yea baby! that worked.. hmm so whats REQUEST_URI do Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 16, 2007 Share Posted February 16, 2007 'REQUEST_URI' The URI which was given in order to access this page; for instance, '/index.html'. from the php manual. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.