Session varaiables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gowthamkg
    New Member
    • Sep 2008
    • 23

    #1

    Session varaiables

    For the following code when ever i open the this page the text box has /
    i ahve set the value of text box with session variables whic is exuted only when submit button is clicked....Pls Help me....

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>REGISTRATION</title>
    <script language="javascript" src="validate.js" type="text/javascript"></script>
    </head>
    <body>
    <h4><b>WELCOME TO REGISTRATION PAGE</b></h4>
    <form id="registration" name="registration" method="post"  onsubmit="return ValidateForm();">
     <table width="346">
     
     <tr><br />
      <td width="338" align="Center"><h2 align="center">REGISTRATION</h2></td>
     </tr> 
      <tr>
         <td width="338" align="center" nowrap="nowrap"><h4 align="left">User Name:
              <input name="txtuname" type="text" value=<%=session("username")%> /> <h4 align="left">First Name:
    		            <input name="txtfname" type="text" value=<%=session("fname")%> />
         </h4></td>
     </tr>
     
      <tr>
         <td width="338" align="center"><h4 align="left">Last Name:   
              <input name="txtlname" type="text" value=<%=session("lname")%> />     
         </h4></td>
     </tr>
     
     <tr>
         <td align="center" ><h4 align="left">Password:     
              <input name="txtpassword" type="password" value=<%=session("password")%> />     
         </h4></td>
     </tr>
     
      <tr>
         <td align="center"><h4 align="left">EMAIL ID:    
              <input name="txtemail"  type="text" value=<%=session("mail")%> />     
         </h4></td>
     </tr>
     
      <tr>
         <td align="center"><h4 align="left">Phone No:    
              <input name="txtphno" type="text" value=<%=session("phno")%> />     
         </h4></td>
     </tr>
     
       <tr>
         <td align="center"><h4 align="left">Mobile No:    
              <input name="txtmno" type="text" value=<%=session("mno")%> />     
         </h4></td>
     </tr>
     
      <tr>
         <td align="center"><h4 align="left">Address:                       
           <textarea name="txtadd1" wrap="physical" value=<%=session("add1")%>></textarea>
         </h4></td>
     </tr>
     <% response.Write(session("mail"))%>
     <tr>
         <td align="center"><h4 align="left">Address2:    
              <textarea name="txtadd2" value=<%=session("add2")%>></textarea>     
         </h4></td>
     </tr>
     
     <tr>
         <td align="center"><h4 align="left">City:    
              <input name="txtcity" type="text" value=<%=session("city")%>/>     
         </h4></td>
     </tr><tr>
         <td align="center"><h4 align="left">State:    
              <input name="txtstate" type="text" value=<%=session("state")%> />     
         </h4></td>
     </tr>
     
     <tr>
         <td align="center"><h4 align="left">Country:    
              <input name="txtcountry" type="text" value=<%=session("country")%> />     
         </h4></td>
     </tr>
     
     <tr>
         <td align="center"><h4 align="left">Zip code:    
              <input name="txtzip" type="text" value="<%=session("zip")%>" />     
         </h4></td>
     </tr>
     
     <tr><br />
    	 <td align="center"><input name="btnsubmit" type="submit" id="btnsubmit" value="Submit" />
    	  <input type="reset" />	 </td>
     </tr>	 
    </table>
    </form>
    
    
    
    </body>
    </html>
    <%
    
    if(request.form("btnsubmit")<>"") then
    mail=request.form("txtemail")
    id=request.form("txtuname")
    
    set conn=server.CreateObject("ADODB.connection")
    conn.Mode = 3
    ConnString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=Rajesh;Port=3306;DATABASE=agstc2008;UID=root;PWD=sa;character set=utf8;"
    conn.open ConnString
    set rs=server.CreateObject("ADODB.recordset")
    query="select * from tbluser"
    Set rs = conn.execute(query)
    no=2  	
    
    while not RS.EOF
    
    if rs("userEmailId")=mail OR rs("userId")=id THEN
        Response.Write("EMAIL ID/USER ID ALREADY EXISTS")
     	session("username")=request.form("txtuname")
    	session("password")=request.form("txtpassword")
    	session("fname")=request.form("txtfname")
    	session("lname")=request.form("txtlname")
    	session("email")=request.form("txtemail")
        session("phno")=request.form("txtphno")
    	session("mno")=request.form("txtmno")
    	session("add1")=request.form("txtadd1")
    	session("add2")=request.form("txtadd2")
    	session("city")=request.form("txtcity")
    	session("state")=request.form("txtstate")
    	session("country")=request.form("txtcountry")
    	session("zip")=request.form("txtzip")
    	no=1
    	end if
    rs.movenext
    wend
    if(no=2) then
        session("username")=request.form("txtuname")
    	session("password")=request.form("txtpassword")
    	session("fname")=request.form("txtfname")
    	session("lname")=request.form("txtlname")
    	session("email")=request.form("txtemail")
        session("phno")=request.form("txtphno")
    	session("mno")=request.form("txtmno")
    	session("add1")=request.form("txtadd1")
    	session("add2")=request.form("txtadd2")
    	session("city")=request.form("txtcity")
    	session("state")=request.form("txtstate")
    	session("country")=request.form("txtcountry")
    	session("zip")=request.form("txtzip")
    	response.Redirect("lsucess.asp")
    end if
    
    rs.close
    conn.close
    end if
    %>
    Last edited by DrBunchman; Nov 6 '08, 08:49 AM. Reason: Added [Code] Tags - Please use the '#' button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi gowthamkg,

    Which text box has the problem?

    Dr B

    Comment

    • gowthamkg
      New Member
      • Sep 2008
      • 23

      #3
      Originally posted by DrBunchman
      Hi gowthamkg,

      Which text box has the problem?

      Dr B
      Every text box shows "/" whene ever i load this page...and password text box it is "."

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Could you try putting some single quotes around the value property of your inputs, like this:

        Code:
        <input name="txtfname" type="text" value='<%=session("fname")%>' />
        I wonder if perhaps the interpreter is picking up the closing / of the input tag as part of the value. Probably not the problem but worth giving it a try!

        Let me know how what happens,

        Dr B

        Comment

        • gowthamkg
          New Member
          • Sep 2008
          • 23

          #5
          ITS gone..but another problem is that..once i click the submit it should check the database whether email id is present or not if so it should display EMAIL ID/USER ID ALREADY EXISTS and it should keep the same entered data's in the form...pls help me...

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            Is it displaying that text?

            I think the problem here might be the condition where you say If (no=2) Then...

            As far as I can see you have set the variable no to equal 2 no matter what happens.

            Dr B

            Comment

            • gowthamkg
              New Member
              • Sep 2008
              • 23

              #7
              ya i have set the no =2 default...becau se if there is only mail id is present it will change to 1 or else it will be directed to a page where it is inserted..

              Comment

              • DrBunchman
                Recognized Expert Contributor
                • Jan 2008
                • 979

                #8
                Okay, I see what you are doing.

                So does that text never display even when there is a mail id present?

                Dr B

                Comment

                Working...