Hi, I am trying to build a shopping cart for my DVD website and am having
trouble reading variable over different pages.
I have a page that allows the user to add things to their cart and this page
also display what they have selected. I also am trying to build a 'checkout'
page that displays the DVDs they have chosen, the cost and allows them to
remove a DVD from their cart.
However, I can't even get the checkout page to display the list of DVDs that
is displayed on the other page. Globals variables have been turned off on
the server I am using.
Any help with this would be great.
Here is the code I was referring to:
<?php
// this section creates a session, connects to the db and handles the two
buttons being pressed.
session_start() ;
session_registe r("trolley");
require ('mysql.php');
mysql_connect ($host, $user, $passwd);
mysql_select_db ($dbName);
if (isset ($_GET['add']))
$_SESSION['trolley'][] = $_GET['add'];
else if ($_GET['op'] === 'clear')
$_SESSION['trolley'] = "";
$_GET['getdvds_query'];
$_GET['search_text'];
$_GET['search_in'];
$_GET['genrename'];
?>
<html>
<head>
<title>PHP & MySQL</title>
</head>
<table>
<?php
if ($search_in == "title") {
$getdvds_query = mysql_query ("SELECT dvdid, title, duration, rel, descr,
genre, stock, price FROM dvd where title LIKE '%$search_text% '");
}
else if ($search_in == "director") {
$getdvds_query = mysql_query ("select dvd.dvdid, dvd.title, dvd.duration,
dvd.rel, dvd.descr, dvd.genre, dvd.stock, dvd.price from dvd, director where
director.name like '%$search_text% '");
}
else if ($search_in == "actor") {
$getdvds_query = mysql_query ("select dvd.dvdid, dvd.title, dvd.duration,
dvd.rel, dvd.descr, dvd.genre, dvd.stock, dvd.price from dvd, actordvd,
actor where actor.actorid = actordvd.actori d and actordvd.dvdid = dvd.dvdid
and actor.name like '%$search_text% '");
}
else
$getdvds_query = mysql_query ("SELECT dvdid, title, duration, rel, descr, ge
nre, stock, price FROM dvd where genre LIKE '%$genrename%'" );
if(!$getdvds_qu ery) {
die("No result, error: ".mysql_error() );
}
echo "<table bgcolor=\"ddeef f\"><thead><tr> ";
for ( $i = 1 ; $i < mysql_num_field s($getdvds_quer y) ; $i++ ) {
echo "<th bgcolor=\"abcde f\">" .
mysql_field_nam e($getdvds_quer y,$i) . "</th>\n";
}
if ( mysql_num_rows( $getdvds_query) > 0 )
{
while ( $row = mysql_fetch_ass oc($getdvds_que ry) )
{
$dvd[$row['dvdid']] = $row;
echo "<tr>\n";
echo "<td>{$row['title']}</td>\n";
echo "<td>{$row['duration']}</td>\n";
echo "<td>{$row['rel']}</td>\n";
echo "<td>{$row['descr']}</td>\n";
echo "<td>{$row['genre']}</td>\n";
echo "<td>{$row['stock']}</td>\n";
echo "<td>{$row['price']}</td>\n";
echo "<td><a
href=\"start.ph p?main=search&a dd={$row[dvdid]}\">add to basket</a></td>";
echo "</tr>\n";
}
}
?>
</table>
<a href="start.php ?main=search&op =clear">empty trolley</a><br /><br />
<a href="start.php ?main=checkout& trolley<?=SID?> ">Checkout</a><br /><br />
<?php
//this section outputs basket contents
if (!empty ($_SESSION['trolley']))
{
echo 'Trolley contents:<br />';
foreach ($_SESSION['trolley'] as $trolley_item)
echo $dvd[$trolley_item]['title']."<br />";
}
else
echo 'Trolley is empty!';
?>
</body>
</html>
Here is my checkout page:
<?php
// this section creates a session, connects to the db and handles the two
buttons being pressed.
session_start() ;
session_registe r("trolley");
session_registe r("add");
require ('mysql.php');
mysql_connect ($host, $user, $passwd);
mysql_select_db ($dbName);
$_SESSION['trolley'];
if (!empty ($_SESSION['trolley']))
{
echo 'Trolley contents:<br />';
echo "<table bgcolor=\"ddeef f\"><thead><tr> ";
foreach ($_SESSION['trolley'] as $trolley_item)
echo "<tr>\n";
echo $dvd[$trolley_item]['title']."<br />";
echo $dvd[$trolley_item]['price']."<br />";
echo "</tr>\n";
}
else
{
echo 'Trolley is empty!';
}
?> 2 2580
James wrote:
(snip) Any help with this would be great.
Here is the code I was referring to:
<?php
// make PHP report the use of unintialized variables
error_reporting (E_ALL);
ini_set('displa y_errors', '1'); // this section creates a session, connects to the db and handles the two buttons being pressed. session_start() ; session_registe r("trolley");
http://www.php.net/session_register
Caution: If your script uses session_registe r() it will not work in
environments where the PHP directive *register_globa ls* is disabled.
(snip)</table> <a href="start.php ?main=search&op =clear">empty trolley</a><br /><br /> <a href="start.php ?main=checkout& trolley<?=SID?> ">Checkout</a><br /><br />
_______________ _______________ ___^^^^^^^^^^^^ ^^^^
Something like "&trolleyfedcba 9876543210fedcb a9876543210" ?
Are you perhaps missing a '=' after "trolley" ?
(snip)
You have quite a few statements without effect throughout your code:
<?php
$_GET['id']; // statement without effect
// AFAICT this does absolutely nothing
?>
--
USENET would be a better place if everybody read: : mail address : http://www.catb.org/~esr/faqs/smart-questions.html : is valid for : http://www.netmeister.org/news/learn2quote2.html : "text/plain" : http://www.expita.com/nomime.html : to 10K bytes :
Pedro, thanks for your advice. It's a bit late now but I'll work on the code
some more tomorrow. If anyone else has any more help I would be very
grateful. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James |
last post by:
Hi, I am trying to build a shopping cart for my DVD website and am having
trouble reading variable over different pages.
I have a page that allows the user to add things to their cart and this page
also display what they have selected. I also am trying to build a 'checkout'
page that displays the DVDs they have chosen, the cost and allows them to
remove a DVD from their cart.
However, I can't even get the checkout page to display the...
|
by: Larry Woods |
last post by:
I am losing Session variables, but only those that are set in the page
previous to a redirect to a secure page.
Anyone seen ANY situation where Session variables just "disappear?"
Note that OTHER session variables are still intact !?!
TIA,
Larry Woods
|
by: Earl Teigrob |
last post by:
I am programming ASP.NET using C#.
I have been accessing static variables accross my entire application but now
need to change some of the static variables that are session specific to
instance variables.
(For more background, see previous post about 30 min ago)
It was so cool using static variables because they where global to the
entire application so I could calculate them when the page loaded and use
then anywhere in the app. Now...
|
by: Salek Talangi |
last post by:
Hello,
I have following (probably very basic) problem:
I made a html-frameset in VS.net, where the frames
itself are aspx-pages with webforms.
Now I want to access the webforms (eg. give a label a
text) from one .aspx.vb page.
I managed to get all the code into one file by writing
the same file in the codebehind statement of all aspx
files.
Now I have one big .aspx.vb file with:
|
by: Alex |
last post by:
I'm having a problem porting an ASP solution to ASPX.
In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and
call functions from VB script on the ASP pages.
The DCOM object handles are stored in session variables.
This works fine without a problem.
Ported it to ASPX, accessing the same DCOM server from code behind pages.
Still, usually no problems.
However sometimes I'm seeing an error stating that the DCOM handle...
| |
by: Nathan Sokalski |
last post by:
I would like to access variables and functions that I declare in the
Global.asax.vb file. However, I am having trouble doing that. What does the
declaration have to look like in the Global.asax.vb file, and what would I
do to access it? (I am using VB.NET for my code) Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
|
by: skeddy |
last post by:
In a nutshell, I'm trying to dynamically create a select box with
ResultSet code in vbscript and then need to be able to access the value
of that select box later with a Save button.
I've got the select box filling with code similar to below:
<SCRIPT LANGUAGE=VBSCRIPT RUNAT=SERVER>
Public Sub BuildComboBox(rs, dispname, val, name, selected)
'rs = the recordset
'val = fieldname to place in the val of the option
|
by: e_matthes |
last post by:
Hello,
I keep reading that $_SERVER can easily be faked. Is
that true of all server variables, or just some of them? In
particular, I'm wondering if server_port can be faked.
I'm interested right now because I want to detect whether the current
page request is using http or https. I realize there are other ways
to ensure the correct delivery of pages over https using directory
management and htaccess, but I also want to understand...
|
by: gom |
last post by:
I am an amatuer asp.net programmer so I hope this question isn't to dumb.
I am having difficulty with my understanding of session state. I have an
application that stores some values in the session and then I use the
following code to try and get a stream of image data. mypage.aspx has a
different session ID then the calling page. I tried to use a relative URI
but the getresponse said it couldn't use a relative uri. I've looked at...
|
by: brendan_gallagher_2001 |
last post by:
HI
I am developog an ASP.net site (using vb.net 1.1) which will be
accessed by a number of different office locations, where certain
users will be assigned a authoriser profile, and others will be
assigned a verifier profile. At least two authoriser, and multiple
verifiers exist per office.
I need to be able to prevent two users with the same profile, and from
the same office location, accessing the same page at the same time. I
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |