Posting Ad while E-mailing Ad

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
help
Forum Newbie
Posts: 3
Joined: Wed May 18, 2005 1:02 pm

Posting Ad while E-mailing Ad

Post by help »

Hi,

I've own a Classified Ad Script (Custom made). When someone makes a new ad, I want it to e-mail it to me. The Code right now is only setup to Post it. I want it to Post it and E-mail it at the same time.

Here is the code for the New Ad:

Code: Select all

<?php
require('header.php');
//If you're not logged in...
if($user->name == '')
{
	echo 'Sorry, you must be logged in to post an ad...';
	require('footer.php');
	die('');
}

//If you're trying to post a new ad
if(isset($_POST['NewAd']))
{
	//Create the CAd object, and create the ad
	$ad = new CAd($sql);
	var_dump($_POST);
	var_dump($_FILES);
	if($ad->NewAd($user->ID, $_POST['title'], ((isset($_POST['image_l']) && $_POST['image_l'] != '') ? $_POST['image_l'] : $_FILES['image_f']), $_POST['category'], $_POST['price'], nl2br($_POST['info']), $_POST['location']))
		echo '<script language="JavaScript">alert("Success. Your ad has been placed.");</script>';
}

//If you're trying to delete an ad
if(isset($_POST['DeleteAd']))
{
	//Create the CAd object, and load the data
	$ad = new CAd($sql);
	$ad->LoadAd($_GET['Edit']);
	
	//If someone thinks they're really smart and tries to fake the HTTP POST transmission, we'll stop 'em... again...
	if($ad->owner != $user->ID)
		die('Hacking Attempt. The site owner has been notified. Further attempts will result in banning.');
	
	//Delete ad and display success message
	$ad->DeleteAd();
	echo '<script language="JavaScript">alert("Success. Your ad has been deleted.");location="register.php";</script>';
}

//If you're trying to edit an ad
if(isset($_POST['EditAd']))
{
	//Create the CAd object, and load the data
	$ad = new CAd($sql);
	$ad->LoadAd($_GET['Edit']);
	
	//If someone thinks they're really smart and tries to fake the HTTP POST transmission, we'll stop 'em... again...
	if($ad->owner != $user->ID)
		die('Hacking Attempt. The site owner has been notified. Further attempts will result in banning.');
	
	//Edit ad and display success message
	if($ad->EditAd($_POST['title'], $_POST['price'], $_POST['info'], $_POST['category']))
		echo '<script language="JavaScript">alert("Success. Your ad has been edited.");location="register.php";</script>';
}

//Display edit ad
if(isset($_GET['Edit']))
{
	$ad = new CAd($sql);
	$ad->LoadAd($_GET['Edit']);
	
	//If someone thinks they're smart and they'll simply change the value in the URL... Terminate page execution with a nasty message
	if($ad->owner != $user->ID)
		die('Hacking Attempt. The site owner has been notified. Further attempts will result in banning.');
		
	echo $ad->OutputEditAd();
}
//Display create ad
else
{
	$ad = new CAd($sql);
	echo $ad->OutputNewAd();
}

require('footer.php');
?>

I'm also needing it to add 5 Checkmark Boxes under the text boxes that are already in the code - Just in the New Ad, don't need them in the Edit Ad.

If anyone can point me in the correct direction or give me directions on how to do any of this, it will be greatly appreciated.

THANKS! :)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

look into mail() you should.

put some kind of mail() function on your page or in your CAd class you should.

to add checkboxes: want to add them to your class do you or just to the page? If the former it is, need to see the class we do.
help
Forum Newbie
Posts: 3
Joined: Wed May 18, 2005 1:02 pm

Post by help »

Thanks for the reply. I'll take a look at the mail() function.

For the checkboxes, I would like them to be e-mailed to me; but without them being posted.

Thanks again! :)
help
Forum Newbie
Posts: 3
Joined: Wed May 18, 2005 1:02 pm

Post by help »

I've made the mail() Code and it works perfect.

How would I go about making the check boxes?

Thanks! :)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

want the check boxes added to your email you do, therefore using html email you will be required. Research the headers needed for html with mail() you should.

processing anything will these checkboxes be?

if so, better served you would be including a link in your email to a web page that includes the checkboxes that can process stuff.
Post Reply