HELP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sebpearce
Forum Newbie
Posts: 2
Joined: Wed Jun 25, 2008 6:18 pm

HELP

Post by sebpearce »

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>
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: HELP

Post by WebbieDave »

Hi. You're new here so you'll want to read the Forum Rules (especially the section about posting).

Also, you should properly indent your code and encompass it between php tags (see BBCode) as it results in much more readable output:

Code: Select all

if ($left_size == 0) {
    if (isset($default_left_size)) {
         $left_size = $default_left_size;
    }
}
Also include descriptions or code snippets of things you've tried to fix it and the results of those tries. We don't usually have time to read through posts that simply entail "my code isn't doing what I expect. Here it is. Take a look and tell me what's wrong." You need to debug your code by checking variable values at pertinent points of execution by employing well placed echo's or print_r's. Try it and you'll shall see how they can enlighten!
Post Reply