Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 27th, 2004, 07:00 AM
Authorized User
 
Join Date: Mar 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default cookies

hi alllz,

i wanna ask how can i retrieve user name on the value of the text box, on another words when someone log into hotmail to access his mail box and after he logged out and wanna login again he will automaticlly find his or here name on the text box of user name.

so how i can do that ????

thanx in advance.

afradoit

 
Old March 29th, 2004, 10:16 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default

Hi

Have a look at the code below I got of the net. I have added a text box which will by default disdplay the contents of the cookie if it already exists. Sure this will get u started

<% response.buffer=true
' response.buffer=true is used to because there is a mix
' of html output and response.cookies when the cookie is written
%>
<html>
<title></title>
<body bgcolor="#FFFFFF">
<%
u_input=request.cookies ("testcookie")("u_input")
'checks for the variable u_input from a cookie named testcookie on
' the local pc.
' If the cookie does not exist or have a value for the variable
' then check to see if the user is inputting one
if trim(u_input) = "" then
u_input=trim(request.form("u_input"))
' If the user hase enetered a value to put to the cookie write it out
if u_input <> "" then
' Write the user input to the cookie
response.cookies ("testcookie")("u_input") = u_input
' Write the expiration date (today + 3 days) to the cookie
response.cookies ("testcookie").expires = DATE + 3
' Read the cookie and write the value of u_input to the browser
response.write (request.cookies ("testcookie")("u_input")) %>
<p>
You text has been written to the cookie.<br>
Click <a href="<%= request.servervariables("script_name") %>" target="_blank">here</a>
to open this page in a new window.
<% else
' If there was no cookie info and there was no value being inputted
' then display the textbox for user input %>
<form action="<%= request.servervariables("script_name") %>" method="post">
<input type=text name=u_input> <input type=submit value=Submit>
</form>
<% end if ' end check for user inputted value
else ' if the cookie has a value
' read the cookie and write the value of u_input to the browser
%>
'Over here I added the txt box with the cookie value
<input type="text" name="textfield" value=<%=request.cookies ("testcookie")("u_input")%>>
<%end if ' end check for cookie value %>
</body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Should I use cookies?? Help Tee88 Classic ASP Basics 3 January 21st, 2005 12:33 AM
Cookies shabboleth Beginning PHP 3 December 30th, 2003 10:32 AM
Cookies cjo ASP.NET 1.0 and 1.1 Basics 1 November 8th, 2003 02:38 PM
Help!About Cookies jelsen ASP.NET 1.0 and 1.1 Basics 2 September 9th, 2003 08:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.