View Full Version : Cookie Problem Reposted
dawilis
12-21-2002, 09:36 PM
Please someone help here
I m trying to get an order page to save details in a cookie then repopulate a form on the next page, however the cookie needs the get method and the form needs the post method, I know Ive posted theis recently but I got no responses, I actually only need the invoice number ,name and email to be remembered .
Any one help
http://www.instantmoneymaker.com.au/orderdetails.html
http://www.instantmoneymaker.com.au/payment.html
krycek
12-21-2002, 11:25 PM
Just look here
http://www.codingforums.com/showthread.php?s=&threadid=11585
::] krycek [::
requestcode
12-22-2002, 12:39 AM
Could you not pass the info through the URL? Here is a link to a tutorial on how to do it:
http://www.javascriptkit.com/javatutors/send1.shtml
Philip M
12-22-2002, 08:38 AM
You say that the cookie needs the GET method and the form
needs the POST method. So what? There is no conflict there.
dawilis
12-22-2002, 11:01 PM
Are you suggesting that I can have the method="post&get"in the form tag?
what is the syntax for this?
krycek
12-22-2002, 11:59 PM
heheh :)
There are two methods of sending variables from a webpage: POST and GET.
GET refers to variables sent in the URL; for instance:
mypage.php?myvar=hello
POST refers to variables sent in the page headers. These cannot be seen in the URL, however they are available to server-side scripts, just the same as GET variables.
You can tell forms to use either method, however be aware that only using GET will JavaScript be able to access the variables on its own. Otherwise you will need a server-side script to process the POST variables first.
To use POST:
<form id="add" method="post" action="add.php">
To use GET:
<form id="add" method="get" action="add.php">
(Or else you can manually add variables to the URL, if you do not want to use a form. But only by using a form can you send POST variables from the client.)
I hope that cleans things up a bit :)
::] krycek [::
dawilis
12-23-2002, 12:19 AM
and there upon lies the problem.
Its this bloody formmail.pl thats giving me the problems, at every turn its blocking my efforts.
Ill I want to do is have a user details form filled in, generate a invoivce number and email the results to me, then continue on to another page where I can send some info to the credit card company for procesing.
I have it all just the sending info to another page
Formail requires POST method, ok so I thought cookies Uhohh mothod="get" (formmail needs POST) again, ok so I uesd the above code to send via url,
bloddy formmail again, uses a hidden redirect address that wont take the query string on the end of payment page.
Im completely lost and frustrated
krycek
12-23-2002, 12:56 AM
well, you lost me on the cookies bit. Cookies don't send their info by POST or GET... they are just cookies! :p
I don't use Perl very much so I don't know how Perl accesses such variables, however in PHP there is a separate array for POST variables, GET variables, and COOKIE variables.
So, using cookies is not the same as sending GET or POST info :)
::] krycek [::
dawilis
12-23-2002, 01:01 AM
The cookies worked perfectly with the method get set but failed with the post set.
I dont understand it, and thats the underlying problem I think
krycek
12-23-2002, 01:44 AM
how were you setting the cookies...?
client-side or server-side?
::] krycek [::
dawilis
12-23-2002, 01:52 AM
client side
<SCRIPT language=JavaScript type=text/javascript><!--
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
function setupForm() {
if (userProfile) getValues(userProfile);
}
function getValues(string) {
getValue(string,"user", document.profileForm.user, "text");
getValue(string,"email", document.profileForm.email, "text");
getValue(string,"country",document.profileForm.country,"select");
getValue(string,"age", document.profileForm.age, "select");
getValue(string,"sex", document.profileForm.sex, "radio");
for (var i=0;i<7+1;i++)
getValue(string,"i"+i, eval("document.profileForm.i"+i), "checkbox");
}
function replace(string,text,by) {
// Replaces text with by in string
var i = string.indexOf(text);
var newstr = '';
if ((!i) || (i == -1)) return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}
krycek
12-23-2002, 02:02 AM
ok, I think I see where you are going wrong.
I think you need to decide exactly what you want to accomplish, before I try to help you out with code.
...you are using Perl on the server, you say? But what is it doing?
Something like this is perhaps what you need to be thinking about:
- client enters details
- details sent via form (using POST) to server
- Perl processes details from POST variables
what happens from there depends on what you need. I don't see why you HAVE to use cookies, or even why you need to use GET at all, and parse the URL. If you are using Perl then you can handle it all through there.
For instance, use Perl to write appropriate JavaScript variables to the page. Or something similar. Or else if that is not suitable, get Perl to store info in a cookie, and then access it with JavaScript.
Bottom line: You can get and set cookie info with JavaScript and Perl, and so they can share details. So, why is there a need for URL parsing etc.?
Think through your dataflow, and give me the lowdown, and I will try to help you work out the best way to accomplish this.
Oh yeah one last thing, do you have PHP available to use? If you do, you may find it more suitable for you than Perl. :)
::] krycek [::
dawilis
12-23-2002, 02:15 AM
Ohh I wish I could use php or asp!! but thats not an option.
generate invoive number (can do)
display form details page(can do)
Client enters (data for invoiceing and delivery)
email form values to owner then goto payment screen
display invoice number (variable) and price (constant) from details page
(Credit card company requires data to be sent via url, they need invoice number and price)
to specific address
how does this sound
dawilis
01-01-2003, 04:55 AM
Hi krycek a quick reminder on this topic, Im still needi g a hand if you have a spare minuit
Regards
daryl
whammy
01-01-2003, 05:16 AM
Ok... from what I understand (although I'm very unclear on this) you have no server-side access at all, and if I'm not mistaken, the only server-side processing is done by a Perl Formmail script you are posting to, which sends an email?
I'm quite a bit lost on your flow, and where server-side processing and client-side processing takes place...
Can you explain step-by-step exactly what you're doing, yet again? I know it's frustrating, but in order to help, we need to know a few things:
1. Do you have any server-side capabilities at all on your server?
2. What exactly are you posting to the Perl script, and what is the formmail script doing - just emailing you the form contents?
3. What information do you get back from the formmail script, if that is the case?
4. What information does the CC processing company need, and how do they need to receive this info?
Regarding step 4, if you're processing credit cards using client-side scripting at all, that's not a good idea... I for one wouldn't even think about putting credit card information on a website that doesn't use SSL, nor would anyone who is familiar with buying things online...
If this IS the case, your best bet would be to get a host (at least for this portion of your site) that supports SSL and server-side scripting (i.e. PHP, ASP, etc.), so you can do things right.
dawilis
01-01-2003, 05:39 AM
The formmail sends the mail and then redirects to the next page,
however at the moment I have turned the redirect off and inserted another button in to go to the next page, using the Url to send the info as someone in this thread suggested, but it looks a bit rough having to press to buttons
http://www.instantmoneymaker.com.au/orderdetails.html
dawilis
01-01-2003, 06:50 AM
Hey whammy I recieved 23 emails from you with this address
robasdf@bellview.com or similar, as I stated in post above I disabled the redirect in formmail because I could not get the cookie part working, also on the form next to the process button it says click here then click payment ( you must have missed it )
and it looks bad I know thats why Id like to get the cookie thing working well.
its basically set out like this
I generate a invoice Number
the user fills in the form (with validation)
I want the invoice number and user email and name saved in a cookie
on payment page I want to display these bits of info and send them of to a credit card company for collecion of money via URL
Hope you can help
daryl
whammy
01-01-2003, 05:08 PM
Oops, sorry about the emails, it appears your form was working, although not readily apparent.
First off, I'd just look up some cookie scripts - for instance
http://www.geocities.com/docwright32nd/sessioncookie.htm
or search the forums for one.
Cookies have nothing to do with "get" or "post", so they shouldn't cause any problems with your form.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.