Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 06-29-2009, 12:17 AM
  #1
kazthedesigner
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 10
iTrader: (0)
kazthedesigner is an unknown quantity at this point
Question Simple Enquiry Form

I have a simple enquiry form i have on a html doc contact us page.

I need the form to send an email to the nominated email address all the information entered into the form once the submit button is hit.

The form i have in there now works fine but ONLY sends the comments section, not the name, number, email address of the person filling it out. I have a feeling that it is something small with the end of the coding in the PHP script where it tells the form which part of the form to email.

I think this bit is wrong, and i cannot figure out how it is meant to look.

else {
mail( "$webmaster_email", "Website Feedback Form Results",
$full_name, $contact_number, $comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}



If I put it so that it says this only:

mail( "$webmaster_email", "Website Feedback Form Results",
$comments, "From: $email_address" );

it works fine, but only sends me the comments.
When I thought that adding the other values to the code that it would send me the 3 bits, it just doesnt work.
It goes to the thank you page but does not come through to my email address.


The HTML form code is as follows:

<form action="send_mail.php" method="post">
<table>
<tr>
<td>Full Name:</td>
<td>
<input type="text" name="full_name" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Contact Number:</td>
<td>
<input type="text" name="contact_number" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Email Adress:</td>
<td>
<input type="text" name="email_address" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Comments:</td>
<td>
<textarea rows="10" cols="50" name="comments"></textarea>
</td>
</tr>
<tr><td>&nbsp;</td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</form>



and the PHP script is as follows:

<?php

$webmaster_email = "email@address.com";

$feedback_page = "index.html";
$error_page = "index_error.html";
$thankyou_page = "index_thanks.html";

$full_name = $_REQUEST['full_name'] ;
$contact_number = $_REQUEST['contact_number'] ;
$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;

function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}

if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}

elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}

else {
mail( "$webmaster_email", "Website Feedback Form Results",
$full_name, $contact_number, $comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>




hopefully someone can help me get it working so that it emails me all the values of the form together.

If you even have a fresh new code that works better and is as easy to understand, that would be VERY helpful too!

All help appreciated greatly.
kazthedesigner is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-02-2009, 01:38 AM
  #2
Sawtooth500
Lord (Level 16)
 
Sawtooth500's Avatar
 
Join Date: Nov 2007
Location: Chicago, IL. USA
Posts: 604
iTrader: (0)
Sawtooth500 is on a distinguished road
PHP Code:
else {
mail$webmaster_email"Website Feedback Form Results",
$full_name "\n" .  $contact_number "\n" $comments"From: " $email_address );
header"Location: " $thankyou_page );
exit();

That should do it for you. First off, do not encase PHP variables in quotes. If you do that PHP will take the literal string, not the value of the variable. Secondly, the format for the mail function is:

mail(to, subject, message, additional headers)

Where you had meant for your message to go you put commas between the variables. Doing so makes the function think part of your message was additional headers, which is wasn't and confused it. Use the "." operator to join strings. "\n" creates a new line in your email.
__________________
-Taras Hryniw

http://www.waltonstreetwebdesign.com
Sawtooth500 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply
KEEP TABS
SPONSORS
 
Boxedart

 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 05:41 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.