/    Sign up×
Community /Pin to ProfileBookmark

Beginner trying to email form results with PHP

Hi, I’m not experienced in any scripting language, but I read a little about PHP and followed a tutorial. I’m trying to send the email results of form data to my email account, and I got an error message when I tested it out.

My PHP page is

[code=php]<?php

$myemail = “[email protected]”;

$yourname = check_input ($_POST[‘yourname’]);
$email = check_input ($_POST[’email;]);
$submission = check input ($_POST[‘submission’]);
$site = check_input ($_POST[‘site’]);

$message = “Hello,

A submisison has been made by

Name: $yourname
E-mail: $email
URL: $site

Submission:
$submission

End of message
“;

mail ($myemail, $subject, $message);

header(‘Location: thanks.htm’);
exit();

function check_input ($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);

?>[/code]

My HTML page is

[code=html]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<meta http-equiv=”Content-type” content=”text/html; charset=ISO-8859-1″ />

<link type=”text/css” rel=”stylesheet” href=”../index.css” />

<title> </title>

</head>

<body>

<form action=”submission.php” method “post”>

<p> Your Name: <input type=”text” name=”yourname” /> <br />

<p> Email: <input type=”text” name=”email” /> <br />

<p> Your Submission: <br />
<textarea name=”submission” rows=”30″ cols=”70″> </textarea> </p>

<p> Your website or blog: <input type=”text” name=”site” /> <br />

<p> <input type=”submit” value=”Submit!”> </p>

</form>

</div>

</body>

</html>[/code]

Since I pretty much just followed a tutorial and changed things, I’m sure I screwed a few things up. If anyone could help me out, I’d greatly appreciate it. Sorry for all the code, but I don’t really know what I’m doing. Thanks in advance.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiDec 03.2009 — The messed up syntax highlighting is a good indication - you have an error in your quoting of strings. You are also missing a closing brace at the end of your function declaration, and you are using the variable $subject without initializing it anywhere. If you make sure you have error_reporting enabled and set to its highest level PHP will inform you of what is wrong and where.

[code=php]
<?php

$myemail = "[email protected]";

$yourname = check_input ($_POST['yourname']);
$email = check_input ($_POST['email']);
$submission = check input ($_POST['submission']);
$site = check_input ($_POST['site']);

$message = "Hello,

A submisison has been made by

Name: $yourname
E-mail: $email
URL: $site

Submission:
$submission

End of message
";

mail ($myemail, $subject, $message);

header('Location: thanks.htm');
exit();

function check_input ($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
}

?>
[/code]
Copy linkTweet thisAlerts:
@we_got_topsauthorDec 03.2009 — Everyone,

Sorry. I didn't really know what I was doing but it looks like I was making some careless errors that should have been easy to identify. I'll be more careful in the future before posting here.
×

Success!

Help @we_got_tops 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...