Form - contact user - mail

Hope someone can help!
I have a contact list from mysql, showing the following items:
id, surname, country, county, dates, details, together with a link - “email Contact”

<a href="contactform.php?id=<?=$row['id']?>">Email Contact</a>

I want this to goto a form - “contactform”, where they input their email [emailer] and their message [emailermessage]. Then on submit the form is checked for validity (Email), it then gets mailed to the original user [id], copy to the [emailer], BCC to admin, togther with a subject “a user has found a link to your wanted name”. This includes the original details - surname, country, county, dates, details , with another this user message [emailermessage].
I believe that the variable [id], will have to be passed through the contactform, then onto being processed and sent (mail)!

Can someone give me some help on this please,
Thanks a lot,

First off give this a whirl and if you get it you should have a good jump on what you need.

On the contactform.php page you will simply need to use something like:

$id = $_GET['id'];

Then once you have the id you can just query the database table for all the information that belongs with this id. For example:

$q = "SELECT * FROM my_table WHERE id = $id"; $r = mysql_query($q) or die("Error 001: " . mysql_error());

and so on and so forth. I recommend getting this done and working then working on the mail part next. Just let us know when you get stuck on the mail stuff. Check this out for more help with the mail part.

Thanks for that, but I have most of it, but as the link goes to a form, that the user enters his email and message, then processes to a “eprocess.php”, to validate and send the mail!

So I am stuck getting the [id], through the “contactform” to the “eprocess.php” form. (maybe I could do it thro the same form?)

Then I am also stuck on a few bits with the email! Here is some code what has been hashed together (so it is not valid yet!).
Email Contact links to this form:

<form name="eprocess" method="post" action="">
Your Email Address:<input name="emailer" type="text" value="your email"
Your Message to user:<textarea name="emailermessage" id="emailermessage"></textarea>
<label>Submit<input type="submit" name="Submit" value="Submit
<input name="Reset" type="reset" id="Reset" value="Reset">
Reset </label>

From there it goes to this “eprocess.php”

// Check if the form was submitted

// Get date/time
$date = date("y-m-d H:i:s");

// Get the subject from the form
$emaileradd = $_POST['emailer'];
$messageadd = $_POST['emailermessage'];

// Creating header information
$headers  = "From: admin <[email protected]>n";
$headers .= "Bcc: admin <[email protected]>n";
$headers .= "Copy: $emaileradd n"; // is this CORRECT?

// message to original user id
A member user is wanting further information on your wanted name
    surname:     ".$surname."
    country:     ".$country."
    county:     ".$county."
    catergory:  ".$catergory."
    dates:         ".$dates."
    details:     ".$details."
    email:         ".$email."
    date:         ".$date."
// message to user emailer
Thankyou for contacting the user. A copy of the message for your records is listed below:

        Surname:     ".$surname."
        Country:     ".$country."
        County:     ".$county."
        Catergory:  ".$catergory."
        Dates:         ".$dates."
        Details:     ".$details."
        Your email: ".$email."

// Retrieving the user?s data from the database
$query = mysql_query("SELECT * FROM wanted WHERE ID = '" . $_POST['id'] . "'");
while($row = mysql_fetch_array($query)){

// Making the user email address (to send to)
$to = $row['surname'] . " <" . $row['email'] . ">";

// Making the header 'Reply-To'
$headers .= "Reply-To: " . $row['surname'] . " <" . $row['email'] . ">n";


// Finishing the header
$headers .= "X-Mailer: PHP/" . phpversion();

// Send email - NEED TO ADD $messageuseradd and $messageadd
$mail = mail($to, $subject . ' - ' . $date, $messageadd, $headers);

// Prints a message depending on the sent email status
$mail ? echo 'Email sent !' : echo 'Error sending email !';



So I need to either make the whole thing 1 form (how to do that?) and to sort out the mail side. Sorry as you may see I amm a novice at this!!

If I understand the problem correctly I guess what I would do is make a hidden field and fill it with the information that you want passed from form to form.

For Example:

<input type="hidden" name="id" value="<?=$_GET['id'];?>">

//Then when you get to the other form just create somethin like:

<input type="hidden" name="id" value="<?=$_POST['id'];?>">

That will fill the hidden fields with the information you need to pass from form to form.

So when the link is clicked on the listing, then comes to the contact form the following will get the [id]?:

This will then carry it to the eprocess.php, where I can get the value by:


Sponsor our Newsletter | Privacy Policy | Terms of Service