Thursday, 3 October 2013

User Login with JQUERY and ASP

User Login with JQUERY and ASP

I have this jquery mobile page designed with asp classic. when i test and
i try to login it bounces me back to the login page again instead of
taking me to the index page of the authenticated user. Here's my code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/VT.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction +
"?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("username"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = ""
MM_redirectLoginSuccess = "source.asp"
MM_redirectLoginFailed = "error.asp"
MM_loginSQL = "SELECT Username, Password"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL &
"," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM dbo.Test_Register_Users WHERE
Username = ? AND Password = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_VT_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append
MM_rsUser_cmd.CreateParameter("param1", 200, 1, 70,
MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append
MM_rsUser_cmd.CreateParameter("param2", 200, 1, 50,
Request.Form("password")) ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") =
CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And true Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<!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>Untitled Document</title>
<link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css"
rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"
type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"
type="text/javascript"></script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header">
<h1>Header</h1>
</div>
<div data-role="content">
<form id="form1" name="form1" method="POST" action="login_code.asp">
<table width="325" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="94">&nbsp;</td>
<td width="210">&nbsp;</td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" name="password" id="password" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="button" id="button" value="Submit" />
</div></td>
</tr>
</table>
</form>
</div>
<div data-role="footer">
<h4>Footer</h4>
</div>
</div>
</body>
</html>

Wednesday, 2 October 2013

Simple query to search a terms in MySQL

Simple query to search a terms in MySQL

I build a little search input in my site, its kind of working, the problem
is that it show all the items as results, so it isnt really searching, it
just throw all the table..
my query look like this
// Get page data
$query1 = "SELECT id,tienda,descripcion,local,img FROM $tableName WHERE
tienda LIKE '%$term%' ";
$result = mysql_query($query1)or die(mysql_error());
if i remove the % symbol of $term , then i got "no results" , so what am i
missing.
What i need is to search for exact and partial coincidences, for example,
"Go" should throw "google" as result..
thanks,

Pasting text from clipboard to Firefox and Chrome

Pasting text from clipboard to Firefox and Chrome

I am using this function that pastes text from clipboard into multiple
text fields.
function pasteFromClipboard(className) {
var data = window.clipboardData.getData('Text');
if (data != null) {
var cells = data.split('\n');
var columns = $$('.'+className);
for (i = 0; i < cells.length; i++) {
if ( columns[i] != undefined ){
columns[i].value = cells[i];
}
}
}
}
This stuff that is attached to button via "onClick" works in IE, but not
in FF or Chrome. Now I know FF restricts access to clip, but I have
manipulated the values in preferences with no success.
Can anyone help me out with this functionality, so it would work in Chrome?
Best regards, no9

VB.NET Adding Interactive User Account to folder permissions

VB.NET Adding Interactive User Account to folder permissions

I am having a little problem, adding a user to a folders permission, the
account in question is a SCCM account "Interactive" in which the account
is used when deploying an application.
I have looked about and not found anything apart from adding a system
account (Authenticated user using a SID) and to get the permissions to
inherit from a parent.
Any help of examples would be greatly appreciated.
AntonSK

Processing Dynamic Form

Processing Dynamic Form

I've a JS dynamic form, where i can add or remove fields:
Field 1
Field 2
Field 3
Field 4
Now if I remove Field 2 and add a new field:
Field 1
Field 3
Field 4
Field 5
K, I'm sending this through Ajax POST inside a form element. My problem is
server side PHP processing...how can I know how many fields I have insde
$_POST array and what are their ids? I'm generating unique id using
"field" + counterIndex, but following the example how can I be able to
understand that I have a total of 4 fields and that number 2 is missing?
By the way, inside the form I have static fields too.

Tuesday, 1 October 2013

Connecting to Amazon RDS instance through EC2 instance using MySQL Workbench

Connecting to Amazon RDS instance through EC2 instance using MySQL Workbench

I AWS I have a VPC set up with a Bastion Host. The bastion host is a
single EC2 instance with a public address trough which you can SSH to any
other server on the VPC.
I have created an RDS MySQL instance within the VPC and I would like to
connect to it using MySQL workbench. I have followed the steps detailed
here, however in "Step 6: Setting up remote SSH Configuration", it asks me
to "Provide the Public DNS of the Amazon EC2 instance" (i.e. the bastion
host).
MySQL workbench then does checks for certain MySQL resources on that
server. However, this is not correct in my opinion as I have provided the
bastion host's address, which does not have MySQL installed. As a result,
the last two checks for "Check location of start/stop commands" and "Check
MySQL configuration file" then fail.
I have then tried using the endpoint address of the RDS MySQL instance but
with no success (as it is in the private subnet so is not publicly
addressable).
It seems that many people have this up and running, but what am I doing
wrong here?

Is it possible to redirect to ssl and non www at the same time?

Is it possible to redirect to ssl and non www at the same time?

I have a developer account and the setup is different from a typical host.
With this provider, each domain is allocated an app. 4 domains:
https://example.com https://www.example.com http://example.com
http://www.example.com
The chosen "main" domain is the top one, https://example.com. So, in my
host login panel, I have allocated the website "app" to
https://example.com while the remaining 3 are allocated "redirect" apps.
For the non ssl http domains I have used:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
The purpose of this is to just redirect to ssl. This seems to work fine.
Then, for the www version, which I'd like to redirect to non www version,
I have used:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
Does not work. But, in additon to figuring that out, what I'd really like
is to have the 3 domain variants all served by the same .htaccess file
with 2 purposes: redirect to ssl and to non www version. Is this possible?