I have a user profile system for my website and each user has their dedicated profile page.
I added a contact form on the profile page and I wanted website users to be able to fill the form and contact the member of that profile directly from their profile page.
I want to know what function and code I need to get the user's email from the profile page uid, and use it in the mail function.
I've tried what I could with certain functions but I can't seem to get the profile page uid to correspond with the select function.
Any ideas?
User Profile - PHP mail
Re: User Profile - PHP mail
This is a basic mail function which I tried, obviously the $to is wrong, but I wasn't sure how to do it.
I put in echo $to at the end to test whether the email is being select which it is not.
[syntax=php]<?php
include('core/init.inc.php');
$pageTitle = "Contact Us";
$user_info = fetch_user_info($_GET['id']);
include('includes/header.php');
$to = "{$user_info['email']}";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
echo $to;
?>[/syntax]
I put in echo $to at the end to test whether the email is being select which it is not.
[syntax=php]<?php
include('core/init.inc.php');
$pageTitle = "Contact Us";
$user_info = fetch_user_info($_GET['id']);
include('includes/header.php');
$to = "{$user_info['email']}";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
echo $to;
?>[/syntax]