troubleshooting Question

Transfering session variables and display block variables to a submit form

Avatar of Senyonjo
Senyonjo asked on
1 Comment1 Solution262 ViewsLast Modified:
I am trying to place session variables(username,cust_num,email) and a display block variable(sale_num) into a submit form.  The form is a link from the display block.  The intention is to be able to submit these form values into a user/buyer table. ie linking a user to a particular item.  Session on these pages are started already from a control panel(This last sentence is updated after Duvlun20080's comment)

This is how I am trying to do it, and so far it is not working.  Is this possible??  Can someone help please.
Do I have to build some kind of shopping cart?.

This is the sql file - that produces the display block
           $valid    = "yes";
         $username = "$username";
         $email    = "$email";
         $cust_num = "$cust_num";
         $sale_num = "$sale_num" ;
echo "p>Hello $username, you are x customer No. $cust_num. You are now logged in./p>";

      $db_name = "aaaa";
  $table_name1 = "bbbb";
  $table_name2 = "ssss";
   $connection = @mysql_connect("", "yyyy", "zzzz");
           $db = mysql_select_db($db_name, $connection);
$sql = "
select sales.sale_num,
from  $table_name1, $table_name2
where bbbb.username = ssss.username
$result = mysql_query($sql, $connection) or die("could not execute query");
while ($row = mysql_fetch_array($result))
       $sale_num      = $row['sale_num'];
       $first_name    = $row['first_name'];
       $last_name     = $row['last_name'];
$display_block .= "
strong>Sale Number:/strong>$sale_num..
strong>Contact    :/strong>$first_name,$last_name
a href=\"\">Make Form/a>
title>This is the display/title>
?php echo "$display_block"; ?>

This is the form that I would like to pick up the session and display block variables
$valid    = "yes";
$username = "$username";
$email    = "$email";
$cust_num = "$cust_num";
$sale_num = "$sale_num" ;
echo "p>Hello $username, you are customer No. $cust_num. You are now logged in./p>";
if ($submit)
if ((!$username))
  $error = "Sorry! All areas marked with  (*) must be filled!";
  $db_name    = "aaaa" ;
  $table_name = "ssss" ;

  $connection = mysql_connect("", "yyyy", "zzzz");
          $db = mysql_select_db("aaaa", $connection);
  $sale_num   = "$sale_num" ;       
         $sql = "INSERT INTO table> (
                                     VALUES (

  $result = mysql_query($sql);
  echo "strong>h2>Thank You! Your Item Number has been entered./h2>/strong>
  echo "strong>Sale Number    :/strong>$sale_num  
  echo "strong>Customer Number:/strong>$cust_num  
  echo "strong>Username       :/strong>$username  
  echo "strong>Email          :/strong>$email      
  echo "Strong>Offer Notes    :/strong>$notes      
h2>Insert Form/h2>
  form method="post" action="?php echo $PHP_SELF ?>">
            input type="hidden" name="offer_num"   value="?php echo $offer_num ?>">

Sale Number:input type="number" name="sale_num"    value="?php echo $sale_num  ?>">

Cust Number:input type="number" name="cust_num"    value="?php echo $cust_num  ?>">

Username   :input type="text"   name="username"    value="?php echo $username  ?>">
Email      :input type="text"   name="email"       value="?php echo $email     ?>">

Notes      :input type="text"   name="notes"       value="?php echo $notes     ?>">

            input type="Submit" name="submit"      value="Send Info">
      p>a href="../log2.php">Return to Menu/a>/td>
?php echo "$result"; ?>

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros