HELP
Posted: Wed Jun 25, 2008 6:39 pm
im new to the world of php and an itresting one it is at that, ive used css and html a lot but untill now havent tried out php.
my question is this...
what im trying to do is when a a submit button is pressed on a form i want the script to handle it by sending a thank you email to the preson sending which i have got done no problems, but also to send an email to an email addres i would like it to go to with all the field data enterd in the form present in the email. the script i have thrown up so far is this.
it sends the email as requested to the person sending the script and it also sends an email to the email addres i want it to send it to.. damien@boltonpropertydevelopments.com with all the field value's there but the data along with it isnt, so it looks like theform was not filled in
just displays as:
Values submitted by the user:
name:
email:
contact:
address:
postcode:
message: Message here....
submit: submit information
recipient: damien@boltonpropertydevelopments.com
subject: Mail Sent Via Website
i have posted a test page up online im working with thats at http://www.boltonpropertydevelopments.com/contact1.php
on the actual website i have a diffrent page http://www.boltonpropertydevelopments.com/contact.html
and that runs the script through <form action="sucess1.php" method="post"> this works fine and sends all the deatils i want but does not send a thankyou we will be in touch soon email to the client that i would like.
Any help would be mega guys, please stear me in the right direction
<!-- START OF PHP FORM SCRIPT -------------------------------- -->
<?php # script 1.00 - contact.php
if (isset($_POST['submit'])) { // HANDEL THIS FORM
$message = NULL;
// name check.
if (strlen($_POST['name']) > 0) {
$name = TRUE;
} else {
$name = FALSE;
echo '<p>Please enter your name</p>';
}
// email check.
if (strlen($_POST['email']) > 0) {
$email = TRUE;
} else {
$email = FALSE;
echo '<p>Please enter your email address</p>';
}
// Contact number check.
if (strlen($_POST['contact']) > 0) {
$contact = TRUE;
} else {
$contact = FALSE;
echo '<p>Please enter a contact number</p>';
}
if ($name && $email && $contact) { // if all is filled out.
// complete the request.
// send an email to sender.
$body = "Thank you '{$_POST['name']}' for your message left on our site boltonpropertydevelopments.com";
mail ($_POST['email'], $body, 'As soon as we check the machine we will be in touch shortly
Thank you, The Team.');
header ('Location: sucess.html');
exit();
} else { //something's not filled in i requested or need.
$message .= '<p>Please try again.
</p>';
}
}
// Print out error message if there is one.
if (isset($message)) {
echo '<font color="red">', $message,
',</font>';
}
?>
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
$msg="Values submitted by the user:\n";
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}
$recipient="damien@boltonpropertydevelopments.com";
$subject="Form Mail from boltonpropertydevelopments.com";
error_reporting(0);
if (mail($recipient, $subject, $msg)){
echo "";
echo nl2br($input);
} else
echo "";
} else
echo "";
?>
<!-- END OF PHP FORM SCRIPT! ----------------------------------------------- -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend></legend>
<br>
<input type="text" name="name">
Name
<br>
<input type="text" name="email">
Email
<br>
<input type="text" name="contact">
Contact Number
<br>
<input type="text" name="address">
Address
<br>
<input type="text" name="postcode">
PostCode
</p>
<p> Please leave a brief message and we will shortly be in touch
<br>
<TEXTAREA NAME ="message" Cols=60 ROWS=10 WRAP class="style2">Message here....</TEXTAREA>
</p>
</fieldset>
<div align="center">
<p>
<input type="submit" name="submit" value="submit information" />
</p>
</div>
<input name="recipient" type="hidden" id="recipient" value="damien@boltonpropertydevelopments.com">
<input name="subject" type="hidden" id="subject" value="Mail Sent Via Website">
</form>
my question is this...
what im trying to do is when a a submit button is pressed on a form i want the script to handle it by sending a thank you email to the preson sending which i have got done no problems, but also to send an email to an email addres i would like it to go to with all the field data enterd in the form present in the email. the script i have thrown up so far is this.
it sends the email as requested to the person sending the script and it also sends an email to the email addres i want it to send it to.. damien@boltonpropertydevelopments.com with all the field value's there but the data along with it isnt, so it looks like theform was not filled in
just displays as:
Values submitted by the user:
name:
email:
contact:
address:
postcode:
message: Message here....
submit: submit information
recipient: damien@boltonpropertydevelopments.com
subject: Mail Sent Via Website
i have posted a test page up online im working with thats at http://www.boltonpropertydevelopments.com/contact1.php
on the actual website i have a diffrent page http://www.boltonpropertydevelopments.com/contact.html
and that runs the script through <form action="sucess1.php" method="post"> this works fine and sends all the deatils i want but does not send a thankyou we will be in touch soon email to the client that i would like.
Any help would be mega guys, please stear me in the right direction
<!-- START OF PHP FORM SCRIPT -------------------------------- -->
<?php # script 1.00 - contact.php
if (isset($_POST['submit'])) { // HANDEL THIS FORM
$message = NULL;
// name check.
if (strlen($_POST['name']) > 0) {
$name = TRUE;
} else {
$name = FALSE;
echo '<p>Please enter your name</p>';
}
// email check.
if (strlen($_POST['email']) > 0) {
$email = TRUE;
} else {
$email = FALSE;
echo '<p>Please enter your email address</p>';
}
// Contact number check.
if (strlen($_POST['contact']) > 0) {
$contact = TRUE;
} else {
$contact = FALSE;
echo '<p>Please enter a contact number</p>';
}
if ($name && $email && $contact) { // if all is filled out.
// complete the request.
// send an email to sender.
$body = "Thank you '{$_POST['name']}' for your message left on our site boltonpropertydevelopments.com";
mail ($_POST['email'], $body, 'As soon as we check the machine we will be in touch shortly
Thank you, The Team.');
header ('Location: sucess.html');
exit();
} else { //something's not filled in i requested or need.
$message .= '<p>Please try again.
</p>';
}
}
// Print out error message if there is one.
if (isset($message)) {
echo '<font color="red">', $message,
',</font>';
}
?>
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
$msg="Values submitted by the user:\n";
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}
$recipient="damien@boltonpropertydevelopments.com";
$subject="Form Mail from boltonpropertydevelopments.com";
error_reporting(0);
if (mail($recipient, $subject, $msg)){
echo "";
echo nl2br($input);
} else
echo "";
} else
echo "";
?>
<!-- END OF PHP FORM SCRIPT! ----------------------------------------------- -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend></legend>
<br>
<input type="text" name="name">
Name
<br>
<input type="text" name="email">
<br>
<input type="text" name="contact">
Contact Number
<br>
<input type="text" name="address">
Address
<br>
<input type="text" name="postcode">
PostCode
</p>
<p> Please leave a brief message and we will shortly be in touch
<br>
<TEXTAREA NAME ="message" Cols=60 ROWS=10 WRAP class="style2">Message here....</TEXTAREA>
</p>
</fieldset>
<div align="center">
<p>
<input type="submit" name="submit" value="submit information" />
</p>
</div>
<input name="recipient" type="hidden" id="recipient" value="damien@boltonpropertydevelopments.com">
<input name="subject" type="hidden" id="subject" value="Mail Sent Via Website">
</form>