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 8462917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:18:47+00:00 2026-06-10T14:18:47+00:00

I’m trying to use a simple PHP mail() function to create user feedback from

  • 0

I’m trying to use a simple PHP mail() function to create user feedback from a website. I’m using the ‘PHP Secure E-mail’ sample script from W3 as a basis. Because of the nature of the email, there’s no need for added security or using some of the libraries, e.g. swift mailer, that have been suggested in other posts related to this topic.

When the base form is loaded and the ‘send mail’ button selected, I get a “server error” message and the following supporting information:

“The website encountered an error while retrieving
http://www.examplewebsite/formsuccessful.php?forename=Joe&surname=Blogs&email=j.oe.blogs%40example.co.uk&subject=TEST+2&message=Test+Content
It may be down for maintenance or configured incorrectly.”

The file ‘formsuccessful.php’ file is definitely on the server in the correct folder – unless there’s another setting I’m overlooking to enable to this type of PHP scripting?

I’ve included both the form and PHP code below in case there’s an error in those.

Would certainly appreciate some help, I’ve danced around the houses on this one that many times I can’t see the wood from the trees any more.

Cheers.

PHP:

<?php
function spamcheck($field)
  {
  $field1=filter_var($field, FILTER_SANITIZE_EMAIL);
  if(filter_var($field1, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

if (isset($_REQUEST['email']))
  {

  $mail = $_REQUEST['email'];
  $mailcheck = spamcheck($mail);
  if ($mailcheck==FALSE)
    {
    echo "Invalid input";
    }
  else
    {
    $email = $_REQUEST['email'] ;
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['message'] ;
    $name = $_REQUEST['forename']." ".$_REQUEST['surname'];
    mail("admin@examplewebsite.com", "Subject: "$subject,
    "Message: "$message, "From: "$email," ",$name );
    }
  }
else{
    //reload page with message highlighting error
    }
?>

HTML Form:

<form method="REQUEST" action="formsuccessful.php">
            <fieldset class="master">
            <legend class="master" style="text-align:left;"><b><u>Personal     Details:</u></b></legend>
                <ol class="master">
                    <li class="master"><label class="master"     for"forname">Forename<em class="master">*</em></label><input class="left" type="text"     name="forename" size="30" /></li>
                <li class="master"><label class="master" for"surname">Surname<em class="master">*</em></label><input type="text" name="surname" size="30" /></li>
                <li class="master"><label class="master" for"email">Your Email<em class="master">*</em></label><input type="text" name="email" size="30" /></li>
            </ol>
        <legend class="master" style="text-align: left;"><b><u>Email Contents:</u></b></legend>
            <ol class="master">
                <li class="master"><label class="master" for="subject">Subject:<em class="master">*</em></label><input type="text" name="subject" size="30" /></li>
                <li class="master"><label class="master" for="message">Content:<em class="master">*</em></label><textarea cols="50%" rows="20" onkeyup="checkContent()" name="message" id="message"></textarea></li>
                <li class="master"><input type="submit" value="Send Email" /></li></ol>
        </fieldset>
    </form>

Standing by to have the criminally obvious pointed out to me.

  • 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-06-10T14:18:49+00:00Added an answer on June 10, 2026 at 2:18 pm

    You seem to have some errors here:

    mail("admin@examplewebsite.com", "Subject: "$subject,
      "Message: "$message, "From: "$email," ",$name );
    

    If you want to concatenate, you need to use something like:

    mail("admin@examplewebsite.com", "Subject: " . $subject,
      "Message: " . $message, "From: " . $email);
    

    You also have one parameter too many, I’m not sure what you want to do with the last part ," ", $name but that’s not valid input for the last parameter, see the manual for mail.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.