Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-10-2011, 05:45 AM   PM User | #1
magician1983
New Coder

 
Join Date: May 2011
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
magician1983 is an unknown quantity at this point
$_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?
magician1983 is offline   Reply With Quote
Old 05-10-2011, 09:15 AM   PM User | #2
Wojjie
Regular Coder

 
Join Date: Apr 2011
Posts: 286
Thanks: 2
Thanked 39 Times in 39 Posts
Wojjie is on a distinguished road
Can you provide a sample of the problem output?
Wojjie is offline   Reply With Quote
Old 05-10-2011, 09:41 AM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
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
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
magician1983 (05-10-2011)
Old 05-10-2011, 12:55 PM   PM User | #4
magician1983
New Coder

 
Join Date: May 2011
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
magician1983 is an unknown quantity at this point
Thank you for. Your help!
magician1983 is offline   Reply With Quote
Old 05-10-2011, 01:03 PM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,665
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
@magician: Take a look at the link in my signature
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Tags
embed, html, mysql, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:41 AM.


Advertisement
Log in to turn off these ads.