/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] keep getting parse error? please help

Hi, I’m new here, looks like a great forum!
Hope someone can help. I’ve been trying to create a form for my site and have been working on the following but I keep getting a parse error.
I created the form and placed it in my public folder and titled it as form.html, then I added the php script and placed that in the same public folder. Creating the php script within my public folder, I was given the following options on what I wanted to create: text document, html document, perl script, shell script. Not having an option for php I chose text. I then created the script and saved it as mailer.php
This is how I started the php script:
<?PHP
$to = “myemailplacedhere”;
$subject = “Results from your request form”;
$headers = “From: Form Mailer”;
$forward = 1;
$location = “thankyou.html”;

## set up the time ##

This is the action that I placed in my form:
<form action=”mailer.php” method=”post”>
I know my host supports php because they offer an option of having a chat forum in php Thoughts on where I went wrong?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@Doc_ThirstJul 31.2006 — If you don't mind, post both your <form> and the complete mailer.php. This is prob an easy fix. We just need to see it all. Of course be sure to exit out your connection and personal info.
Copy linkTweet thisAlerts:
@ms_khwauthorJul 31.2006 — Thanks for your kind response. This is what I put together:

My form, saved as form.html

[code=html]<html>
<head>
<title>Form</title>
</head>
<body>
<form action="mailer.php" method="post">
<p>Name:
<input type="text" name="textfield">
</p>
<p>Email:
<input type="text" name="textfield2">
</p>
<p align="left">Comments:</p>
<p align="left">
<textarea name="textarea"></textarea>
</p>
<p align="left">
<input type="submit" name="Submit" value="Submit">
&nbsp;&nbsp;
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
</body>
</html>[/code]


[code=php]<?PHP
$to = "[email protected]";
$subject = "Results from your request form";
$headers = "From: Form Mailer";
$forward = 1;
$location = "thankyou.html";
## set up the time ##

$date = date ("l, F jS, Y");
$time = date ("h:i A");

## mail the message ##

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.nn";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "n";
}
}

mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}

?>[/code]

As I said in my earlier post, I had no other option but to select the file for editing as a text file, whether that makes any difference I don't know. But I did save it as mailer.php and placed it in my public folder where I had placed the form.

Thank you
Copy linkTweet thisAlerts:
@bokehJul 31.2006 — Please edit your posts and encapsulate all the code between php tags. All you need to do is highlight the code and press the php button.
Copy linkTweet thisAlerts:
@NogDogJul 31.2006 — What is the exact error message you get? Does it reference a line number in the file, and if so make sure to indicate to us which line it is.

I don't see any obvious syntax errors, but the value for "From:" in the $header variable should be a valid email address, not a name.
Copy linkTweet thisAlerts:
@ms_khwauthorAug 01.2006 — This is the parse error:

Parse error: parse error, unexpected '<' in /home/[I]my user id shows here[/I]/public_html/mailer.php on line 2
Copy linkTweet thisAlerts:
@ms_khwauthorAug 01.2006 — I've solved the problem! All is a-ok.
×

Success!

Help @ms_khw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...