Hi alex,
Okay, I don't see where the function url() is being used, but I'll take your
word for it that the URL is in the "members" table. Another thing that
puzzles me is that the url() function seems to be updating a field in a
table called "users," but the GetUser() function is querying a table called
"users." But again, I don't see that function being used, so I'll ignore it.
So, as I don't know the names of all the columns in the "members" table, I'm
going to call the "url" column "url" and you can change it if I'm mistaken
about the name. Now, you're currently using
FormsAuthentication.RedirectFromLoginPage(UserName.Text, false) to redirect
the user to what I presume to be your default home page, although I could be
wrong. In any case, you would replace that line with the following:
Response.Redirect(Convert.ToString(userDS.Tables[0].Rows[0]["url"]), false);
Note that the code above assumes that the value in the column is never null.
Otherwise you have to check for a null value, as the Convert.ToString()
method will throw an exception if it operates on anything other than a
string.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
alex said:
well the login page i did by following a guide. But here is the code from
each page
login.aspx page
<%@ Page Language="C#" Debug="True" %>
<script runat="server">
void LoginBtn_Click(Object sender, EventArgs e) {
if (Page.IsValid) {
System.Data.DataSet userDS = new System.Data.DataSet();
userDS = GetUser(UserName.Text, UserPass.Text);
if (userDS.Tables[0].Rows.Count == 1) {
Session["userid"] = userDS.Tables[0].Rows[0].ItemArray[0];
FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
}
else {
Msg.Text = "Invalid Credentials: Please try again";
}
}
}
int url(string url) {
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole
DB Services=-4; Data Source=z:\\";
System.Data.IDbConnection dbConnection = new
System.Data.OleDb.OleDbConnection(connectionString);
string queryString = "UPDATE [users] SET
Did you write this code, or did a Wizard? If a Wizard wrote it, I would
have
to see the code.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
[/QUOTE]"]=@url";
System.Data.IDbCommand dbCommand = new
System.Data.OleDb.OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;
System.Data.IDataParameter dbParam_url = new
System.Data.OleDb.OleDbParameter();
dbParam_url.ParameterName = "@url";
dbParam_url.Value = url;
dbParam_url.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_url);
int rowsAffected = 0;
dbConnection.Open();
try {
rowsAffected = dbCommand.ExecuteNonQuery();
}
finally {
dbConnection.Close();
}
return rowsAffected;
}
System.Data.DataSet GetUser(string username, string password) {
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole
DB Services=-4; Data Source=Data Source=z:\\";
System.Data.IDbConnection dbConnection = new
System.Data.OleDb.OleDbConnection(connectionString);
string queryString = "SELECT [members].* FROM [members] WHERE
(([members].[username] = @username) AND (" +
"[members].[password] = @password))";
System.Data.IDbCommand dbCommand = new
System.Data.OleDb.OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;
System.Data.IDataParameter dbParam_username = new
System.Data.OleDb.OleDbParameter();
dbParam_username.ParameterName = "@username";
dbParam_username.Value = username;
dbParam_username.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_username);
System.Data.IDataParameter dbParam_password = new
System.Data.OleDb.OleDbParameter();
dbParam_password.ParameterName = "@password";
dbParam_password.Value = password;
dbParam_password.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_password);
System.Data.IDbDataAdapter dataAdapter = new
System.Data.OleDb.OleDbDataAdapter();
dataAdapter.SelectCommand = dbCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<h2>Login Page
</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>
Username:</td>
<td>
<asp:TextBox id="UserName"
runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator
id="RequiredFieldValidator1" runat="server" ErrorMessage="*"
Display="Static"
ControlToValidate="UserName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="UserPass" runat="server"
TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator
id="RequiredFieldValidator2" runat="server" ErrorMessage="*"
Display="Static"
ControlToValidate="UserPass"></asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server"
text="Login"></asp:button>
<p>
<asp:Label id="Msg" runat="server" forecolor="red"></asp:Label>
</p>
</form>
</body>
</html>
default.aspx page
<%@ Page Language="C#" %>
<script runat="server">
// Insert page code here
//
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
</form>
</body>
</html>
Kevin Spencer said:
Did you write this code, or did a Wizard? If a Wizard wrote it, I would
have
to see the code.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
[/QUOTE][/QUOTE]