Skip to main content
Known Participant
September 24, 2009
Question

How do I set up an internal mail system to users?

  • September 24, 2009
  • 1 reply
  • 384 views

I am new to building sites and just purchased David's book on DW CS4.  I have set up a database/users.  I was having trouble getting the user log in to access a user only page, but I think, reading the book, that I can do that using sessions...is that the best way?  Also, I would like my users to be able to send message to other users without directly(seeing) the other users email address.  How/can this be done?  Thanks.

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
September 24, 2009

Rick4209 wrote:

I am new to building sites and just purchased David's book on DW CS4.

Thank you.

I was having trouble getting the user log in to access a user only page, but I think, reading the book, that I can do that using sessions...is that the best way?

Yes. Details of restricting access to users-only pages are in Ch 15.

I would like my users to be able to send message to other users without directly(seeing) the other users email address.  How/can this be done?

It's almost exactly the same as the contact form example in Ch 11. Instead of hard-coding the value of $to, get it from a dynamic drop-down menu see page 707 onwards. The example of the dynamic drop-down menu in Ch 16 displays authors' names and uses their associated primary key as the value. For the contact form, display the other members' names, but use the email address as the value.

Of course, anyone would be able to see the email address by right-clicking and viewing the source code. If you want to prevent that, use the members' primary keys as the values. Then, in the background, use a recordset to retrieve the email address of the selected member. If you're new to all this, it might sound complicated, but it's a simple logical process.

Let's say the dynamic drop-down menu lists members' names and stores each member's primary key as the value. If the name of the drop-down menu is "member", when the form is submitted, your script needs to use a recordset that selects the email address using the Form Variable "member" ($_POST['member']). There will be only one result, so you can assign the value of $to like this:

$to = $row_recordsetName['email'];

Of course, the recordset needs to come before you call the mail() function. In pseudo-code:

if (the form has been submitted) {

  get the email address from the database

  process the rest of the form

  send the email

}