soad el-hayek
soad el-hayek

Reputation: 63

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=$GLOBALS["COMPNAME"]' > شاهد سيرتك الذاتية من هنا </a>

Upvotes: 1

Views: 441

Answers (3)

Dreaded semicolon
Dreaded semicolon

Reputation: 2294

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.

Upvotes: 0

Rikesh
Rikesh

Reputation: 26421

Try like this

<a href="compInfo2.php?CName=<?php echo $GLOBALS['COMPNAME'];?>"> شاهد سيرتك الذاتية من هنا </a>

Upvotes: 1

Ibu
Ibu

Reputation: 43810

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>

Upvotes: 3

Related Questions