Home Web Development ASP.NET Online Dating Websites
Online Dating Websites
Not yet rated
Written by TV Mogul   
Friday, 30 January 2009 16:00

Introduction

I had some free time, and decided to create a 100% free dating website www.MatchElf.comwww.MatchElf.com as an experiment to see how long it would take me to write a fully functional, 100% free dating website, and I quickly learned that building a 100% free dating website isn"t that easy.

I started by making a list of the pages and features I would need to create, and also the tables I would need. The most interesting of these features were:

  • Dating dropdowns
  • Dating website layout
  • Security
  • Dating bad words filter
  • Target marketing
  • Dating profile
  • Chat system
  • Dating website database design

For example, I needed to take steps to block against things like certain tags, SQL injection, etc., and I realized that I also needed a "bad words" filter so that users couldn"t post inappropriate words. And, since the website was to be a 100% free dating website, revenues would come from the display of advertising, but that advertising needed to be targeted at each user"s profile. And, a chat system that wouldn"t crash the server was needed.

The dating profile, or the information to be collected voluntarily from a user needed to be carefully researched because it needed to serve two purposes, namely, to assist in matching people with a mate, and to assist in matching people to ads to display to a member based on their profile.

In this article, I will focus on the typical dating website dropdowns for country, state, city, Zip code, and the dropdowns for allowing users to enter their birthday. In a typical dating website, the country dropdown generates the "state/providence" dropdown which, in turn, generates the city dropdown. But there is no need to include states or cities for most countries.

In addition, in the case of a dating website you have the issue of wanting to move the user along quickly through the signup process.

Cognitive Psychology and Dating Website Layouts

Cognitive Psychology was the first "scientific branch" of psychology that examined how sensory input is transformed into beliefs and actions through the process of cognition, as in the case of magazine ads and website layouts. I studied Cognitive Psychology in college and graduate school, and applied it to marketing and to web page design in my companies and my TV shows. One of the more interesting things in Cognitive Psychology is that the more text you have on a page that answers as many questions as possible for a reader, the greater the probability of inducing that reader to take action. This is one of the big mistakes that most dating websites make. In their rush to push a visitor through the signup process, dating websites have almost no text or ad copy on the first landing page or domain page. It turns out that the more ad copy you have answering questions about the dating website, the greater the chances that the visitor will signup.

The Dating Countries Dropdown

I decided to use the ISO 3166-1 alpha-2, i.e., a two-letter system to represent the dating member"s country to be consistent with the 2-letter top-level domains (ccTLDs) representation of countries for latter domain matching. It took some research to determine which countries to include. I finally decided that the United States, Canada, United Kingdom, and Puerto Rico were the countries that most users would belong to, and to only include a short list of other countries. The Countries dropdown is pretty straightforward as seen below.

  • United States
  • United Kingdom
  • Puerto Rico
  • Other Countries

The Dating State, Province, District Dropdown

The fun begins with the "State, Province, District" dropdown which isn"t so simple. If the user selects the "United States", then this needs to generate a list of U.S. states, and if the user selects "Canada", then this needs to generate a list of "Provinces". If the user selects the "United Kingdom", then this needs to generate a list of "Districts", and if the user selects Puerto Rico or any other country, then that would not generate any further choices so the "City" dropdown would be disabled. In the United Kingdom, the districts are very complicated because they have old names and new names for each district, and it took some talking with people from England to figure out which districts to include by which name. The Country dropdown calls a Stored Procedure that passes the 2-letter country code as a parameter, as follows:

    IF( (@country = "US") OR (@country = "CA") OR (@country = "GB") ) 
   BEGIN 
      SELECT StateName, State FROM [MatchElf].[dbo].[CtryStateName] 
      WHERE ([Country] = @country) 
   END 
ELSE 
   SELECT "not applicable"
  

The logic is that if the country isn"t "US" or "CA" or "GB", then we return the phrase "not applicable" that will appear in the States dropdown. The logic is that if the country isn"t "US" or "CA" or "GB", then we return the phrase "not applicable" that will appear in the States dropdown.

The Dating Cities Dropdown

The "Cities" dropdown retrieves a list of cities only if the United States is selected.

    IF (@country = "US") 
   BEGIN 
      SELECT DISTINCT [City] FROM StateCity WHERE [State] = @state 
      ORDER BY [City] 
   END 
ELSE 
   SELECT "not applicable" AS City, "not applicable" AS City
  

The Dating Website Postal Code Textbox

The Zip code or postal code on a dating website is probably the most important single piece of information that a user will enter since it is the value used most often in searching for members within a certain radius of that user"s zip code. I finally decided that it was better to not try and validate the user"s input for their zip code or postal code, but to just add a filter to this textbox to "help" prevent users from inserting undesirable tags like <script>alert("Hello")</script> into this textbox, as follows:

    public static string RemoveBadTags(string html)
{
    Regex oRegex = new Regex(
      "(<script>.*</script>)|(<object>.*</object>)|(<body>.*</body>) | 
     (<embed>.*</embed>)|(<frameset>.*</frameset>)|(<frame>.*</frame>)|
     (<iframe>.*</iframe>)|(<meta>.*</meta>)|(<ling>.*</ling>)|
     (<style>.*</style>)");
    html = oRegex.Replace(html, "");
    return html;
}
  

The Dating Birthday Dropdowns and User"s Age

The birthday dropdowns of Month, Day, and Year, I thought, was better than allowing the user to enter a date for their birthday. But, you need to calculate the person"s age and make sure that the person is not under 18 years of age. As it turns out, to calculate a person"s age is not straightforward, but one way to do this is as follows:

    protected void btnRegister_Click(object sender, EventArgs e)  e) 
{
   string sPostalCode = RemoveBadTags(txtPostalCode.Text); 
   //Calculate potential member"s age. Reject if person is under 18 DateTime 
   dtAge = new DateTime(); 
   int intYR, intMonth, intDay; 
   try
   {
      intYR = Convert.ToInt32(ddYear.Text); 
      intMonth = Convert.ToInt32(ddMonth.Text); 
      intDay = Convert.ToInt32(ddDay.Text); 
      dtAge = new DateTime(intYR, intMonth, intDay); 
      DateTime dtToday = DateTime.Today; 
      //Calculate how many leap years from DOB using 
      //timespan which includes leap yr day as 366 
      int intLeapYear = 0; 
      for (int i = dtAge.Year; i < dtToday.Year; i++) 
      {
         if (DateTime.IsLeapYear(i)) 
         {
            ++intLeapYear; 
         } 
      } 
      TimeSpan ts = dtToday.Subtract(dtAge); 
      intDay = ts.Days - intLeapYear; 
      //substracting leap year 
      int intResult = 0; 
      intYR = Math.DivRem(intDay, 365, out intResult); 
      //Year taken as 365 days 
      if (intYR < 18) 
      { 
         LABEL_Birthday.ForeColor = System.Drawing.Color.Red; 
         LABEL_Birthday.Text = "You must be 18 or older"; 
         return; 
      } 
   } 
   catch (Exception ex) 
   { 
      LABEL_Birthday.ForeColor = System.Drawing.Color.Red; 
      LABEL_Birthday.Text = "You must be 18 or older"; return; 
   } 
}
  

The Dating Bad Words Filter

Another thing I encountered was the need for a "Bad Words Filter" which I added that is included in the sample project. It"s pretty straight forward and you can add your own idea of "bad words" to the xml list of "bad" words I created. I added this list of inappropriate words to a static ArrayList and checked that list as as follows:

    public string BadWordsFilter(string sBadString)
{
   Regex r = default(Regex);
   string str = string.Empty;
   IEnumerator eWords = arrayListBad.GetEnumerator();
   while (eWords.MoveNext())
   {
      r = new Regex("\b" + eWords.Current.ToString());
      sBadString = r.Replace(sBadString, "****");
   }
   return sBadString;
} 

  

Summary

You can, of course, place these dropdowns on an AJAX panel. The sample with this article includes the full tables for states/cities. If you have any questions, please feel free to contact me at: This e-mail address is being protected from spambots. You need JavaScript enabled to view it

public

Something wrong with this article? Report it
0 Comments

Write comment
You must be logged in to a comment. Please register if you do not have an account yet.

busy
Last Updated on Friday, 06 February 2009 16:00