Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 03-04-2005, 07:14 AM   #1 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
Question Craigslist Anonymous Email Relay with PHP & MySQL?

I have a guestbook application that uses a webform to enter into a MySQL database.

The entries from that database are displayed on another page, sort of like a guest book or bulletin board.

What I would like to do is instead of having their real email listed, I would like to assign them a temporary email that will forward to their real address, so that the initial responder does not see the real email address, i.e. my email would be changed to tab123456@domainname.com and when anyone sends email to that address, it is looked up in the db and then email is sent to the correct address. Does that make any sense?

This is exactly what http://www.craigslist.org does, and I have been looking all over for a script or an application or anything that will do that and I have had no luck. The closest I have found is a form on a website that will send email aa hidden email address based on an id.

Anyhelp would be much appreciated!
oc_earthling is offline   Reply With Quote
Old 03-04-2005, 08:11 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
seems like more of a job for a mail server rather than php/mysql. i don't know how php/mysql would receive the initial email.
__________________
Mike
sde is online now   Reply With Quote
Old 03-04-2005, 08:27 AM   #3 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
Arrow

Hmm, yes I was wondering if that would be the case, if so, then I maybe able to do this as an alternative, but I am not sure how:

From the website, a visitor could click on the email link which will bring up a form that does not contain the actual email, but the id, and then forwards it to this person. I know this can be done, becasue I have seen a similar application, but it used a flat text file instead of a database, and I need it to pull from the database. Here was the example, I just need help in modifying it:

http://www.theadultbroker.com/php_mailscript/index.php
oc_earthling is offline   Reply With Quote
Old 03-04-2005, 08:35 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
yes, now that would completely work with a web form. do you need help to implement this? the logic would go something like this: ( haven't tested the code )
PHP Code:
<?
if($_POST['submit']){
  
$result mysql_query("select email from users where id=".$_POST['id']);
  if(
$row mysql_fetch_array($result)){
    
mail($row[0], $_POST['subject'], $_POST['message'], "From: ".$_POST['from']);
    echo 
"Email Sent";
  }else{
    echo 
"Email Failed";
  }
}else{
?>
<form method=post action=<?=$_SERVER['PHP_SELF']?>>
<input type=hidden name=id value=552>
From: <input type=text name=from><br>
Subject:<input type=text name=subject><br>
Message:<textarea name=message></textarea><br>
<input type=submit name=submit value=send>
</form>
<?
}
?>
__________________
Mike
sde is online now   Reply With Quote
Old 03-04-2005, 08:39 AM   #5 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
Arrow

Thank you thank you soo much! I will try that and see if I can make it work!
oc_earthling is offline   Reply With Quote
Old 03-04-2005, 03:14 PM   #6 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
Ahhhhhhhhhhhhhhhhhhhh I am going to pullout all of my hair! Can you help implement this, how much would you charge?
oc_earthling is offline   Reply With Quote
Old 03-04-2005, 03:41 PM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
eleventy-billion dollars .. what is wrong? show me what you got, errors, and tell me what it is or isn't doing.
__________________
Mike
sde is online now   Reply With Quote
Old 03-04-2005, 03:57 PM   #8 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
I have a page that retrieves a single record from the MySQL database based on a URL string query, assigns a variable to each field, and displays the results of each variable and this works:

PHP Code:
<?php
include 'config.php';
include 
'opendb.php';

$query  "SELECT id, name, email, message FROM guestbook WHERE id = '$searchid'";
$result mysql_query($query);

while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
{
    
$id =           ("{$row['id']}");
   
$name =       ("{$row['name']}");
    
$email =       ("{$row['email']}"); 
    
$message =   ("{$row['message']}");

echo 
"$id<BR>";
echo 
"$name<BR>";
echo 
"$message<BR>";
echo 
"$email<BR>";

include 
'closedb.php';
?> 

BUT... if I add anything else to it, like the part of a form, it doesn't retain the variable information....only what was in the original querystring....

<?php
include 'config.php';
include 
'opendb.php';

$query  "SELECT id, name, email, message FROM guestbook WHERE id = '$searchid'";
$result mysql_query($query);

while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
{        
    
$id =          ("{$row['id']}");
    
$name =     ("{$row['name']}");
    
$email =      ("{$row['email']}"); 
    
$message = ("{$row['message']}");
            
print(
"<h2>Send an e-mail to ");
echo (
"$name</h2>");
echo (
"<form  name=\"form1\" method=\"POST\" action=\"contactmesent_old.php\">");
echo (
"<input type=\"hidden\" name=\"searchid\" value=\"$searchid");

blah blah blah more form info.....

include 
'closedb.php';
}
?>
and contactmesent_old.php would contain the mail command, along with the information from this form, which I haven't even gotten to, but the idea is to have an email submit form where the email address is hidden from the user.

Am doing this totally wrong or what? Any help or pointing in the right direction would be sooo much appreciated!
oc_earthling is offline   Reply With Quote
Old 03-04-2005, 04:13 PM   #9 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
maybe this ..
PHP Code:
<?php
include 'config.php';
include 
'opendb.php';

// if the form has not been posted, print the form
if(!$_POST){

  
$query  "SELECT id, name, email, message FROM guestbook WHERE id = '".$searchid."'";
  
$result mysql_query($query);
  
  
// since we're only getting 1 row, we can use 'if' instead of 'while'
  
if($row mysql_fetch_assoc($result))
  {        
      
$id =$row['id'];
      
$name $row['name'];
      
$email $row['email'];
      
$message $row['message'];
              
    echo 
"<h2>Send an e-mail to ".$name."</h2>
      <form  name=\"form1\" method=\"POST\" action=\"contactmesent_old.php\">
      <input type=\"hidden\" name=\"searchid\" value=\""
.$searchid."\">
      Your Email: <input type=\"text\" name=\"from\"><br>
      Subject: <input type=\"text\" name=\"subject\"><br>
      Message: <textarea name=\"message\"></textarea><input type=\"submit\" value=\"send\">
      </form>"
;
  }else{
    echo 
"error: id not found";
  }
  
}else{
  
// send email and say thank you
  
$result mysql_query("SELECT id, name, email, message FROM guestbook WHERE id = '".$_POST['searchid']."'");
  if(
$row mysql_fetch_assoc($result)){
    
mail($row['email'], $_POST['subject'], $_POST['message'], "From: ".$_POST['from']);
    echo 
"Thank You, Your email as been sent";
  }else{
    echo 
"Error: Invlid User ID";
  } 
}

mysql_close();
?>
__________________
Mike
sde is online now   Reply With Quote
Old 03-04-2005, 04:26 PM   #10 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
OMG! I LOVE YOU! I just changed one thing, to post to itself and it worked! OMG YOU ARE A GENIUS! What can I do to repay you?!?!?!

xoxoxoxoxoxoxo
oc_earthling is offline   Reply With Quote
Old 03-04-2005, 07:26 PM   #11 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
you're not too far, .. how about leave an ice cold six pack of heineken on my porch for when i get home from work monday. .. j/k, .. just visit more or tell people about our community.

i'm glad it works, happy to help.
__________________
Mike
sde is online now   Reply With Quote
Old 03-05-2005, 08:10 AM   #12 (permalink)
oc_earthling
If I Only Had a Brain
 
Join Date: Mar 2005
Location: Orange County, CA
Posts: 7
oc_earthling is on a distinguished road
Send a message via ICQ to oc_earthling Send a message via AIM to oc_earthling Send a message via Yahoo to oc_earthling
You bet! This is my new favorite second home!
oc_earthling is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
WML PHP and MySQL rmill9681 PHP 10 11-20-2004 12:59 PM
Simple PHP MySQL code: confused. easilyi Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 4 10-24-2004 07:53 PM
cant connect to mysql databases using php eran PHP 11 08-07-2004 08:02 AM
Help with setting up mySQL and PHP Ilya020 PHP 11 03-19-2003 05:10 AM
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 5 07-07-2002 09:54 AM


All times are GMT -8. The time now is 02:22 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting