Hi chaps,
I'm relatively new to the language, but I want to create a simple order
form using PHP and cookies. Please let me know if there's a better way
in this situation, database isn't availible.
What I'm trying to get is this:
1) Variable(A) passed from HTML page to script.
2) Script checks for cookie.
3) If no cookie, script creates one, Variable(A) the value.
4) If cookie, script adds Variable(A) value.
Then the script should produce an "order form" type page, listing the
variables within the cookie.
I'm new to PHP and I have no experience of cookies. I may be going about
this the wrong way, so please let me know!
Many thanks for any help,
- Daniel 3 5887
Tinkering with browser cookies directly is so...passe. Use PHP sessions
instead:
<?php
session_start() ;
if(is_array($_S ESSION['orders'])) {
$_SESSION['orders'] = array();
}
array_push($_SE SSION['orders'], $a); // from your form
?>
Uzytkownik "Daniel Ruscoe" <co*****@websit e.plz> napisal w wiadomosci
news:MP******** *************** *@news.btopenwo rld.com... Hi chaps,
I'm relatively new to the language, but I want to create a simple order form using PHP and cookies. Please let me know if there's a better way in this situation, database isn't availible.
What I'm trying to get is this:
1) Variable(A) passed from HTML page to script. 2) Script checks for cookie. 3) If no cookie, script creates one, Variable(A) the value. 4) If cookie, script adds Variable(A) value.
Then the script should produce an "order form" type page, listing the variables within the cookie.
I'm new to PHP and I have no experience of cookies. I may be going about this the wrong way, so please let me know!
Many thanks for any help,
- Daniel
Daniel Ruscoe wrote: Hi chaps,
I'm relatively new to the language, but I want to create a simple order form using PHP and cookies. Please let me know if there's a better way in this situation, database isn't availible.
What I'm trying to get is this:
1) Variable(A) passed from HTML page to script. 2) Script checks for cookie. 3) If no cookie, script creates one, Variable(A) the value. 4) If cookie, script adds Variable(A) value.
Then the script should produce an "order form" type page, listing the variables within the cookie.
Do you need a cookie? Do you need to know the value of the data beyond
the order form page? Could you send data straight to the order form page
using forms, and perhaps hidden form fields?
If you do need to keep the data for several pages, then using PHP
sessions may be useful. Sessions use a cookie to store a session key
that points to a set of session data on the PHP server (though make sure
to think about security of session variables and whether there's a risk
of the session keys being intercepted over open connections). See the
Session handling functions (chapter XCV) in the PHP user manual.
If you need to store the data on the user's machine for more than
several pages, e.g. for several hours, days, months, or years, then
cookies are the way. Again, make sure to think about security of data
being stored on the remote machine, and about transmitting the data over
open (non-encrypted) connections.
--
Bob
London, UK
echo Mail fefsensmrrjyahe eoceoq\! | tr "jefroq\!" "@obe.uk"
In article <lb************ ********@comcas t.com>, Chung Leong says... Tinkering with browser cookies directly is so...passe. Use PHP sessions instead:
<?php
session_start() ;
if(is_array($_S ESSION['orders'])) { $_SESSION['orders'] = array(); } array_push($_SE SSION['orders'], $a); // from your form
?>
Thanks for that, I'm beginning to get the basics now. I've looked up
sessions and I see how they work. Looks like the perfect solution.
I'm stuck trying to figure out how I would add multiple items to a
session.
Say I want a form on one page, when the submit button is clicked 4
variables are sent to a PHP script to be added to a session.
Then I'd need that script to list them in an order form style:
Title Title Title Title
Variable1(A) Variable1(B) Variable1(C) Variable1(D)
With the ability to add more sets of variables afterwards to give:
Title Title Title Title
Variable1(A) Variable1(B) Variable1(C) Variable1(D)
Variable2(A) Variable2(B) Variable2(C) Variable2(D)
Can anybody point a beginner in the way of some code?
Thank you.
- Dan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John |
last post by:
I am storing user names and addresses in cookies so that they do not
have to enter them in forms. But now if I try to send the form with
new data, the data in cookies is always called when I press the submit
button. The data that I have entered get deleted and the data in the
cookies is submitted. This also happens in scripts where I am not even
using cookies to set the forms. How do I solve this problem?
Thank you
John
|
by: Sam |
last post by:
I am trying to pinpoint down a random response.redirect
error message. "Object Moved To Here". I think it is due
to the following order in which I am assigning cookies
and redirecting:
1. I set the cookie - Response.Cookies("name").Values
("val") = ...
2. I redirect response.redirect("...")
Is this legal. The problem is 85% of the time it works so
I need somebody else's opinion.
|
by: SHarris |
last post by:
Hello,
In our new intranet ASP.NET project, two requirements are that the browser
accept cookies AND JavaScript. We are requiring the use of Internet
Explorer 6+.
1. Using C# in an ASP.NET application, how can we code the project to check
to make sure the browser accepts cookies?
2. Where would we put this code? In Global.asax?
3. Using C# in an ASP.NET application, how can we code the project to
detect and make sure the browser...
|
by: Luis Esteban Valencia Muñoz |
last post by:
I'm working on a web scraping application that needs to log into a website
before it can get the data to scrape. I've always been confused about how
the HttpWebRequest and HttpWebResponse objects work together with cookies,
and was hoping that someone here could clear it up for me!
Here's the steps I need to accomplish:
1) Set two cookies containing information I already have
2) Request the login page URL, and save a third cookie that...
|
by: Cheung, Jeffrey Jing-Yen |
last post by:
I have a windows form application that generates a request, downloads an image, and waits the user
to enter in login info. Unfortunately, this image is dynamic and based on session data. I have
read documents on the CookieCollection property of HttpWebRequest. Currently, I have the
functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest;
however, upon further inspection of the returning...
| |
by: Paul |
last post by:
Here is a question that should get everyone going.
I have an ecommerce site where I need to pass the order_id to every page. So
which method is the best practice to pass this variable between pages:
Cookies or Session variable or by the HTTP header (either GET querystring or
POST form)?
I do not like to use sessions because they time out after 20 minutes of
inactivity.
|
by: Esa |
last post by:
Hi,
I'm having problems with one strange web system where submitting an
application and making queries about its handling status require a series of
form submits and response parsing - all in HTML. Luckily other interfaces
are "modern" using xml file up/downloads without any difficulties...
I'm not very used to .NET-environment yet, so I'd appreciate some clues
about the classes I should use to implement this stupid interface - stupid...
|
by: Immortalist |
last post by:
Various aquisition devices that guide learning along particular
pathways towards human biases. And as E.O. Wilson might say mental
development appears to be genetically constrained.
(1) Language Aquisition Device
(2) Color Aqusition Device
(3) Sound Aquistion Device
(4) Smell Aquisition Device
(5) Touch Aquisition Device
(6) Art Aquisition Device
|
by: bhavin30 |
last post by:
Is there a way to obtain user information (using LOGON_USER server
variables) when you have set up the security to Anonymous Access? I
have tried setting the security to both Anonymous + Window Integrated,
without any luck. I'm using IIS 6.0 on Windows Server 2003
Thanks in advance!
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |