Strategies for Creating a Web Classified

Looking for suggestions from experienced developers

Page 1 of 1

1 Replies - 506 Views - Last Post: 13 December 2010 - 06:59 PM

#1 DarkGinger  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 08-December 10

Strategies for Creating a Web Classified

Posted 13 December 2010 - 03:05 PM

Hey folks. New poster here. I really like the site, and it looks like an awesome compilation of programming resources. Here's the deal. I am trying to develop an easy-to-use website for classifieds (thing Craigslist but with a more narrow scope to help college students). I've taken a look at a lot of books (for CSS and HTML and Perl) and I have sort of a vague understanding of a lot of different topics.

I am hoping that someone with experience developing a website can help me synthesize all of this material into one coherent project. I'd love any tips I could get, but I have a few basic questions.

1. What do you need to do to utilize forms => posts on the website

It's a classified, right? So obviously the most important aspect will be the ability of users to post information about their product and have it appear within a specific category.

In my book, it shows you how you can automatically have form entries e-mailed to yourself, but I have no clue how one goes from merely hosting a form to utilizing a form as I explained. Any tips? Is this where databases come into play, and if so, what topics should I look at to make this a reality?

2. How do you create a registration system?

I have found ways to code a log-in section, but I have no idea what it takes to enable users to make accounts and then access those accounts through the website. This might tie into the database question, but what do you need to know to do something like this?

I'm aware that this is sort of a big project and it would be easier to pay someone to help me out, but I'd really like to learn how to develop functional websites, and I figure this is a great place to start.

Is This A Good Question/Topic? 0
  • +

Replies To: Strategies for Creating a Web Classified

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,127
  • Joined: 18-April 07

Re: Strategies for Creating a Web Classified

Posted 13 December 2010 - 06:59 PM

Well how you go about these topics depends on the computer language you want to make the site with. All the server-side languages (PHP, ASP.NET, Coldfusion, Ruby etc) can do forms. All of them use the standard <form> tag you find in any HTML book or website tutorial. How they collect the info submitted in the form and process it are done slightly differently in the way of syntax.

Below is a simple HTML form...

<form method="POST" action="myscript.php" name="my_classified_form">
<input type="text" name="product_title"/>
<input type="submit" name="classified_submit" value="Submit Classified"/>
</form>



This form simply has a textbox and a button. The textbox allows the user to enter the name of the product and a button submits the form content to a PHP script called "myscript.php" for processing the form.

The PHP form then reads in the values from the form and performs different tests, decisions and perhaps entering the data into a database (which relates to your second question about registration).

myscript.php example

if (isset($_POST["classified_submit"])) {
   $title = $_POST["product_title"];

   // Do something with title, insert into a database etc
}



Here we have collected the title submitted through the form and we do something with it. Insert it into a database, write it to a file, check if it is empty and print an error etc. That part is up to you.

This is how your registration will work. A simple form that collects the person's information and a password of their choice. It then inserts that data into a database. When they come to login, we present them with a form that collects their username and password. We use our script to then collect the info, look it up in the database and if the data matches, we redirect them to whatever page we want them to.

logging in example script...
// Read from our form and escape it (to make it safe)
$username = mysql_real_escape($_POST["username"]);
$password = $_POST["password"];

// Use the username to then lookup their password
$results = mysql_query("select password from users_table where username = '$username'");

if ($pass = mysql_fetch_array($results)) {
   if ($password == $pass["password"]) {
      // They match, so they are approved. Setup a session variable or something and redirect user
   } 
   else { 
      // Failed login, send them back to login page
   }
}
else {
  // No record for a user with that username exists, send back to login page
}



We used the username collected from the form to then look for a record in the database that matches. We retrieve the password for that record and compare it to the one supplied in the form. If they match, they are good to go. If not, they failed to login.

This should give you a good start on how to set this system up. Write it up and come back if you have trouble. Show us the code you have so far and we can point out where you might be going wrong.

I hope you get this up and running soon! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1