I have a query that finds a name, and if a condition exists, it redirects them to one page, if another condition exists, it redirects them to another page...but I am losing the session variable...

I can't pass the variable in the header Location because the variable contains spaces...

so, they select their institution from start.php and then it goes to the below code

<?php
require_once('dbconn.php'); 
session_start();
$conn = db_connect();
  	if (!$conn)
    	return 'Could not connect to database server - please try later.';
$institutionname = $_POST["institutionname"];
$query_payment = "SELECT paidflag, institutionname FROM test_tbl WHERE institutionname = '$institutionname'";
$institutionpayment = mysql_query($query_payment) or die("Problem with the query: $query_payment<br>" . mysql_error());
$row = mysql_fetch_array($institutionpayment);
if (isset($row['paidflag']) && $row['paidflag']=="0") {
header ("Location: https://mysite.com/membership06/memberaffiliateapp.php");
exit;
}
if (isset($row['paidflag']) && $row['paidflag']=="1") {
header ("Location: https://mysite.com/membership06/unpaid.php");
exit;
}
?>

in memberaffiliateapp.php I have
session_start();
$institutionname = $_POST["institutionname"];

it does pass the variable using
https://mysite.com/membership06/memberaffiliateapp.php?institutionname=".$row['institutionname']."");

but, of course with spaces in instututionname I get
U%20of%20Me instead of U of Me

I can't use the primary key as the variable passed as there could be 12 institutions with the same name. I possibly could select distinct and use the primary key...or create a new table of just institutions with no institution repeating...but there has to be a way to pass the variable? I am babbling and trying new things as I type and am getting no where.

Any thoughts are appreciated from the masses here. Coding is not my forte...

    Thanks, that worked like a charm...

      When you set a SESSION variable there is no need to pass it with an URL it is in the $SESSION array as long as the user is logged in, all you have to do to retrieve it is do a session_start() on the page where you want to use it
      Here are scripts to prove that a session variable can have a space (many of them.
      first.php

      <?php
      session_start();
      //Thisis a session veriable that will be available anywhere I want it
      $_SESSION['test']='Here I am a session variable value!';
      //now lets go to another page namedpage2.php
      header("Location: page2.php");
      ?> 

      page2.php

      <?php
      session_start(); 
      echo "This is the page2.php page and we will now show the value of the \$_SESSION['test'] variable.<br />";
      echo "<hr /><b>{$_SESSION['test']}</b> well there it is now lets go to page three with a link.<a href='page3.php'>Page3 </a>";
      ?> 

      page3.php

      <?php 
      session_start();
      echo $_SESSION['test'];
      echo"<br />As you can see the variable is always available as long as you use session_start()";
      ?> 
        11 days later

        okay, so how do I get those session variables to echo in forms

        ie the usual way I have done it was in form 1, the first part of the form, goes to form2.php and form2.php has:

        $institutionname = $_POST["institutionname"];

        and I can echo it in more forms, call up info from the database, etc. but can't find a way to do it with $_SESSIONS

        <?php if (isset($_POST['institutionname'])) echo $_POST['institutionname']; ?>
          session_start();
          $institutionname = $_SESSION['institutionname'];

          Make sure you call [man]session_start/man on every page that you're attempting to access the session data on.

          If session values aren't being retained, show us the "sessions" table in a phpinfo() output. Another thing you can do to try and debug is make sure that the same session id is being used on the first and subsequent pages by doing this:

          session_start();
          echo 'DEBUG: Session id = ' . session_id();
            6 days later

            I am definately doing something wrong with the sessions. I can't even echo them.

            here is start.php

            <?php session_start();
            require_once('mysql_connect.php');
            $query_member4 = "SELECT DISTINCT institutionname FROM users_tbl ORDER BY institutionname ASC";
            $member4 = mysql_query($query_member4) or die(mysql_error());
            $row_member4 = mysql_fetch_assoc($member4);
            ?>
            
            <form name="formcheckpayment" method="post" action="memberaffiliateapp.php">
                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td><table width="100%" border="0" align="left" cellpadding="4" cellspacing="0" bordercolor="#666666" class="bodytext">
                                      <tr class="bodytextbold">
                                        <td colspan="4" class="header">Previous Member
                                          Institutions</td>
                                      </tr>
            						  <tr>
                                        <td width="5%"></td>
                                        <td width="89%"><strong>Institution</strong></td>
                                        <td width="6%">&nbsp;</td>
                                      </tr>
                                      <?php do { ?>
                                      <tr>
                                        <td><input type="radio" name="institutionname" value="<?php echo $row_member4['institutionname']; ?>"></td>
                                        <td><?php echo $row_member4['institutionname']; ?></td>
                                      </tr>
                                      <?php } while ($row_member4 = mysql_fetch_assoc($member4)); ?>
                                    </table>
                                  </td>
                                </tr>
                                <tr>
                                  <td><input type="submit" name="Submit" value="Continue Membership"></td>
                                </tr>
                                <tr>
                                  <td>&nbsp;</td>
                                </tr>
                              </table>
                            </form>
            

            Then to memberaffiliateapp.php where all I am trying to do is echo the session

            <?php 
            session_start();
            $institutionname = $_SESSION['institutionname'];
            echo $_SESSION['institutionname']; 
            echo"<br />nothing is above this line"; 
            ?

              You will still need to use $_POST[] to get the information from the POSTed form.

              Once you have it, however, you can store it in $SESSION to make it available on subsequent pages without needing to shuttle it back and forth between the server and the client. So in that first code same you posted you would (just prior to redirecting to memberaffiliate.php) have a line to the effect that

              $_SESSION['institutionname']=$_POST['institutionname'];
                Write a Reply...