php pass variables between pages
I'm trying to send this varabile from one page to another but there is no value in it when I send it
I stored the value in compInfo.php
in compInfo2.php
<?php
if (isset($_POST['savebutton'])) {
$company = new copmany();
$copmnae = $_POST['CName'];
$COMPNAME = $copmnae;
?>
I dont know whats wrong
<a href='compInfo2.php?$copmnae=$GLO开发者_如何学运维BALS["COMPNAME"]' > شاهد سيرتك الذاتية من هنا </a>
I dont really understand the problem but this is suspicious :
<a href='compInfo2.php?$copmnae=$GLOBALS["COMPNAME"]' > شاهد سيرتك الذاتية من هنا </a>
should be
echo "<a href='compInfo2.php?CName={$COMPNAME}' > شاهد سيرتك الذاتية من هنا </a>";
or
<a href='compInfo2.php?CName=<?php echo $COMPNAME ?>' > شاهد سيرتك الذاتية من هنا </a>
Try like this
<a href="compInfo2.php?CName=<?php echo $GLOBALS['COMPNAME'];?>"> شاهد سيرتك الذاتية من هنا </a>
You also trying to send a $_GET data to the second file, then getting it there as a post data.
so if you want to keep it as get data, you should change $copmnae = $_POST['CName'];
to
$copmnae = $_GET['CName'];
beside converting compInfo2.php?$copmnae=$GLOBALS["COMPNAME"] to
compInfo2.php?CName=<?=$GLOBALS["COMPNAME"]?>
note the compnae name difference, because over in the second file you are getting the wrong name from the one you are sending.
精彩评论