Home  |  About  | Last |  Submit  |  Contact
AllQuests.com




Previous Question:  Multiple boards for single installation multiple databases  phpBB 3.0.x 3.0.x Support ForumNext Question:  Grouping forums like on this quot Board Index quot  phpBB 3.0.x 3.0.x Support Forum
Question Contact Form problem ( SitePoint Forums PHP )
Updated: 2008-11-23 05:55:01 (2)
Contact Form problem

I am having a contact form problem.

For some reason, the messages I receive from my contact form have no FROM information, even though I seem to have it set in the form.

What am I doing wrong?

PHP Code:

 <?php


    
// if form is submitted
    
if($_POST['submit'])
    {
       
$sender = "From: " . $field_1 . " <" . $field_2 . ">";
        
// if you are using these values to add into a database as well, you may want some more security!
        
foreach($_POST as $key => $value)
            $
$key = htmlspecialchars($value);
    
        
// required fields
        
if($field_1 != '' && $field_2 != '' && $field_3 != '' && $field_4 != '')
         {
           
$message_body .=  $field_1 . ' <' . $field_2 . ' > ' . ' wrote the following message: ' . "\r\n";
           
$message_body .= 'Comments: '. $field_4 . "\r\n";
    
           
// send mail
           //mail($to_email, 'Contact - ' . $field_3, $message_body);
           
mail("info@mydomain.org", $field_3, $message_body, $sender);
           
$msg = '<p>We have received your information. We will try and answer your question or comments ASAP.</p>';
           
$msg .= '<p>Thank you.</p><p><b>You wrote the following:</b>';
           
$msg .= '<div class="followup">';
           
$msg .= '<p><b>Full Name:</b> '. $field_1 .'</p>';
           
$msg .= '<p><b>Email</b>: ' . $field_2 . '</p>';
           
$msg .= '<p><b>Subject</b>: ' . $field_3 . '</p>';
           
$msg .= '<p><b>Comments:</b><br /> ' . $field_4 . '</p>';
           
$msg .= '</div>';
         }
        
// if a required field wasn't filled in
        
else
           
$error = '<p class="error">Please make sure all fields are filled in.</p>';
    }

    if(isset(
$msg))
        echo
$msg;
        
    else
    {
        if(isset(
$error))
            echo
$error;
?>
Thanks
Bryan

Answers: Contact Form problem ( SitePoint Forums PHP )
Contact Form problem

Thanks. Works great!

Bryan

jag5311

Contact Form problem

Quote:
$sender = "From: " . $field_1 . " <" . $field_2 . ">";
// if you are using these values to add into a database as well, you may want some more security!
foreach($_POST as $key => $value)
$$key = htmlspecialchars($value);
You're trying to use $field_1 and $field_2 before you've created then using $$key so the $sender = line needs to go below the $$key = part.

markl999

Previous Question:  Multiple boards for single installation multiple databases  phpBB  phpBB 3.0.x 3.0.x Support ForumNext Question:  Grouping forums like on this quot Board Index quot  phpBB  phpBB 3.0.x 3.0.x Support Forum

- Source: Contact Form problem SitePoint Forums PHP
- Previous Question: Multiple boards for single installation multiple databases phpBB phpBB 3.0.x 3.0.x Support Forum
- Next Question: Grouping forums like on this quot Board Index quot phpBB phpBB 3.0.x 3.0.x Support Forum