login.aspx
<table>
<tr>
<td colspan="2">
Login With
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#CC0000"></asp: Label>
</td>
</tr>
<tr>
<td>
Email ID :
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="TextBox1"> </asp:RequiredFieldValidator>
<asp: RegularExpressionValidator ID=" RegularExpressionValidator1" runat="server" ErrorMessage="*"
ControlToValidate="TextBox1" ValidationExpression="\w+([-+. ']\w+)*@\w+([-.]\w+)*\.\w+([-. ]\w+)*"></asp: RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp: TextBox>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<img height="30" alt="" src="Turing.aspx" width="80">
</td>
<td>
<asp:TextBox ID="txtTuring" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="txtTuring" ></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="Button1" runat="server" Text="Login" OnClick="Button1_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<a href="">Forgot Login Details? </a>
</td>
</tr>
</table>
login.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class jobseekerLogin : System.Web.UI.Page
{
SqlConnection con = new SqlConnection( ConfigurationManager. ConnectionStrings["conn"]. ToString());
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid && (txtTuring.Text == Session["randomStr"].ToString( )))
{
con.Open();
string str = "Select * from Tbl_user where Email='" + TextBox1.Text + "' and pass='" + TextBox2.Text + "'";
SqlDataAdapter adp = new SqlDataAdapter(str, con);
DataTable tb = new DataTable();
adp.Fill(tb);
if (tb.Rows.Count > 0)
{
Session["username"] = TextBox1.Text;
TextBox2.Text = "";
Response.Redirect(" jobseekerAccount.aspx");
}
else
{
Label1.Text = "Password Is Not Match ";
TextBox2.Text = "";
}
con.Close();
}
else
{
Label1.Text = "Please enter info correctly";
TextBox2.Text = "";
}
}
}
Turing.aspx
Turing.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Xml.Linq;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.Web.SessionState;
public partial class Turing : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bitmap objBMP = new System.Drawing.Bitmap(60, 20);
Graphics objGraphics = System.Drawing.Graphics. FromImage(objBMP);
objGraphics.Clear(Color. Green);
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//' Configure font to use for text
Font objFont = new Font("Arial", 8, FontStyle.Bold);
string randomStr = "";
int[] myIntArray = new int[5];
int x;
//That is to create the random # and add it to our string
Random autoRand = new Random();
for (x = 0; x < 5; x++)
{
myIntArray[x] = System.Convert.ToInt32( autoRand.Next(0, 9));
randomStr += (myIntArray[x].ToString());
}
//This is to add the string to session cookie, to be compared later
Session.Add("randomStr", randomStr);
//' Write out the text
objGraphics.DrawString( randomStr, objFont, Brushes.White, 3, 3);
//' Set the content type and return the image
Response.ContentType = "image/GIF";
objBMP.Save(Response. OutputStream, ImageFormat.Gif);
objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();
}
}
No comments :
Post a Comment