PHP form processing problem

Posted on 2003-02-25
Medium Priority
Last Modified: 2006-11-17
My web server admin recently decided to upgrade PHP on server and disable old form field variable access. So I have to use the new method which I believe is $_POST['field'] instead of $field for the POST submission method.

However, I encounter this error when I changed my code:
PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Documents and Settings\dluu\Desktop\scholarship\$test.txt on line 12

Here is my PHP code:
// Developed by David Luu for the EE Dept.
// Questions/Comments Contact luud@cuulmedia.com
// This script for sending application to EE email address.

//Recepient Email address for application submissions.
$send_to = "phsu@email.sjsu.edu, coe@email.sjsu.edu, dluu4@email.sjsu.edu";

/* $message is a variable containing the entire form data. The PHP code below combines the data of each form field into the message variable. Each name with a $ preceding it is a variable that is linked to its form field name and will be inserted where it is listed in the code below. \n = new line, \t = tab.

$message = "Name: $_POST['FirstName'] $_POST['MiddleName'] $_POST['LastName']\nSSN: $_POST['SSN']\nHigh School Attended: $_POST['highschool']\nGPA: $_POST['GPA']\nSAT Score: $_POST['SAT']\nIntended Major: $_POST['major']\nEmail: $_POST['submit_by']\nAddress:\n$_POST['Street']\n$_POST['City'], $_POST['State'] $_POST['Zip']\nPhone: $_POST['AreaCode']-$_POST['Telephone']\n\nPersonal Statement:\n$_POST['personalSt']\n";

/* mail("recepient@email.com", "Subject", "message", "From: return@email.com");
In the code below, "message" is replaced with the $message variable and the return email is replaced with the $submit_by variable.

/* All scholarship submissions should be sent with the appropriate subject heading such as the one given below. */

mail($send_to, "SVE Scholarship Application", $message, "From: $_POST['submit_by']");


Off hand, I can't tell the source of the problem. Can someone point out my error.
Question by:daluu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Author Comment

ID: 8022499
oh, and never mind that the file is on local pc. I have same problem on server.

Accepted Solution

carchitect earned 200 total points
ID: 8023074
in $message you can not use string in that wau pls use it in this way...

$message = "Name: ".$_POST['FirstName']." ".$_POST['MiddleName']." ".$_POST['LastName']."\r\nSSN: ".$_POST['SSN']."\r\nHigh School Attended: ".$_POST['highschool']."\r\nGPA: ".$_POST['GPA']."\r\nSAT Score: ".$_POST['SAT']."\r\nIntended Major: ".$_POST['major']."\r\nEmail: ".$_POST['submit_by']."\r\nAddress:\r\n".$_POST['Street']."\r\n".$_POST['City'].", ".$_POST['State']." ". $_POST['Zip']."\r\nPhone: ".$_POST['AreaCode']."-".$_POST['Telephone']."\r\n\r\nPersonal Statement:"\r\n".$_POST['personalSt']."\n";


LVL 15

Expert Comment

ID: 8023205
absolutely. Again and for the n-th time and in any language I know :
you can't reference array elements in a string that way. This is the BASIC-like feature with strings.
In Pascal or C/C++ things are clearer 'cause variable references NEVER make it into the string itself, but are rather listed sequentially or after the "format" string.

Author Comment

ID: 8030769
Thanks. I never really worked with $_POST[] method so I didn't know you couldn't do that. But it did seem out of place doing what I did when I did it.

Expert Comment

ID: 8031908
thx for acceptance...

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question