New Posts  All Forums:Forum Nav:

Email forms HELP!

post #1 of 7
Thread Starter 
Hey everyone,
I have been doing a coding project for someone, and have to implement a form. View the forms here: Form1 and Form2.
Can anyone tell me how to set up the PHP to get the email attachment and message form set up. I have only dabbled in PHP forms before and need to get this done soon.
THANKS!!!
Maelstrom
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 Gigabyte DS3LR eVGA 9800GTX+ 4x2gb G.Skill Ripjaws 
Hard DriveOSMonitorKeyboard
Seagate 500gb perp Windows 7 x64, Ubuntu 9.10 beta 23" Samsung, 22" Acer AL2223, 19" Hanns-G Logitech G15 
PowerCaseMouse
Ultra X-Finity 600W NZXT Alpha Logitech G7 
  hide details  
Reply
Maelstrom
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 Gigabyte DS3LR eVGA 9800GTX+ 4x2gb G.Skill Ripjaws 
Hard DriveOSMonitorKeyboard
Seagate 500gb perp Windows 7 x64, Ubuntu 9.10 beta 23" Samsung, 22" Acer AL2223, 19" Hanns-G Logitech G15 
PowerCaseMouse
Ultra X-Finity 600W NZXT Alpha Logitech G7 
  hide details  
Reply
post #2 of 7
dont know how to do something like that with PHP; but i use jotform.com, forms made easy
post #3 of 7
Submit the form as normal, with an action of this:
Code:
<form action='SCRIPTNAME.php' method='POST'>
The values will then be available to your PHP script. You could so something like this:

Code:

<?php
// Set some variables
$recipient = 'user@example.com';
$subject = 'Form Submission';
$from = stripslashes($_POST['Name'])."<".stripslashes($_POST['Email']).">";

// Setup file handling
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$tmp_name = $_FILES['Upload']['tmp_name'];
$type = $_FILES['Upload']['type'];
$name = $_FILES['Upload']['name'];
$size = $_FILES['Upload']['size'];

// Build the message text
$message = "Name: ".$_POST['Name']."
Phone: ".$_POST['Phone']."
Message:
".$_POST['Message'];

// Was the file upload successful?
if (file_exists($tmp_name)){

    if(is_uploaded_file($tmp_name)){
        // Yes, open for reading into a variable
        $file = fopen($tmp_name,'rb');
        $data = fread($file,filesize($tmp_name));
        fclose($file);
        $data = chunk_split(base64_encode($data));
    }
    
    // Build the headers
    $headers = "From: $from\ \
" .
    "MIME-Version: 1.0\ \
" .
    "Content-Type: multipart/mixed;\ \
" .
    " boundary=\\"{$mime_boundary}"";

    // Build the MIME message
    $message = "This is a multi-part message in MIME format.\
\
" .
    "--{$mime_boundary}\
" .
    "Content-Type: text/plain; charset=\\"iso-8859-1"\
" .
    "Content-Transfer-Encoding: 7bit\
\
" .
    $message . "\
\
";
    $message .= "--{$mime_boundary}\
" .
    "Content-Type: {$type};\
" .
    " name=\\"{$name}"\
" .
    "Content-Transfer-Encoding: base64\
\
" .
    $data . "\
\
" .
    "--{$mime_boundary}--\
";
    
    // Send the mail
    mail($to, $subject, $message, $headers)
}
?>
Of course I have assumed some affinity with PHP here. Please don't hesitate to post back or PM if you need anything else explained!
Neuron
(13 items)
 
  
CPUMotherboardGraphicsRAM
Pentium D 805 (Dual Core) ASRock 775Twins-HDTV XFX GeForce 6600 1GB DDR 
Hard DriveOptical DriveOSMonitor
480GB Total 2x DVD-RW (1x LightScribe) Ubuntu Philips 170B 17in 
KeyboardPowerCaseMouse
Logitech G15 Thermaltake TR2 430W Thermaltake Tsunami BWA Logitech G5 
Mouse Pad
X-Ray Thunder 8 
  hide details  
Reply
Neuron
(13 items)
 
  
CPUMotherboardGraphicsRAM
Pentium D 805 (Dual Core) ASRock 775Twins-HDTV XFX GeForce 6600 1GB DDR 
Hard DriveOptical DriveOSMonitor
480GB Total 2x DVD-RW (1x LightScribe) Ubuntu Philips 170B 17in 
KeyboardPowerCaseMouse
Logitech G15 Thermaltake TR2 430W Thermaltake Tsunami BWA Logitech G5 
Mouse Pad
X-Ray Thunder 8 
  hide details  
Reply
post #4 of 7
Thread Starter 
awesome that helps a lot for now.
repped! you seriously deserve it.
Maelstrom
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 Gigabyte DS3LR eVGA 9800GTX+ 4x2gb G.Skill Ripjaws 
Hard DriveOSMonitorKeyboard
Seagate 500gb perp Windows 7 x64, Ubuntu 9.10 beta 23" Samsung, 22" Acer AL2223, 19" Hanns-G Logitech G15 
PowerCaseMouse
Ultra X-Finity 600W NZXT Alpha Logitech G7 
  hide details  
Reply
Maelstrom
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 Gigabyte DS3LR eVGA 9800GTX+ 4x2gb G.Skill Ripjaws 
Hard DriveOSMonitorKeyboard
Seagate 500gb perp Windows 7 x64, Ubuntu 9.10 beta 23" Samsung, 22" Acer AL2223, 19" Hanns-G Logitech G15 
PowerCaseMouse
Ultra X-Finity 600W NZXT Alpha Logitech G7 
  hide details  
Reply
post #5 of 7
Glad I could help
Neuron
(13 items)
 
  
CPUMotherboardGraphicsRAM
Pentium D 805 (Dual Core) ASRock 775Twins-HDTV XFX GeForce 6600 1GB DDR 
Hard DriveOptical DriveOSMonitor
480GB Total 2x DVD-RW (1x LightScribe) Ubuntu Philips 170B 17in 
KeyboardPowerCaseMouse
Logitech G15 Thermaltake TR2 430W Thermaltake Tsunami BWA Logitech G5 
Mouse Pad
X-Ray Thunder 8 
  hide details  
Reply
Neuron
(13 items)
 
  
CPUMotherboardGraphicsRAM
Pentium D 805 (Dual Core) ASRock 775Twins-HDTV XFX GeForce 6600 1GB DDR 
Hard DriveOptical DriveOSMonitor
480GB Total 2x DVD-RW (1x LightScribe) Ubuntu Philips 170B 17in 
KeyboardPowerCaseMouse
Logitech G15 Thermaltake TR2 430W Thermaltake Tsunami BWA Logitech G5 
Mouse Pad
X-Ray Thunder 8 
  hide details  
Reply
post #6 of 7
Thread Starter 
here is a copy of the php document for the contact page (http://thefacesofhope.org/contact.html)
Quote:
<?php
// Set some variables
$recipient = 'lespaulplyr6@yahoo.com';
$subject = 'Contact Form Submission';
$from = stripslashes($_POST['Name of Facility'])."<".stripslashes($_POST['Email']).">";


// Build the message text
$message = "Person Making Referral: ".$_POST['Person Making Referral']."
Name of Facility: ".$_POST['Name of Facility']."
Address: ".$_POST['Street Address'] .$_POST['City'] .$_POST['State'] .$_POST['ZIP']."
Phone: ".$_POST['Phone']."
Fax: ".$_POST['Fax']."

Message:
".$_POST['Message'];



// Build the headers
$headers = "From: $from\
\
" .
"MIME-Version: 1.0\
\
" .
"Content-Type: multipart/mixed;\
\
" .
" boundary=\\"{$mime_boundary}\\"";

// Build the MIME message
$message = "This is a multi-part message in MIME format.\
\
" .
"--{$mime_boundary}\
" .
"Content-Type: text/plain; charset=\\"iso-8859-1\\"\
" .
"Content-Transfer-Encoding: 7bit\
\
" .
$message . "\
\
";
$message .= "--{$mime_boundary}\
" .
"Content-Type: {$type};\
" .
" name=\\"{$name}\\"\
" .
"Content-Transfer-Encoding: base64\
\
" .
$data . "\
\
" .
"--{$mime_boundary}--\
";

// Send the mail
mail($to, $subject, $message, $headers)

?>
Thanks for the code btw... helped a lot!
When I submit the form, I get a 500 Error, but I can't seem to find the origin of the problem. What do you think is wrong with the script?
Maelstrom
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 Gigabyte DS3LR eVGA 9800GTX+ 4x2gb G.Skill Ripjaws 
Hard DriveOSMonitorKeyboard
Seagate 500gb perp Windows 7 x64, Ubuntu 9.10 beta 23" Samsung, 22" Acer AL2223, 19" Hanns-G Logitech G15 
PowerCaseMouse
Ultra X-Finity 600W NZXT Alpha Logitech G7 
  hide details  
Reply
Maelstrom
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 Gigabyte DS3LR eVGA 9800GTX+ 4x2gb G.Skill Ripjaws 
Hard DriveOSMonitorKeyboard
Seagate 500gb perp Windows 7 x64, Ubuntu 9.10 beta 23" Samsung, 22" Acer AL2223, 19" Hanns-G Logitech G15 
PowerCaseMouse
Ultra X-Finity 600W NZXT Alpha Logitech G7 
  hide details  
Reply
post #7 of 7
500 is Internal Server Error. You don't need all that MIME junk for a plain contact form. Use this:

Code:

                              <?php
// Set some variables
$recipient = 'lespaulplyr6@yahoo.com';
$subject = 'Contact Form Submission';
$from = stripslashes($_POST['Name of Facility'])."<".stripslashes($_POST['Email']).">";


// Build the message text
$message = "Person Making Referral: ".$_POST['Person Making Referral']."
Name of Facility: ".$_POST['Name of Facility']."
Address: ".$_POST['Street Address'] .$_POST['City'] .$_POST['State'] .$_POST['ZIP']."
Phone: ".$_POST['Phone']."
Fax: ".$_POST['Fax']."

Message:
".$_POST['Message'];

// Build the headers
$headers = "From: $from";
    
// Send the mail
mail($recipient, $subject, $message, $headers);

?>
Neuron
(13 items)
 
  
CPUMotherboardGraphicsRAM
Pentium D 805 (Dual Core) ASRock 775Twins-HDTV XFX GeForce 6600 1GB DDR 
Hard DriveOptical DriveOSMonitor
480GB Total 2x DVD-RW (1x LightScribe) Ubuntu Philips 170B 17in 
KeyboardPowerCaseMouse
Logitech G15 Thermaltake TR2 430W Thermaltake Tsunami BWA Logitech G5 
Mouse Pad
X-Ray Thunder 8 
  hide details  
Reply
Neuron
(13 items)
 
  
CPUMotherboardGraphicsRAM
Pentium D 805 (Dual Core) ASRock 775Twins-HDTV XFX GeForce 6600 1GB DDR 
Hard DriveOptical DriveOSMonitor
480GB Total 2x DVD-RW (1x LightScribe) Ubuntu Philips 170B 17in 
KeyboardPowerCaseMouse
Logitech G15 Thermaltake TR2 430W Thermaltake Tsunami BWA Logitech G5 
Mouse Pad
X-Ray Thunder 8 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding