Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

MMKG

unread,
Aug 17, 2008, 8:20:00 AM8/17/08
to
<%
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

unread,
Aug 17, 2008, 12:31:01 PM8/17/08
to
Gazing into my crystal ball I observed =?Utf-8?B?TU1LRw==?=
<MM...@discussions.microsoft.com> writing in
news:6943211A-B451-4C46...@microsoft.com:

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
> 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)

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>
><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>

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>
> <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>

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>
>

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

pa...@bullschmidt.com

unread,
Sep 15, 2008, 9:02:53 PM9/15/08
to

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

0 new messages