Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Setting up a PHP classifeds page

Featured Replies

Hey all I'm wanting to set up a classifeds page on my website somewhat like ebay like a person uploads a image and puts in their information they want to add and after hitting submit it loads it to the classifeds page

 

can anyone lead me in a possible direction to get started? tried using google but have'nt found much help except for custom made classifed pages but these could'nt be edited design wise to match the site

Hey all I'm wanting to set up a classifeds page on my website somewhat like ebay like a person uploads a image and puts in their information they want to add and after hitting submit it loads it to the classifeds page

 

can anyone lead me in a possible direction to get started? tried using google but have'nt found much help except for custom made classifed pages but these could'nt be edited design wise to match the site

Hi i wrote a classifieds script when i was just learning php i found a link to a forum tutorial and addapted it

 

http://www.chipmunk-scripts.com/board/inde...=43&ID=9268

 

if you do this tutorial then you will have a lot of work done for you

 

you will need to add file field for uploading an image tutorial here

 

http://www.developer.com/lang/php/print.php/1456041

 

then you will need to change the CSS to the layout you like this is just a basic classifieds page but it will get you on the way to learning the basics of PHP as well

 

make sure you have a folder on your server called tmp_name as this is where the images are stored when first uploaded that was a mistake i made when i first tried it

 

good luck

Hi i wrote a classifieds script when i was just learning php i found a link to a forum tutorial and addapted it

 

http://www.chipmunk-scripts.com/board/inde...=43&ID=9268

 

if you do this tutorial then you will have a lot of work done for you

 

you will need to add file field for uploading an image tutorial here

 

http://www.developer.com/lang/php/print.php/1456041

 

then you will need to change the CSS to the layout you like this is just a basic classifieds page but it will get you on the way to learning the basics of PHP as well

 

make sure you have a folder on your server called tmp_name as this is where the images are stored when first uploaded that was a mistake i made when i first tried it

 

good luck

 

i forgot to mention that when you wish to display an image from the databace you need to upload the root of the image into a varchar column in the databace

 

eg if you are uploading the image into a folder called uploads then when the image is uploaded you need to upload the name of the folder and the name of the image into the databace

 

eg images/my.jpg

 

then when you are displaying the image with a while loop and the image src need to be

 

eg <img src=\"$row[image]">

 

try it for your self if you get stuck pm me i will send you a copy of an upload sccript that will display the image for you as well

  • Author

thanks for that I'll try it out and see how it goes and let ya know

I own a classified ads site that im developing from scratch, let me know if you get stuck and I'l give you a hand. One thing i will say is that you need to make sure that you check all the variables in the uploaded image because I have found that people will try and upload all sorts of stuff from plain text to pdf files.

 

A classified site is just like any other site that grabs data from a database, its no difference at all.

  • Author

Well ran into a problem in index and had some code errors as seen here but some of it seems to have worked as I see some post text there as well

 

Warning: include(connect.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/PHP/index.php on line 3

 

Warning: include(connect.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/PHP/index.php on line 3

 

Warning: include() [function.include]: Failed opening 'connect.php' for inclusion (include_path='.:/usr/share/php') in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/PHP/index.php on line 3

New Topic

Topic Topic Starter Replies Last replied time

 

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13) in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/PHP/index.php on line 15

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/PHP/index.php on line 15

Could not get threads

Hi

 

It looks like you havent created a connect.php file. if you create connect.php file with the following code in it , you should be ok.

 

<?php



$db = mysql_connect("localhost", "username", "password") or die("Could not connect.");

if(!$db) 

die("no db");

if(!mysql_select_db("database_name",$db))

	die("No database selected.");

if(!get_magic_quotes_gpc())

{

 $_GET = array_map('mysql_real_escape_string', $_GET); 

 $_POST = array_map('mysql_real_escape_string', $_POST); 

 $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);

}

else

{  

  $_GET = array_map('stripslashes', $_GET); 

  $_POST = array_map('stripslashes', $_POST); 

  $_COOKIE = array_map('stripslashes', $_COOKIE);

  $_GET = array_map('mysql_real_escape_string', $_GET); 

  $_POST = array_map('mysql_real_escape_string', $_POST); 

  $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);

}



?>

 

Just insert your username password etc in the bit of code below

 

$db = mysql_connect("localhost", "username", "password")

 

Pat

  • Author

got it working but have another problem after I post a message it says could not post message

  • Author

Ok I have sorted out the forum problems just still confused on the image uploading aside from the PHP do I need to get it working?

  • Author

Ok most of it I have working at the moment just a few bugs to work out thanks to all how've helped just wondering though if I can find a tutorial for sommething to set up a database for emails so I can send newsletters out in a mailing list plus make sure noone can add their email more than once

You could use something like PHPmyAdmin to setup your database.

 

Im assuming you have a local setup, but if thats not the case im sure your live server will have something setup for this.

 

Basically you need to create a new database, i dont know give it a name - be creative. You could call it "classifieds"! genius. lol

 

Actually I will do this in bullet form.

 

  • PHPMyAdmin
  • Create new database
  • add new user with all privelages to database (default is root and password is blank, but you can make your own)
  • add a new table to the database, i dont know call it "mailingList"
  • you will need 2 fields in this table, one called "id" make it an int or tiny_int and the other will be "email" make that a varchar and limit it's length to 255 or something logical
  • Make the "id" field the primary key and make sure you set it to auto increment.
  • database is ready!

 

So now you need some PHP code to make it all happen. I assume you will have a form on your classified page for people to submit their email address. Okie so here goes...

 

Your html form

<form action="subscribe.php" method="post">
<fieldset> ------- reason for fieldset is its XHTML Strict, you dont need this if your using transitional doctype
<input type="text" name="email" />
<input type="submit" />
</fieldset>
</form>

 

subscribe.php - the page that sends the info to the database

<?php
// Connect to your database here - you already know how to do that, so lets skip the obvious
// Grab the user submitted value
$email = $_POST['email'];
// Check if they already exist
$query = ("SELECT email from mailingList WHERE email = `$email`");					 
$result= mysql_query($query);
// If we got a result, then they are already there - so we let them know, they are idiots.
if($result == true)
{
echo "You are already in our database.";
}
// If they are not, we add their email to the database and let them know memory serves them well.
else
{

$query = sprintf("insert into classified set  email = '$email'", mysql_real_escape_string($email));					 
$result= mysql_query($query);

if($result)
{
	echo "You have now been added to our mailing list.";
}
else
{
	echo "There was a problem.";
}

}
?>

 

That's some basic PHP and should hopefully see you on the right road.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.