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

  • SEARCH
  • Home
  • 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 8452477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:30:36+00:00 2026-06-10T11:30:36+00:00

I am learning php and have a book which has lots of examples and

  • 0

I am learning php and have a book which has lots of examples and exercises in. The one I’m doing is about sending email. I copied the code to the letter, but I am getting an error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\website2\www\sendscript.php on line 6 

Why is this happening, any idea?

Here is my PHP script:

<?php
    if(($_POST['sender_name']=="")||($_POST['sender_email']=="")||($_POST['message']=="")){
        header("Location: sendemail.html");
        exit;
    }

    $email = "Sender's name:\t$_POST['sender_name']\n";
    $email .= "Sender's email:\t$_POST['sender_email']\n";
    $email .= "Message:\t$_POST['message']\n";
    $to = "stafford.king16@pgs.org.uk";
    $subject = "did script work?";
    $mailheaders = "From: Stafford King";
    $mailheaders .= "Reply to: $_POST['sender_email']\n";
    mail($to, $subject, $email, $mailheaders);
?>
<html>
    <head></head>
    <body>
        <h1>Email sent!</h1>
    </body>
</html>

And here is my email input form:

<html>
  <head></head>
  <body>
    <form method = "post" action = "sendscript.php">
        <p><strong>Your name:</strong><br />
        <input type = "text" name = "sender_name" size = "30"</p>
        <p><strong>Your email address:</strong><br />
        <input type = "text" name = "sender_email" size = "30"</p>
        <p><strong>Message:</strong><br />
    <textarea name = "message" cols = "30" rows = "5" wrap = "virtual"></textarea></p>
        <p><input type = "submit" name = "submit" value = "send email"></p>
    </form>
  </body>
</html>

Thanks guys 🙂

  • 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-10T11:30:37+00:00Added an answer on June 10, 2026 at 11:30 am

    You need to wrap your array variables in curly brackets {} or concatenate them within the string:

    OPTION 1

    $email = "Sender's name:\t{$_POST['sender_name']}\n";
    

    OPTION 2

    $email = "Sender's name:\t" . $_POST['sender_name'] . "\n";
    

    NOTE:

    Use of an IDE such as Dreamweaver (license fee), NetBeans or Eclipse (both open source & free) would have caught this immediately. Try one of these, rather than Notepad or Notepad++.

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

Sidebar

Related Questions

I have been learning php for sometime now. Besides reading books and doing tutorials
Learning php! I have a sql database which contains a table called 'images' which
I have been learning PHP for some time now and I wanted one clarification.
I have a PHP website which I am learning PHP on, which is on
I'm learning about PHP and web coding. Specifically, the PHP book I'm using that
I'm still learning php and have run up against what should be a relatively
I have committed to learning C now, I'm good with Python/PHP/Bash but I've decided
I am coming from the world of PHP and am learning Ruby/Rails. I have
I'm new to learning php and in one of my first programs I wanted
I'm learning PHP. The PHP has inline commands in HTML code to produce dynamic

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.