Jump to content

How to use result of query as a variable?


SokrMan

Recommended Posts

Hello,

So I have a content management site set up, but I'm stuck on one part. I have a query.

Select `email` FROM author WHERE author.id IN(SELECT authorid FROM job WHERE id = '$_POST[id]')

 

I'm a beginner in PHP and SQL. Basically I need the query to run, it will come out with one result and I need that to be where the email is sent to.

 

This is the existing code I have for sending out the email

$subject = " Job Application Confirmation";

$message = "Hello $_POST[name] , \r\rYou, or someone using your email address, has applied for the job: $text Using the Resource Locator at Prahan.com. Keep this as future reference. \r\r Full Name: $_POST[name] \r Location: $_POST[location] \r Email: $_POST[email] \r Additional Information: $_POST[info] \r Job ID: $id  \r Job Name: $text  \r \r Expect a response shortly. \r\r Regards, Prahan.com Team";

$headers = 'From: Prahan.com Team <noreply@prahan.com>';

    'Reply-To: noreply@prahan.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

$to1      = 'pratik@prahan.com';

mail($to1, $result, $message, $headers);

 

Thanks in Advance!

Link to comment
Share on other sites

For some reason, this code

$result = mysql_query("Select `email` FROM author WHERE author.id IN(SELECT authorid FROM job WHERE id = $id)"); $to1 = PRINT $result;

echo "An email has been sent to the Job Poster with your contact information. You will recieve a confirmation email at $to1 . Remeber to check your junk mail as well.";

isn't working.

 

The email of the author should = $to1. Here is the whole page's code

 

if ($_POST['form_submitted'] == '1') {
##User is registering, insert data until we can activate it
session_start();
$id = $_SESSION['id'];
$text = $_SESSION['text'];
$authorid = $_SESSION['authorid'];
$name = ($_POST[username]);
$info = ($_POST[info]);
$location = ($_POST[location]); 
$email = ($_POST[email]);

$db_host = 'localhost';
$db_user = '************';
$db_pwd = '*****';

$database = '*****';
$table = 'job';

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");


$result = mysql_query("Select `email` FROM author WHERE author.id IN(SELECT authorid FROM job WHERE id = $id)"); $to1 = PRINT $result;

echo "An email has been sent to the Job Poster with your contact information. You will recieve a confirmation email at $to1 . Remeber to check your junk mail as well.";

##Send activation Email

$to      = $_POST[email];

$subject = " Job Application Confirmation";

$message = "Hello $_POST[name] , \r\rYou, or someone using your email address, has applied for the job: $text Using the Resource Locator at Prahan.com. Keep this as future reference. \r\r Full Name: $_POST[name] \r Location: $_POST[location] \r Email: $_POST[email] \r Additional Information: $_POST[info] \r Job ID: $id  \r Job Name: $text \r Author's Email: $to1  \r \r Expect a response shortly. \r\r Regards, Prahan.com Team";

$headers = 'From: Prahan.com Team <noreply@prahan.com>';

    'Reply-To: noreply@prahan.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

$subject1 = "test";

mail($to1, $subject1, $message, $headers);

 

Thanks in Advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.