/    Sign up×
Community /Pin to ProfileBookmark

Form Question/help

How do I get this code in this php file below to send the data from form on a html page,[B] but either stays on the same page or redirects back to the page? Right now, it sends the data and goes to a blank page.
[/B]

<?php
$to = “[email protected]“;
$subject = “Contact Page Information for Hope Today”;

$headers = “From: ” . $_POST[“name”];
$headers .= “<” . $_
POST[“email”] . “>rn”;
$headers .= “Reply-To: ” . $_POST[“email”] . “rn”;
$headers .= “Return-Path: ” . $_
POST[“email”];

$message .= “nn”;
$message .= “Subject: ” . $_POST[“subject”] . “rn”;
$message .= “Email: ” . $_
POST[“email”] . “rn”;
$message .= “Name: ” . $_POST[“name”] . “rn”;
$message .= “Address: ” . $_
POST[“address”] . “rn”;
$message .= “City: ” . $_POST[“city”] . “rn”;
$message .= “State: ” . $_
POST[“state”] . “rn”;
$message .= “Zip Code: ” . $_POST[“zip”] . “rn”;
$message .= “Phone: ” . $_
POST[“phone”] . “rnn”;
$message .= “Message: ” . $_POST[“message”] . “rn”;

mail($to, $subject, $message, $headers);
?>

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@jogolMar 13.2007 — let´s assume you have a contact.php that has a form with

<form method="post" action="send.php">

put the code you posted into the send.php. after the code put in whatever html code you want.

like

[CODE][your code...]
<!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">
<head>
.....
.....[/CODE]


but don´t forget to validate your form fields and secure your form from injections! http://computerbookshelf.com/email_injection/
Copy linkTweet thisAlerts:
@LUTRELLAauthorMar 13.2007 — Yeah that part is fine, the last part (in bold) is the problem.
Copy linkTweet thisAlerts:
@jogolMar 13.2007 — header( 'Location: http://www.yoursite.com/desired_page.html' );
Copy linkTweet thisAlerts:
@LUTRELLAauthorMar 13.2007 — header( 'Location: http://www.yoursite.com/desired_page.html' );[/QUOTE]

would that code be placed in the html file or the php file?
Copy linkTweet thisAlerts:
@jogolMar 14.2007 — right after

mail($to, $subject, $message, $headers);
×

Success!

Help @LUTRELLA 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.6,
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,
)...