Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Webdotx

Session + Link = Problema seriooooooo

Recommended Posts

ai galera como eu faço pra guarda em uma session uma parte de um link ou seja

 

eu montei um sistema de links sendo que eu não consigo enviar pra consulta o que eu quero

 

Vou explicar

 

eu tenho um banco de dados com diversas empresas cadastradas e diversas categorias - num total de 10 categorias

 

eu queria fazer assim quando o usuario clicar no Link Farmacia seria guardado em uma session o nome farmacia - e quando entrasse na segunda pagina que faz a consulta no BD o nome farmacia que esta guardado na session seria usado tipo assim

 

ASP [/tr][tr]

Set RS = links.execute("select * from links where category LIKE '%"&session("teste")&"%' order by Category asc,Description asc")

[/tr]

 

me de uma luz ae galera pois eu tenho que entregar esse sistema tao logo e só falta isso pro sistema funfa, e já tentei de tudo - e pesso a juda da galera aheee

 

http://forum.imasters.com.br/public/style_emoticons/default/ninja.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pôe a variavel de sessão de tro de outra variavelempresa = Session("teste")Set RS = links.execute("select * from links where category LIKE '%"&empresa&"%' order by Category asc,Description asc")Faz um teste aiqualquer coisa posta de novo

Compartilhar este post


Link para o post
Compartilhar em outros sites

Vou postar abaixo o codigo pra se ter uma ideia do que estou fazendo - onde posso emplementar pra funfar legal

 

links.asp(este é a pagina que lista as categorias e algumas empresas cadastradas)

ASP [/tr][tr]

<%

pass = "admin" 'Password

screenwidth = 800

adminapproval=false 'Administration approval is required before displaying links? (True/False)

title="Links"

usercreateowncategories = true 'Allow users to create their own categories? (True/False)

Set links=Server.CreateObject("ADODB.Connection")

links.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=d:\servicemedi.com\dados\db\links.mdb"

set rs = Server.CreateObject("ADODB.Recordset")

 

'*************

if isnumeric(Request.QueryString("accept")) and Request.QueryString("accept") <> "" and Request.QueryString("pass") = pass then' Accept

RS.Open "select * from links where ID=" & Request.QueryString("accept"), links, 0, 3'1,3

rs("Accept") = True

rs.Update

rs.Close

Links.close

Response.Redirect ("links.asp?pass=" & Request.QueryString("Pass"))

end if

 

if isnumeric(Request.QueryString("d")) and Request.QueryString("d") <> "" and Request.QueryString("pass") = pass then' Delete

IDlink = Clng(Request.QueryString("d"))

links.execute("delete from links where ID=" & IDlink)

Links.close

Response.Redirect ("links.asp?pass=" & Request.QueryString("Pass"))

end if

 

if Request.QueryString("a") = "b" then ' Admin

if Request.Form("Pass") = pass then

Response.Redirect("links.asp?pass=" & Request.Form("Pass"))

else

Response.Redirect ("links.asp")

end if

end if

 

if Request.QueryString("a") = "a" then 'Add/update a link

if Request.Form ("description") <> "" and Request.Form ("address") <> "" and Request.Form ("address") <> "http://" then

 

if isnumeric(Request.form("h")) and Request.form("h") <> "" then

RS.Open "select * from links where ID=" & Request.form("h"), links, 0, 3'1,3

else

RS.Open "links", links, 0, 3'1,3

RS.Addnew

end if

 

if Request.Form("NewCategory") <> "" then

RS("Category") = Request.Form("NewCategory")

else

RS("Category") = Request.Form("Category")

end if

 

RS("Date") = now()

RS("URL") = Request.Form("address")

RS("Description") = Request.Form("description")

if not adminapproval then RS("Accept")=true

RS.Update

 

RS.Close

Links.close

end if

 

if Request.form("h") <> "" then

Response.Redirect ("links.asp?pass=" & Request.QueryString("Pass"))

else

Response.Redirect("links.asp")

end if

 

end if

 

if isnumeric(Request.QueryString("u")) and Request.QueryString("u") <> "" then

RS.Open "select * from links where ID=" & Request.QueryString("u"), links, 0, 3'1,3

acategory = RS("Category")

aurl = RS("URL")

adescription = RS("Description")

aid = RS("ID")

rs.Close

end if

%>

<html>

<head>

<title>Links</title>

</head>

<body>

<style type="text/css">

<!--

A:link { text-decoration: none; color:"#0000FF" }

A:visited { text-decoration: none; color:"#FF0000" }

-->

</style>

<table border="1" cellpadding="0" cellspacing="0" width="<%=screenwidth%>"><tr><td>

<table border="0" cellpadding="0" cellspacing="0" width="<%=screenwidth%>">

<tr><td bgcolor="#008080">

<p align="center"><font color="#FFFFFF" size="4"><b><%=title%></b></font></p>

</td></tr>

</table>

<div align="center">

<center>

<table border="0" cellpadding="0" cellspacing="0" width="<%=screenwidth-100%>">

<%

if Request.QueryString("pass") = pass then ' Admin

Set RS = links.execute("select * from links order by Category asc,Description asc")

else

Set RS = links.execute("select * from links where accept order by Category asc,Description asc")

end if

 

do while not (RS.Eof)

 

if dept <> rs("Category") then

Response.Write "<tr><td width=" & screenwidth & " colspan='2'> </td></tr>"'Spacer

Response.Write "<tr><td width=" & screenwidth & " height='1' colspan='2' bgcolor='#000000'><img src='../pics/spacer.gif' width='1' height='1'></td></tr>"

Response.Write "<tr><td width=" & screenwidth & " colspan='2' bgcolor='#FFFFCC'> <font color='#000000'>" & RS("Category") & "</font></td></tr>"

Response.Write "<tr><td width=" & screenwidth & " height='1' colspan='2' bgcolor='#000000'><img src='../pics/spacer.gif' width='1' height='1'></td></tr>"

dept = rs("Category")

xp=dept

session("teste")=xp

end if

 

Response.Write "<tr><td width='39'> </td>"

Response.Write "<td width=" & screenwidth-39 & " bgcolor='#FBFBFB'>"

Response.Write "<a href='ks.asp?" & session("teste") & "' target='_blank'>" & RS("category") & "</a>"

testando = "<a href='ks.asp?" & session("teste") & "' target='_blank'>" & RS("category") & "</a>"

response.Write session("teste")

Response.Write "</td></tr>"

RS.Movenext

loop

%>

</table>

</center>

</div>

<br><br><hr width='<%=screenwidth-100%>'>

<form method="POST" action="links.asp?a=a<%if Request.QueryString("Pass")<> "" then Response.Write"&pass="&Request.QueryString("Pass")%>">

<%

if adescription <> "" then

Response.Write "<input type='hidden' name='h' value=" & aid & ">"

end if

rs.close

%>

<div align="center">

<center>

<table border="2" cellpadding="0" cellspacing="0" width="600" bordercolor="#008080">

<tr>

<td bgcolor="#008080" align="center"><font color="#FFFFFF" size="4">Add

a new Site</font></td>

</tr>

<tr>

<td align="center" bgcolor="#F7F7F7"><br>

Place my link into existing category <select size="1" name="category">

<%

Set RS = Links.execute("select Distinct Category from links")

do while not rs.eof

Response.Write "<option"

if RS("Category") = acategory then Response.Write (" selected")

Response.Write ">" & RS("Category") & "</option>"

rs.movenext

loop

rs.close

%>

</select>

<br>

<%if usercreateowncategories or Request.QueryString("Pass")=pass then%>

<b>or<br>

</b>Create a new category <input type="text" name="newcategory" size="18" maxlength="50">

<%end if%>

<p>Description of Site <input type="text" name="description" value="<%=adescription%>" size="49" maxlength="100"></p>

<%if aurl = "" then aurl = "http://"%>

 

<p>Address of Site <input type="text" name="address" size="52" value="<%=aurl%>" maxlength="100"></p>

<p><input type="submit" value="Add Site to Links" name="B1"><br>

 </td>

</tr>

</table>

</center>

</div>

</form>

<form method="POST" action="links.asp?a=b">

<div align="center">

<center>

<table border="2" cellpadding="0" cellspacing="0" width="400" bordercolor="#008080">

<tr>

<td align="center" bgcolor="#F7F7F7"><br>

<input type="text" name="pass" size="21"> <input type="submit" value="Admin Login" name="B1">

<%if Request.QueryString("Pass")=pass then Response.Write "<a href='links.asp'>logout</a>"%>

<br>

 </td>

 

</tr>

</table>

</center>

</div>

</form>

</td></tr></table></td></tr></table>

</body>

</html>

 

<%

links.close

%>

[/tr]

 

Este aqui abaixo deveria receber o nome que esta na session teste e gerar uma consulata com esse valor veja o codigo

 

ks.asp

ASP [/tr][tr]

<%

pass = "admin" 'Password

screenwidth = 800

adminapproval=false 'Administration approval is required before displaying links? (True/False)

title="Links"

usercreateowncategories = true 'Allow users to create their own categories? (True/False)

 

Set links=Server.CreateObject("ADODB.Connection")

links.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=d:\servicemedi.com\dados\db\links.mdb"

set rs = Server.CreateObject("ADODB.Recordset")

 

'********************************************************************************

*****************************************

%>

<html>

<head>

<title>Links</title>

</head>

<body>

<link href="style.css" rel="stylesheet" type="text/css">

<table border="1" cellpadding="0" cellspacing="0" width="<%=screenwidth%>"><tr><td>

<table border="0" cellpadding="0" cellspacing="0" width="<%=screenwidth%>">

<tr><td bgcolor="#008080">

<p align="center"><font color="#FFFFFF" size="4"><b><%=title%></b></font></p>

</td></tr>

</table>

<div align="center">

<center>

<table border="0" cellpadding="0" cellspacing="0" width="<%=screenwidth-100%>">

<%

Set RS = links.execute("select * from links where category LIKE '%"&session("teste")&"%' order by Category asc,Description asc")

 

do while not (RS.Eof)

 

if dept <> rs("Category") then

Response.Write "<tr><td width=" & screenwidth & " colspan='2'> </td></tr>"'Spacer

Response.Write "<tr><td width=" & screenwidth & " height='1' colspan='2' bgcolor='#000000'><img src='../pics/spacer.gif' width='1' height='1'></td></tr>"

Response.Write "<tr><td width=" & screenwidth & " colspan='2' bgcolor='#FFFFCC'> <font color='#000000'><b>" & RS("Category") & "</font></td></tr>"

Response.Write "<tr><td width=" & screenwidth & " height='1' colspan='2' bgcolor='#000000'><img src='../pics/spacer.gif' width='1' height='1'></td></tr>"

dept = rs("Category")

xp=dept

session("teste")=xp

 

end if

 

Response.Write "<tr><td width='39'> </td>"

Response.Write "<td width=" & screenwidth-39 & " bgcolor='#FBFBFB'>"

Response.Write "<a href='" & RS("URL") & "' target='_self'>" & RS("Description") & "</a>"

response.Write("<br>")

response.Write("<hr>")

Response.Write "</td></tr>"

 

RS.Movenext

loop

%>

</table>

</center>

</div>

</td></tr></table></td></tr></table>

</body>

</html>

 

<%

links.close

%>

[/tr]

 

Onde posso esta errando galera...

 

:( :( :( :unsure:

Compartilhar este post


Link para o post
Compartilhar em outros sites

bem cara é o seguinte é meio ruim analisar o codigo inteiro, então verifica se a session recebe mesmo algum valor na pagina anteriore tambem notei que você alterar o valo da session dentro de um loop verifica se é isso mesmo

Compartilhar este post


Link para o post
Compartilhar em outros sites

o valor que esta indo pra pagina seguinte esta errado pois ele pega a ultima categoria cadastrada no BDeu queria que ele apénas pegasse o nome do link por exemploo link é farmacia, o valor que ficaria guardado na session seria farmaciaquando eu entrasse na pagina de resultado eu utilizaria a session para consultar o BD e me retornaria tudo que esta cadastrado na categoria farmaciacasso você tenha um codigo mais faciil que o meu, ficarei agradecido (*_*)

Compartilhar este post


Link para o post
Compartilhar em outros sites

bem cara se você quer que passe apenas o valor do link não altera o valor dela na pagina seguinte.mentem o valor da session e so altera em caso de novo clique

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.