Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

PHP form processing problem

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:
<?php
// 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.
0
daluu
Asked:
daluu
  • 2
  • 2
1 Solution
 
daluuAuthor Commented:
oh, and never mind that the file is on local pc. I have same problem on server.
0
 
carchitectCommented:
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";

regards


0
 
VGRCommented:
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.
0
 
daluuAuthor Commented:
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.
0
 
carchitectCommented:
thx for acceptance...
regards
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now