waako
14-10-2007, 04:04 PM
Hello All,
I've been writing a ASP.NET page to act as a signup form, it emails the details to an email address.
The server doesn't support PHP, otherwise it would be fairly easy for me. I am completely incompetent in ASP or .NET, so I'd be so very grateful if you had a moment to look at my mess and tell me what is wrong with it... thank you ever so much!
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="UTF-8" %>
<script language="c#" runat="server">
MailMessage email = new MailMessage();
string user;
string password;
string server;
user = ConfigurationSettings.AppSettings["email@t5m"];
password = ConfigurationSettings.AppSettings["password"];
server = ConfigurationSettings.AppSettings["smtp.server.net"];
email.From = tbEmail.Text;
email.To = "registrations@t5m.com";
email.Subject = "T5M.com registration";
email.BodyFormat = MailFormat.Html;
email.Body = "<html>"
+ "<head>"
+ "<meta http-equiv="Content-Language" content="fr">"
+ "<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">"
+ "</head>"
+ "<body>"
+ "<p>T5M.com Registration</p>"
+ "<p>Name:" Name.text "</p>"
+ "<p>Email:" Email.text "</p>"
+ "<p>Age:" Age.text "</p>"
+ "<p>Sex:" Sex.SelectedItem.Text "</p>"
+ "<p>Location:" Location.SelectedItem.Text "</p>"
+ "<p>My Favourite Thing:" FavouriteThing.Text
+ "</body>"
+ "</html>";
SmtpMail.SmtpServer = server;
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user);
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
try {
SmtpMail.Send(email);
} catch (Exception ex) {
lblErreur.Text = ex.Message;
}
</script>
<!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>T5M - Signup Page</title>
</head>
<body>
<asp:panel id="SignupPage" runat="server">
<form runat="server">
<asp:label id="confirmation" runat="server" /><br>
Name
<asp:textbox id="Name" runat="server"/><br>
Email
<asp:textbox id="Email" runat="server"/><br>
Age
<asp:textbox id="Age" runat="server"/><br>
Sex
<asp:RadioButtonList id="Sex" runat="server">
<asp:ListItem Selected="true">Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList><br>
Location
<asp:DropDownList id="Location" runat="server">
<asp:ListItem>Australia</asp:ListItem>
</asp:DropDownList><br />
Tell us what your favourite thing on the internet is
<asp:textbox id="FavouriteThing" TextMode="MultiLine" Columns="27" Rows="5" runat="server" /><br />
<asp:button Text="Sign Up!" OnClick="submit" runat="server"/>
</form>
</body>
</html>
I've been writing a ASP.NET page to act as a signup form, it emails the details to an email address.
The server doesn't support PHP, otherwise it would be fairly easy for me. I am completely incompetent in ASP or .NET, so I'd be so very grateful if you had a moment to look at my mess and tell me what is wrong with it... thank you ever so much!
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="UTF-8" %>
<script language="c#" runat="server">
MailMessage email = new MailMessage();
string user;
string password;
string server;
user = ConfigurationSettings.AppSettings["email@t5m"];
password = ConfigurationSettings.AppSettings["password"];
server = ConfigurationSettings.AppSettings["smtp.server.net"];
email.From = tbEmail.Text;
email.To = "registrations@t5m.com";
email.Subject = "T5M.com registration";
email.BodyFormat = MailFormat.Html;
email.Body = "<html>"
+ "<head>"
+ "<meta http-equiv="Content-Language" content="fr">"
+ "<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">"
+ "</head>"
+ "<body>"
+ "<p>T5M.com Registration</p>"
+ "<p>Name:" Name.text "</p>"
+ "<p>Email:" Email.text "</p>"
+ "<p>Age:" Age.text "</p>"
+ "<p>Sex:" Sex.SelectedItem.Text "</p>"
+ "<p>Location:" Location.SelectedItem.Text "</p>"
+ "<p>My Favourite Thing:" FavouriteThing.Text
+ "</body>"
+ "</html>";
SmtpMail.SmtpServer = server;
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user);
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
try {
SmtpMail.Send(email);
} catch (Exception ex) {
lblErreur.Text = ex.Message;
}
</script>
<!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>T5M - Signup Page</title>
</head>
<body>
<asp:panel id="SignupPage" runat="server">
<form runat="server">
<asp:label id="confirmation" runat="server" /><br>
Name
<asp:textbox id="Name" runat="server"/><br>
<asp:textbox id="Email" runat="server"/><br>
Age
<asp:textbox id="Age" runat="server"/><br>
Sex
<asp:RadioButtonList id="Sex" runat="server">
<asp:ListItem Selected="true">Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList><br>
Location
<asp:DropDownList id="Location" runat="server">
<asp:ListItem>Australia</asp:ListItem>
</asp:DropDownList><br />
Tell us what your favourite thing on the internet is
<asp:textbox id="FavouriteThing" TextMode="MultiLine" Columns="27" Rows="5" runat="server" /><br />
<asp:button Text="Sign Up!" OnClick="submit" runat="server"/>
</form>
</body>
</html>