Jump to content

logz

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by logz

  1. hi i want to post the checkbox value to my access db , and i check the recored in the db for yes or no , please sent to me a small example for checkbox and radiothank you

    HTML FORM PAGE:<FORM action="http://www.yoursite.com/db_add.asp" method="get"><input type="checkbox" name="checkboxname"><input type="submit" value="submit"></FORM>db_add.asp:
    <%	var checkboxvalue	checkboxvalue=request.querystring("checkboxname")  if checkboxvalue<>"" then  	var_dbaddvalue="yes"  else  	var_dbaddvalue="no"  end if	end if	set conn=Server.CreateObject("ADODB.Connection")	conn.Provider="Microsoft.Jet.OLEDB.4.0"	conn.Open "D:\DATABASE PATH.mdb"		sql="INSERT INTO table_name (field_name)	sql=sql & " VALUES "	sql=sql & "('" & var_dbaddvalue & "')"	on error resume next	conn.Execute sql,recaffected  if err<>0 then    	Response.Write("Error")  else     	Response.Write("OK")  end if	conn.close%>

  2. 2) How is the login verified when people have signed up and are attempting to login with their password. Thanks whoever can helpReachster

    You need to create a login form with the fields USERNAME and PASSWORD.When you click login, you need to be taken to a new ASP page.On that page, you need a program which saves the username and password collected from the login form to a variable.Use the USERNAME variable to then search your database for the username and password. IE:SQL:SELECT username, userpass FROM login WHERE username='" & request.form("username") & "'"Then, assign these two entries you've collected from the database to two other variables. for instance: collected_username and collected_passwordYou then need to compare the password submited via the login form to the password collected from the database using the IF ELSE function.IF request.form("username")=collected_username AND if request.form("password")=collected_password THENresponse.redirect("controlpanel.asp")ELSEresponse.redirect("failed.asp")END IF
  3. Try this: set Conn = Server.CreateObject("ADODB.Connection")Conn.Open "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=kurf;USER=root;PASSWORD=rishakawwemana;Option=3;"set rs=Server.CreateObject("ADODB.Recordset")rs.Open "Select * from diwan" , Conndo until rs.EOF for each x in rs.Fields Response.Write(x.name) Response.Write("=") Response.Write(x.value & "<br />") next Response.Write("<br />") rs.MoveNext loop rs.close Conn.closeIT looks like you forgot the rs.MoveNext part. But im not sure.

  4. when i try on the demo which locates at http://www.w3schools.com/ado/demo_db_add.asp  in the my local pc, it does not allow me to update the database. i tried to retrieve the data from database, it didn't give me any problem. so query from database is not a problem for me.i have checked with the acess right of the *.mdb ,it permits read write operation.can anyone please help me?

    W3schools has set the database and ASP program so you cant update or delete entries from the database.
  5. I would like to know how to find user information when they access an ASP page to get their current user ID, computer name, IP address....Maelstorm......

    Well, if you want to find there user ID, then you would need to create a few ASP programs. You would need for members to login to your website, then a save a cookie to there computer, then you would need to access and display that cookie. I dont know hwo to get the computer name, but ill have a look around, and as for the IP address, use this code:
    <%  Response.Write(Request.ServerVariables("remote_addr"))%>

    How do you want to display them? just wrote as plain text on a webpage? or saved to a database?Here is a very simple login script i wrote a while back. It connects to a database with a table of two fields, username and user_pass. What happens is, the user enters there username and password into a login form, that data is then saved as a variable, and the database is connected to. The program then collects the password in the database where the username relates the the username given by the user. The password collected from the database is then compared to the password provided by the user, and if the username given AND username collected = the same, and the password given AND password collected = the same, a cookie is placed on there computer and they are logged in. Else they are redirected to an error page:---------------------------------Login Form:

    <form action="http://www.yourdomain.com/login.asp" method="post"><input type="text" size="40" name="username" value="username"><br><input type="password" size="40" name="password" value=""><p><input type="submit" value="Login"></form><form>

    login.asp(before the HTML tags, i collected the data sent from the form, and assign it to variables:

    <%  dim cusername, cpassword    cusername=request.form("username")    cpassword=request.form("password")%>

    Then this is the database program:

    <%	set conn=Server.CreateObject("ADODB.Connection")	conn.Provider="Microsoft.Jet.OLEDB.4.0"	conn.Open "D:\database.mdb"	set rs = Server.CreateObject("ADODB.recordset")	rs.Open "SELECT username, user_pass FROM userdata WHERE username='" & cusername & "'", conn	do until rs.EOF  	for each x in rs.Fields          if x.name="username" then  	session("con_user_session")=x.value  else  if x.name="user_pass" then  	session("con_pass_session")=x.value  end if  end if	next  	rs.MoveNext	loop	rs.close	conn.close	if session("con_user_session")=cusername AND session("con_pass_session")=cpassword then		response.cookies("acception")=1	response.cookies("iuser")=cusername	else		response.cookies("acception")=0	response.cookies("iuser")=""	end if%>

    Then in the body section, i use this code to display the username given:

    <%  response.write(request.cookies("iuser"))%>

    Hope it helps. But that databse program is very simple, and un-secure. Im not sure what you meant about the displaying username tho.

  6. set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/your/database/path.mdb"))or set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "D:\your database path "

  7. theres a couple of ways of doing it. The most easiest of which is creating a field which uses the AutoIncrement function. When you use the CREATE TABLE function, add this line:CREATE TABLE your_table(id autoincrement)Then, when you go to insert some data into the table, the ID field will automatically add 1 to the current value.However, if you delete a record in the middle of the table, you will be left with this id array:12356As you can see, the 4 is missing, and its carried straight on to five.You can overcome this by using the second method. You need to create the field ID as a varchar or whatever table. NOT AutoincrementThis one is slightly longer. First of all, create your ADO connection and use the SELECT SQL statement, but use the function COUNT(*). Note ive created the variable "add_count".

    <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "YOUR DATABASE ROUTE"set rs = Server.CreateObject("ADODB.recordset")rs.Open "SELECT COUNT(*) FROM your_table", conndo until rs.EOF    for each x in rs.Fields     dim add_count     add_count=x.value    next    rs.MoveNextlooprs.closeconn.close%>

    What ive done, is counted all the records in the "your_table" table. ive then assigned this value to a variable. You will need this variable later.Next, you need to create a new variable which will add 1 to the total number of records.... to do this write this:

    <%   dim iadd_count   iadd_count=add_count+1%>

    Now, you can write your update or insert program as normal:

    <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "DATABASE PATH"sql="INSERT INTO your_table (id)"sql=sql & " VALUES "sql=sql & "('" & iadd_count & "')"on error resume nextconn.Execute sql,recaffectedif err<>0 then  Response.Write("Error")else   Response.Write("Record Added")end ifconn.close%>

    Now, you've included the "iadd_count" variable in the insert program.If you need any help, just ask!Try the first method first though!

  8. Using the Content Linkin Component1) Create the file nav.txt (or whatever you want to call it. Just remember the exact file name).2) In your nav.txt file, you need to format your text as such:

    home.asp	(TAB) Homepage1.asp	(TAB) Example Page 1page2.asp	(TAB) Example Page 2contact.asp (TAB) Contact Us

    In the above, the first column indicates the URL to the web page you are linking to. so for example, if you wanted your first link to go to your homepage, you would use this url:http://www.your-domain.com/index.aspAfter you have wrote the URL, you need to use the TAB spacing character. NOT the space bar.When you have pressed tab, enter the text you want users to click on. IE:index.asp (TAB) HomeSave this file to your server, and take note of the location.Next, open the file you want your links to be displayed on, and enter this code:

    <%	dim c	dim i  set nl=server.createobject("MSWC.Nextlink")  c = nl.GetListCount("nav.txt")  i = 1%><table border="0" cellspacing="0" cellpadding="0" width="100%" align="left" valign="top"><%	do while (i <=c) %>	<tr>  <td width="100%" align="left" valign="top">  <a href="<%=nl.GetNthURL("nav.txt", i)%>" target="_self"><%=nl.GetNthDescription("nav.txt", i)%></a>  </td>	</tr><%	i= (i+1)	loop%></table>

    Save that page as a .asp page, save to your server and run the page.

  9. Hey, Im trying to utilize the TextStream object of ASP to create and write into a textfile based on my server.This is the code im using to create the textfile.

    <%     set fs=Server.CreateObject("Scripting.FileSystemObject")     set tfile=fs.CreateTextFile("D:\WWWRoot\cyban-networks.com\www\entertainment\textfiles\content_music\news\" & request.querystring("filename") & ".txt",false)     tfile.close     set tfile=nothing     set fs=nothing%>

    That code works fine. The next part of the code includes a form, in which details can be wrote and submitted to the next section of ASP, which is wrote below. In this section of code, i only want to write details into a TXT file, not create a new file.

    <%     set fs=Server.CreateObject("Scripting.FileSystemObject")      set t=fs.OpenTextFile("D:\WWWRoot\cyban-networks.com\www\entertainment\textfiles\content_music\news\" & request.querystring("filename") & ".txt")           t.WriteLine("<!--filename-->" & request.querystring("filename") & ".txt")     t.WriteLine("<!--author-->" & request.querystring("author"))     t.WriteLine("<!--date-->" & request.querystring("date"))     t.WriteLine("<!--header-->" & request.querystring("header"))           t.close     set t=nothing     set fs=nothing%>

    However, Whenever i execute this last peice of code, I am given the error message: Bad File ModeCan anyone give me a hand here and tell me what im doing wrong?!Cheers :)

  10. It is prohibited in Xhtml to use capitals in both elements and attributes, taht is why I said :)

    lol i know, but i never use Xhtml, only HTML, but im not really a designer, im more towards server side languages and development
  11. But the capitalisation is not necessary, you may if you want,
    Yup, you can use lowercase if you want. Usually, i put the main tags in capitals and lesser tags in lowercase so its easier for me to nagivate the code.
  12. Im just wondering, if we happen to have an ADO query, should we put it in the SQL or ASP forum?Thanks :)EDIT: Can we ask about online databases such as MSSQL, MySQL and Access?

  13. When visitors access a website, the first thing they will do is scan the homepage. They'll look to see if its interesting, whether it loads fast enough, and then check some text out briefly. You should try make a checklist or something and write things you as a visitor to another site would look for and try imply them into your website.As a helpful start, you may want to introduce graphics to your site, or a wider range of colours. Website templates can be bought for pretty cheap, they are usually professionally designed and attract visitors. One of my favourites is www.4templates.com :) good luck!

  14. <TITLE> Type your name here </TITLE>

    you need to put that in the head section of your coding:

    <HTML>   <HEAD>      <TITLE> Your Name </TITLE>   (any other tags you want to include)   </HEAD>   <BODY>   </BODY></HTML>

    Enjoy!

  15. I think i understood you, Within your .inc file, i believe you can use ASP. If you can, you can use the 'if - else' function.Its really easy. you will need to utilize querystrings also. When you create a link using HTML, write a querystring like this:www.domain.com/file.asp?action=resultThe question mark indicates the beginning of a querystring, the "action" word is the querystring name, and the result is the names value.When im using querystrings to preform an action on a subsequent page, i always use the name "action".The next thing you need to do it edit your .inc file. Within the .inc file, you need to recall your querystring in a if statement. The IF statement will display a peice of code, if the condition is true. other wise it will display a different peice of code:

    <% if request.querystring("action")="step_one" then%>step oneYour homepage text can go here, in normal, standard HTMLThis will be displayed if the querystring name "action"'s value is equil to "step_one"<% else %>This will be displayed if the value of "action" is anything other than "step_one".<%end if%>

    So, if i access that code above with the querystring: action=step_onethen it will display the text "Your homepage text can go here..." if the querystring is this:action=step_twothen it will display the text "this will be displayed if the value of "action" is anything other than..."So, this is what your end .inc file should look like:

    <% if request.querystring("action")="example1" then %>Example One<a href="http://www.exampledomain.com/index.asp?action=example2">Example two link</a> <a href="http://www.exampledomain.com/index.asp?action=example3">Example three link</a><% else if request.querystring("action")="example2" then %>Example Two<a href="http://www.exampledomain.com/index.asp?action=example1">Example one link</a> <a href="http://www.exampledomain.com/index.asp?action=example3">Example three link</a><% else if request.querystring("action")="example3" then %>Example Three<a href="http://www.exampledomain.com/index.asp?action=example1">Example one link</a> <a href="http://www.exampledomain.com/index.asp?action=example2">Example two link</a><% end ifend ifend if%>

    Using that code, you only need to use one .inc file, which is alot easier to update.IF you want to use a different .inc file for each page, you can use the following code:

    index.asp file:<!-- CONTENT START --><% header=request.querystring("header")%><!--#include virtual="<%=header%>"--><!-- CONTENT END -->

    Thats your index.asp file. Basically, your index.asp file should have the following querystring attached:index.asp?header=virtual pathThe virtual path is something like: /inc/homepage.incor /inc/page_two.inctherefore, if you wanted to display the homepage inc file, use the querystring:index.asp?header=/inc/homepage.incWithin the ASP file i have included a small script which will change the querystring value into a variable. the variable is called header. The <!--#include virtual="<%=header%>"--> then includes the inc file wrote in the variable. If you want to request a different page, you need to use the follow links:www.yourwebsite.com/index.asp?header=/inc/homepage.incwww.yourwebsite.com/index.asp?header=/inc/page_two.incwww.yourwebsite.com/index.asp?header=/inc/page_three.incwww.yourwebsite.com/index.asp?header=/inc/page_four.incSorry if this is confusing, if you need more help, ill try explain it more clearly

×
×
  • Create New...