Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / September 2008



Tip: Looking for answers? Try searching our database.

Please advise why the following code only giving empty string no u

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MMKG - 17 Aug 2008 13:20 GMT
<%
dim Conn, mysql
Set Conn= Server.CreateObject("Adodb.Connection")
Conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\MDN2008\asp\db1.mdb;Persist Security Info=False"
'mysql= "insert into UserInfo(U_Name,P_Word)values('"& Request.Form("uname")
& "', '"& Request.Form("passw") &"')"
'Conn.execute (mysql)
Set Rs =Server.CreateObject("Adodb.Recordset")
Conn.BeginTrans
mysql= "insert into UserInfo([Name],PWord)values(' " &
Request.Form("txtName") & "', '" & Request.Form("txtpass") & "' )"
response.write(mysql)
Conn.CommitTrans
conn.close
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="Styles/CssStyles.css" rel="stylesheet" type="text/css">
</head>
<body>

     <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <td class="HeadingWithBackGround"><center>
       Login Maintenance
     </center></td>
   <tr>
    <td> </td>
    </tr>
    <tr>
    <td align="center" class="Heading">To register 'Click' create Login</td>
    </tr>
    </table>

 <table width="30%" align="center" cellpadding="="1" cellspacing="0" >
   <tr>
     <td width="25%" align="center"><b>User Name</b></td>
     <td width="40%"><input type="text"  name="txtName" ></td>
   <tr>
     <td width="25%" align="center"><b>Password</b></td>
     <td width="40%%"><input type="Password" name="txtpass"></td>
   </tr>
   <tr>
    <td> </td>
     <td> </td>
   </tr>
   <tr>
     <td> </td>
     <td align ="Left"><input type=Submit name=btnOk value="   Create   "
class=Buttons>
       <input type=Reset name=btnCancel value=" Clear " class=Buttons></td>
   </tr>
    </table>
    </body>
    </html>
Adrienne Boswell - 17 Aug 2008 17:31 GMT
Gazing into my crystal ball I observed =?Utf-8?B?TU1LRw==?=

We have a few problems here.  First, one should state the question in
the first part of the post, and then include code.

><%
> dim Conn, mysql
[quoted text clipped - 4 lines]
> Request.Form("uname") & "', '"& Request.Form("passw") &"')"
> 'Conn.execute (mysql)

No need to include commented out code here.  The commented code is not
causing the problem.

> Set Rs =Server.CreateObject("Adodb.Recordset")

No need to open a record set for an insert statement.

> Conn.BeginTrans
> mysql= "insert into UserInfo([Name],PWord)values(' " &
> Request.Form("txtName") & "', '" & Request.Form("txtpass") & "' )"

You are seriously opening yourself to SQL injection. You need to
validate all user input server side _before_ it goes into the db.

> response.write(mysql)

And so what does mysql say?  It would probably be more helpful to quote
this than commented out code.

> Conn.CommitTrans
> conn.close
> %>
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

New pages should use a strict doctype, transitional is for pages that
are, well, in transition.

><html>
><head>
[quoted text clipped - 15 lines]
>     Login</td> </tr>
>     </table>

Please stop abusing tables and deprecated elements.  This could simply
be marked up as:
<h1>Login Maintenance</h1>

<form method="post" action="page.asp">
<fieldset><legend>Fill out the form</legend>

>  <table width="30%" align="center" cellpadding="="1" cellspacing="0" >
>     <tr>
[quoted text clipped - 5 lines]
>     </tr>
>     <tr>

Yikes!  Another table, but no form element whatsoever.  How do you
expect anything to get to the server without the form element?

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

What's this? This is just bloat.

>       <td align ="Left"><input type=Submit name=btnOk value="   Create
>         "
> class=Buttons>
>         <input type=Reset name=btnCancel value=" Clear "
>         class=Buttons></td>

It will help you to be consistent in quoting element attributes.  If you
ever decide to go with XHTML, attributes _must_ be quoted.

>     </tr>
>     </table>
>     </body>
>     </html>

Signature

Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

paul@bullschmidt.com - 16 Sep 2008 02:02 GMT
> <%
> dim Conn, mysql
[quoted text clipped - 55 lines]
>         </body>
>         </html>

Perhaps the fields aren't posting because the login page does not have
a <form> tag and </form> end tag.

Best regards,
-Paul
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.