#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    33
    Rep Power
    15
    Hi I have a data base where visitors can sell their car. Their email address is collected and included in the mysql database and their email address is visible as a mailto link on the page when viewing their car. What I would like to know is if it is possible to have a link that when clicks and pops a form that can then have details sent to the advert owner without anyone ever seeing the email address?

    If so is there an easy way?

    Iain
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Aalborg, Denmark
    Posts
    36
    Rep Power
    15
    Hi

    There is a very easy way to do just that.

    You can use the php mail() command (check php.net for documentation).

    I'm sure you have some sort of idnumber in your db (eg your primary key). If you can make the link look something like this:
    <a href="mailpage.php?mailid=<idnumber>">mail this person</a>

    mailpage.php should have the following:

    $mailSubject = "Iain previously owned cars";
    $mailBody = "We've found a buyer for your car";
    $mailHeaders = "From: some name <some@email.com>";

    and now the interesting bit:
    $result = db_query("SELECT emailfield FROM emaildb WHERE emailid=mailid");
    if($row = db_fetch_array($result)) {
    $mailTo = $row["emailfield"];
    }
    mail($mailTo, $mailSubject, mailBody, mailHeaders);

    Hope this helps you. Btw; it's a good idea to keep your db functions/info in a db abstraction layer. That way you can use the same functions no matter if your db is mysql or oracle or something else.

    An example is the function db_fetch_array i used here. In my db layer i have the function:
    function db_fetch_array($id) {
    return mysql_fetch_array($id);
    }

    Regards

    // Martin
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    33
    Rep Power
    15
    Thanks Martin I will give that a try!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    33
    Rep Power
    15
    Help

    Hi Martin

    I am a newbie to this and am getting lost. I have a database (mysql) called carsale in that I have a table called owner, with a unique id and row 13 is the email field. I managed to call up the correct unique id but cannot get the mailpage to send.

    I know this is painful I am going to invest in a php book! Is it also possible to pop text box for the reply to add comments?

    Thanks again

    Iain

Similar Threads

  1. inserting multiple email address from a textarea
    By mrkgrav in forum PHP Development
    Replies: 17
    Last Post: September 24th, 2004, 06:28 PM
  2. Regular Expression for multiple email address
    By L John in forum HTML Programming
    Replies: 2
    Last Post: January 29th, 2004, 06:41 AM
  3. HTML: submitting forms to hidden email address?
    By kitiwiti in forum Beginner Programming
    Replies: 4
    Last Post: December 21st, 2003, 09:17 PM
  4. need email address from submitted html email form
    By fallen8ngel in forum PHP Development
    Replies: 4
    Last Post: November 22nd, 2003, 03:11 AM
  5. breaking up an email address from a DB
    By Fife Club in forum MySQL Help
    Replies: 2
    Last Post: November 17th, 2003, 10:53 PM

IMN logo majestic logo threadwatch logo seochat tools logo