Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 527569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:53:49+00:00 2026-05-13T08:53:49+00:00

On my site I have a contactUser.php that sends mail and a replyMail.php. I

  • 0

On my site I have a contactUser.php that sends mail and a replyMail.php. I have put PHPMail on my contact user to send email notifications which is working great. When I put the same code chunk on my replyMail (which mail goes to the same place as the contact user mail,the inbox) that shares the same variables its giving me a internal server error. I have tried different GET vars as well as echoed die($vars) and echoed queries. Any ideas what the problem might be. Here is my code:

$prof = new User($_GET['id']);

$query = "SELECT `Email` FROM `Users` WHERE `id` = '" . $prof->id . "'";
$request = mysql_query($query,$connection) or die(mysql_error());
$result = mysql_fetch_array($request); 

$Email = $result['Email'];


$to = $Email;
$subject = "$auth->first_name $auth->last_name sent you a message";
$message = "$auth->first_name $auth->last_name sent you a message:<br /> <br /> <a href='http://www.blah.org/Inbox.php'>Click here to view</a><br /><br /> The Team";
$from = "blah<noreply@blah.org>";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:$from";
mail($to, $subject, $message, $headers);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:53:49+00:00Added an answer on May 13, 2026 at 8:53 am

    I really suggest wrapping it up into a function. From what you’ve posted, I get the sense that you have all the code in the global namespace, in which case any number of auto-prepends or includes could easily be messing with variables.

    Something like:

    // Function that accepts a user object and a database connection, then sends a notice email.
    function email_message_notice($prof, $connection){
    $query = "SELECT `Email` FROM `Users` WHERE `id` = '" . $prof->id . "'";
    $request = mysql_query($query,$connection) or die(mysql_error());
    $result = mysql_fetch_array($request); 
    
    $Email = $result['Email'];
    
    $to = $Email;
    $subject = "$auth->first_name $auth->last_name sent you a message";
    $message = "$auth->first_name $auth->last_name sent you a message:<br /> <br /> <a href='http://www.blah.org/Inbox.php'>Click here to view</a><br /><br /> The Team";
    $from = "blah<noreply@blah.org>";
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From:$from";
    $res = mail($to, $subject, $message, $headers);
    return $res;
    }
    
    
    $prof = new User($_GET['id']);
    $sent = email_message_notice($prof, $connection);
    

    Since there’s a database involved, this is untested code, so you’ll want to test that it works and want to debug any further issues yourself, but otherwise it should be a good way to compartmentalize and share the code. If you’re doing exactly the same thing in both scripts, you can just include the email_user function in a separate include.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 265k
  • Answers 265k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is currently not possible as reported in Remote Configuration… May 13, 2026 at 12:27 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately matching in .hgignore is done just by filenaming. However,… May 13, 2026 at 12:27 pm
  • Editorial Team
    Editorial Team added an answer This error occurs if you have data in the table… May 13, 2026 at 12:27 pm

Related Questions

I have this membership site setup on my local machine using the ASP.NET membership
I'm experimenting with ASP.NET MVC and Routes. It appears MVC forces me to add
I am creating a site-map with all urls on my site! I have a
On my site I'm using the jquery cycle plugin for a slideshow with a
I have a site that saves a date in my model to the database.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.