hey Lee. maybe you can take a loook at this with me... its kind of a bit of code here but it is in pretty "manageable" chunks. and not all of it is really neccessary to show but i do anyways in case someone decides to give constructive criticism. anyways my problem here is:
1) After registering, the register page reloads with blank text fields instead of redirecting me to my profile page.
2) i cant log in with the created user account (the new username shows up in my member list though) the only reason i can log in at all is because of the user account i defined in the web config file.
if i get a reply on this giant post (its my gift to whoever needs to make a login procedure on their page) my thanks in advance
******************
WEB.CONFIG |
******************
Overview:
1) Defined ConnectionString:myConnection0&&myConnection1
2) Defined Provider
Code:
WEB CONFIG
<connectionStrings>
<add name="myconnection0" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\MemberSites\MemberSites_AspSpider_Ws\iceman90289\database\ASPNETDB.MDF;Integrated Security=True;User Instance=True" />
<add name="myconnection1" connectionString="Data Source=.\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=iceman90289_ASPNETDB"/>
</connectionStrings>
<roleManager enabled="true">
</roleManager>
<membership defaultProvider="MyMembership">
<providers>
<add name="MyMembership" minRequiredNonalphanumericCharacters="0" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="myconnection0" requiresQuestionAndAnswer="false" requiresUniqueEmail="True"
applicationName="/iceman90289" />
</providers>
</membership>
***********************
REGISTER.ASPX |
***********************
Overview:
1) Created Custom Register Form
2) Creates a profile on a usertable
Code:
<script runat="server">
protected void AddUserToProfile(object sender, EventArgs e)
{
CreateUserProfile(
((TextBox)CreateUserWizard1.FindControl("UserName")).Text,
((TextBox)CreateUserWizard1.FindControl("txtFirstName")).Text,
((TextBox)CreateUserWizard1.FindControl("txtLastName")).Text,
((TextBox)CreateUserWizard1.FindControl("Password")).Text,
((TextBox)CreateUserWizard1.FindControl("Email")).Text,
((DropDownList)CreateUserWizard1.FindControl("ddlQuestion")).SelectedValue,
((TextBox)CreateUserWizard1.FindControl("txtAnswer")).Text);
}
protected void CreateUserProfile(string userName, string firstName, string lastName, string password,
string email, string question, string answer)
{
string constring = WebConfigurationManager.ConnectionStrings["UserProfiles"].ConnectionString;
SqlConnection con = new SqlConnection(constring);
SqlCommand cmd0 = new SqlCommand("CREATE TABLE UserProfiles (UserName varchar(30), FirstName varchar(30), LastName varchar(30),Password varchar(30),Email varchar(30),Question varchar(30),Answer varchar(30))");
using (con)
{
con.Open();
cmd0.ExecuteNonQuery();
con.Close();
}
SqlCommand cmd = new SqlCommand("INSERT INTO UserProfiles(UserName, FirstName, LastName, Email, Question, Answer) VALUES(@UserName, @FirstName, @LastName, @Email, @Question, @Answer");
cmd.Parameters.AddWithValue("@UserName", userName);
cmd.Parameters.AddWithValue("@Password", lastName);
cmd.Parameters.AddWithValue("@FirstName", firstName);
cmd.Parameters.AddWithValue("@LastName", lastName);
cmd.Parameters.AddWithValue("@Email", email);
cmd.Parameters.AddWithValue("@Question", question);
cmd.Parameters.AddWithValue("@Answer", answer);
using (con)
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
</script>
<asp:CreateUserWizard
id="CreateUserWizard1"
RequireEmail="true"
AutoGeneratePassword="false"
OnCreatedUser="AddUserToProfile"
ContinueButtonText="Proceed" CreateUserButtonText="Create Profile"
runat="server" BorderStyle="Outset" BorderWidth="2"
CompleteSuccessText="Your account is good to go alright! chaha!">
<WizardSteps>
<asp:CreateUserWizardStep>
<ContentTemplate>
<h1>Register Here</h1>
<asp:Label
id="lblUserName"
Text="User Name: "
AssociatedControlID="UserName"
Runat="server" />
<asp:TextBox
id="UserName"
runat="server" />
<br />
<asp:Label
id="lblPassword"
Text="Password: "
AssociatedControlID="Password"
Runat="server" />
<asp:TextBox
id="Password"
runat="server" />
<br />
<br />
<asp:Label
id="lblFirstName"
Text="First Name"
AssociatedControlID="txtFirstName"
Runat="server" />
<asp:TextBox
id="txtFirstName"
runat="server" />
<br />
<asp:Label
id="Label2"
Text="Last Name"
AssociatedControlID="txtLastName"
Runat="server" />
<asp:TextBox
id="txtLastName"
runat="server" />
<br />
<asp:Label
id="Label3"
Text="Email"
AssociatedControlID="Email"
Runat="server" />
<asp:TextBox
id="Email"
runat="server" />
<br /><br />
<asp:Label
id="Label4"
Text="Security Question: "
AssociatedControlID="ddlQuestion"
Runat="server" />
<asp:DropDownList
id="ddlQuestion"
runat="server">
<asp:ListItem
Text="Enter Pet Name"
Value="Pet Name" />
<asp:ListItem
Text="Enter Favorite Color"
Value="Favorite Color" />
</asp:DropDownList>
<br /> <br />
<asp:Label
id="lblAnswer"
Text="Security Answer"
AssociatedControlID="txtAnswer"
runat="server" />
<asp:TextBox
id="txtAnswer"
runat="server" />
<hr />
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
*******************
LOGIN.ASPX |
*******************
Overview:
* Simple login control.
Code:
<script runat="server">
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string userName = Login1.UserName;
string password = Login1.Password;
e.Authenticated = FormsAuthentication.Authenticate(userName, password);
}
</script>
<asp:Login ID="Login1"
runat="server"
OnAuthenticate="Login1_Authenticate"
BackColor="#F7F6F3"
BorderColor="#E6E2D8"
BorderPadding="4"
BorderStyle="Solid"
BorderWidth="1px"
CreateUserText="Register"
CreateUserUrl="~/Register.aspx"
Font-Names="Verdana"
Font-Size="0.8em"
ForeColor="#333333"
Height="200px"
TitleText="Sign In"
Width="415px"
VisibleWhenLoggedIn="False"
MembershipProvider="MyMembership" />