Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    $_SESSION problem with html page

    i am working on a project that involves pulling variables from a mysql table, sticking them in a mysql_array, placing that said array into a $_SESSION, and then transferring said $_SESSION from one PHP page to another. The coding for this is as follows

    Page 1:

    [CODE]
    <?php
    $con = mysql_connect("localhost", "root", '');

    if (!$con)
    {
    die('Cannot make a connection');
    }


    mysql_select_db('yumbox_table', $con) or die('Cannot make a connection');
    session_start();
    ini_set('session.bug_compat_warn', 0);
    ini_set('session.bug_compat_42', 0);

    $_SESSION['user_name'] = $_POST['user_name'];
    $_SESSION['password'] = $_POST['password'];
    $user_name = mysql_real_escape_string($_POST['user_na…
    $password = mysql_real_escape_string($_POST['passwor…




    $data = mysql_query("SELECT * from users where user_name = '$user_name' AND password = '$password'") or die(mysql_error());

    $info = mysql_fetch_array($data);

    $count = mysql_numrows($data);

    if ($count==1)
    {
    if ($info['user_type']=('Support Staff'))
    {
    $support_data = mysql_query ("SELECT yumbox_customer_inquiry.customer_last_na… yumbox_customer_inquiry.customer_first_n… yumbox_customer_inquiry.customer_email, yumbox_customer_inquiry.problem_body, yumbox_customer_inquiry.problem_status, yumbox_customer_inquiry.problem_solution from yumbox_customer_inquiry, users where users.problem_id = yumbox_customer_inquiry.category_id");
    $support_pull = mysql_fetch_array($support_data) or die(mysql_error());

    while($support_pull = mysql_fetch_array($support_data))
    {
    if ($support_pull['problem_status'] = "unsolved")
    {
    echo "Customer Last Name: ". $support_pull['customer_last_name'];
    echo "<br/>";
    $_SESSION['customer_last_name']=$suppo…

    echo "Customer First Name: ". $support_pull['customer_first_name'];
    echo "<br/>";
    $_SESSION['customer_first_name']=$supp…

    echo "Customer E-Mail: ". $support_pull['customer_email'];
    echo "<br/>";
    $_SESSION['customer_email']=$support_p…

    echo "Description of Problem: ". $support_pull['problem_body'];
    echo "<br/>";
    $_SESSION['problem_body']=$support_pul…
    $_SESSION['problem_status']=$support_p…

    print( '<a href="respond.html">Click here to resolve this issue</a>' );

    }
    }

    }

    if ($info['user_type']='Customer')
    {
    $customer_data = mysql_query ("SELECT yumbox_customer_inquiry.customer_last_na… yumbox_customer_inquiry.customer_first_n… yumbox_customer_inquiry.customer_email, yumbox_customer_inquiry.problem_body, yumbox_customer_inquiry.problem_status, yumbox_customer_inquiry.problem_solution from yumbox_customer_inquiry, users where users.email = yumbox_customer_inquiry.customer_email")…
    $customer_pull = mysql_fetch_array($customer_data) or die(mysql_error());

    while($customer_pull = mysql_fetch_array($customer_data))
    {
    $problem_solv = 1;
    $problem_unsolv = 1;

    if ($customer_pull['problem_status'] = "unsolved")
    {
    echo "HERE IS AN UNSOLVED TICKET";
    echo $problem_num. ".";
    echo "Description of Problem: ". $customer_pull[problem_body];
    echo "<br/>";
    ++$problem_solv;
    }

    else
    {
    echo "HERE IS A RESOLVED TICKET:";
    echo $problem_unsolv. ".";
    echo "Description of Problem: ". $customer_pull[problem_body];
    echo "<br/>";
    echo "Given Solution: ". $customer_pull[problem_solution];
    ++$problem_unsolv;
    }
    }

    print( '<a href="front_page.html">To submit a new customer support entry, click here</a>' );
    }
    }
    else
    {
    echo ("I am sorry but this login is incorrect. Please try again");
    }












    mysql_close($con);
    ?>
    [CODE]

    Page 2:

    [CODE]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    session_start();

    echo "Response to Customer Inquiry";


    echo "Customer Last Name: ";
    echo "</br>";
    echo $_SESSION['customer_last_name'];
    echo "Customer First Name: ";
    echo "</br>";
    echo $_SESSION['customer_first_name'];
    echo "</br>";
    echo "Description of Problem: ";
    echo "</br>";
    echo $_SESSION['problem_body'];
    ?>
    [CODE]
    Instead of displaying the variables stored in the $_SESSION superglobal, it displays the code you stored in your php file. Could someone please help me figure out why it does this?

  • #2
    Regular Coder
    Join Date
    Apr 2011
    Posts
    286
    Thanks
    2
    Thanked 39 Times in 39 Posts
    Can you provide a sample of the problem output?

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Instead of displaying the variables stored in the $_SESSION superglobal, it displays the code you stored in your php file. Could someone please help me figure out why it does this?
    Are you using .htm or .hrml extensions to your files? To parse php code, you need to give a .php extension to the files Or add a line in server's configuration file to parse php code inside html files
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    magician1983 (05-10-2011)

  • #4
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you for. Your help!

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    @magician: Take a look at the link in my signature
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •