PDA

View Full Version : Contact Form on this site can you send to a registered user?


nanny
10-12-2006, 03:47 AM
Hi I am interested in the contact form on the front of this website. If I have registered users who place listings in my directory, can I use the contact form that allows viewers to send to that registered users email address in my database?

A person registers on my site, then they can add a listing to my directory. In the listing detail page I have a link to their email address ( I use a 'Go To Detail' for the contact form)
Can I use $_rowblah['email'] = $_GET['email'] to send the contact details from the contact form to them?

Thanks hope you get what I mean.

davidj
10-12-2006, 07:41 AM
Thanks hope you get what I mean.

no. confused city. Not sure what your after

nanny
10-12-2006, 08:06 AM
Hi sorry for being confusing.
Using Dreamweaver and PHP to send form results in an email on this website where:
// Your email address. This is where the form information will be sent.
$emailadd = 'mail@rdsnetworks.net';

Instead of sending to my email address I am wanting other people send to an email in my database - the person who has placed the listing(advertisement) on my website.
To get the $emailadd to be the email address in the database is how?
I have the page using $_GET[email'] in the recordset and it shows up when I use the bindings tab and insert the <?php echo $row_blah['email']; ?>
So what I am trying to do is make the <?php echo $row_blah['email']; ?>
as the $emailadd = '<?php echo $row_blah['email']; ?>'


Hope that explains better......its all in my head not coming out to read..
Thanks for your time.

davidj
10-12-2006, 10:42 AM
ok

where you have...

$emailadd = 'mail@rdsnetworks.net';

it will have to be set from your dropdown like this..

$emailadd = $_POST['dropdown'];

you would just dynamicaly create your select options from your database

nanny
10-12-2006, 10:26 PM
I will need to explain a little further as I think you mean I am sorting through a selection of emails in my database.
Thanks I will be able to use this in another area.

But for this one
Page 1: Directory Listing with contact details what they are their web address and email address. I have a conditional to show the words 'Email Us' if they have supplied an email address. The email link is then used as a URL link with the variable being $_GET['regid'].
Page 2: This is the Detail Page where to have the email form that allows the person who clicked on that email link to send that company an enquiry etc.
Page3: This is the confirmation page.

So the email details are shown on Page 2 via using the $_GET['regid'] and that gives me all the details for that particular business.
I know you need to use the $_POST['reg_contactemail'] for the variable but seeing I have used the recordset with $_GET['regid'] for that page - in dreamweaver do I place another recordset with Select* from the database table to then be able to use $_POST['reg_contactemail'] or can I simply put:
$emailadd = $_GET['reg_contactemail'];
from the recordset already there.

Thanks for your replies, I really appreciate it.

davidj
10-13-2006, 07:37 AM
if you passing the email through a URL then $emailadd = $_GET['reg_contactemail']; will work

nanny
10-13-2006, 08:03 AM
Cool!!!
Thanks - everywhere I have read says to send the email to ??? you need to use the $_POST that is why I was so stumped.
I thought gee I am going to have to write a really out there recordset.
Thanks heaps...saves time and extra writing for me....

davidj
10-13-2006, 08:10 AM
your URL should look like this

http://www.domain.com/page.php?reg_contactemail=email@address.com

you are restricted in how long the URL string can be so i would advise against using reg_contactemail as part of your key value pair. It will still work but its not best practice. Try contactemail or even better, mail or RE. It just keeps the size down

remember that your $_GET will have to change accordingly

davidj
10-13-2006, 08:14 AM
As a second thought it maybe better to just pass the id for the address you need then you can do a query using the passed ID and retreive the address that way

nanny
10-13-2006, 08:26 AM
This is the link name coming from a conditional:
<?php if (!empty($row_detailrs['contactemail'])) echo 'Email Us'; ?>

And the URL for this is:
<a href="list.php?classid=<?php echo $row_detailrs['classid']; ?>">

This is where list.php is using the recordset with $_GET['classid'] for the variable. So this is why I can show the email using: <?php echo $row_detailrs2['contactemail']; ?>

So maybe I can't use the $_GET method hey?
It was the best way to hide the email address even in the URL it shows the classid instead. I am trying to keep eyes away from email addresses so that when I do my job board it can be hidden.
Cheers

davidj
10-13-2006, 08:35 AM
you would use a $_GET to catch a URL variable...

http://www.domain.com/page.php?reg=email@address.com

$regVariable = $_GET['reg'];

$regVariable now contains email@address.com

nanny
10-13-2006, 09:02 AM
I don't think it will pass on anything other than the primary key. I tried it but it won't pass to the list.php using the email.
So back to the drawing board, can I set the:
$emailadd = <?php echo $row_detailrs2['contactemail']; ?>

Or have the recordset as:

<?php
$varEmail_detailrs2 = "$emailadd";
if (isset($_GET['contactemail'])) {
$varEmail_detailrs2 = (get_magic_quotes_gpc()) ? $_GET['contactemail'] : addslashes($_GET['contactemail']);
}
$varDetail_detailrs2 = "0";
if (isset($_GET['classid'])) {
$varDetail_detailrs2 = (get_magic_quotes_gpc()) ? $_GET['classid'] : addslashes($_GET['classid']);
}
mysql_select_db($database_config, $config);
$query_detailrs2 = sprintf("SELECT class_ad.classid, class_ad.classbusinessname, class_ad.contactemail FROM class_ad WHERE classid = '%s' AND class_ad.contactemail = '%s'", $varDetail_detailrs2,$varEmail_detailrs2);
$detailrs2 = mysql_query($query_detailrs2, $config) or die(mysql_error());
$row_detailrs2 = mysql_fetch_assoc($detailrs2);
$totalRows_detailrs2 = mysql_num_rows($detailrs2);
?>


And then it will be able to use the $_GET? Is this what you meant?

davidj
10-13-2006, 09:15 AM
I don't think it will pass on anything other than the primary key. I tried it but it won't pass to the list.php using the email.
yes it does. Thats how it works.

check out my example

if page1.php has a link

link (page2.php?email=mail@domain.com)

if you have this...on page2.php

$email = $_GET['email'];

then $email WILL contain mail@domain.com

nanny
10-13-2006, 09:25 AM
OK I will have a little play tomorrow. It's Friday night here in Aussie land so I am going to have a glass of red and come back with a fresh start tomorrow.
Cheers and thanks.

davidj
10-13-2006, 10:50 AM
enjoy your wine

its friday morning here so looking forward to a beer tonight

nanny
10-16-2006, 09:05 AM
Yep! It works. Thank you.
Yeah!!!

davidj
10-16-2006, 03:53 PM
of course it works