Form with CMS

5 posts by 3 authors in: Forums > CMS Builder
Last Post: June 23, 2011   (RSS)

I am using a form on my web site for customer support

<?php
require_once "../cmsAdmin/lib/init.php";

// process form
if (@$_REQUEST['submitForm']) {

// error checking
$errorsAndAlerts = "";
if ([url "mailto:!@$_REQUEST['fullname'"]!@$_REQUEST['fullname'[/url]]) { $errorsAndAlerts .= "You must enter your full name!<br/>\n"; }
if ([url "mailto:!@$_REQUEST['email'"]!@$_REQUEST['email'[/url]]) { $errorsAndAlerts .= "You must enter your email!<br/>\n"; }
else if(!isValidEmail(@$_REQUEST['email'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }
if ([url "mailto:!@$_REQUEST['message'"]!@$_REQUEST['message'[/url]]) { $errorsAndAlerts .= "You must enter a message!<br/>\n"; }

// send email user
if (!$errorsAndAlerts) {
$from = $_REQUEST['email'];
$to = "test@test.com";
$subject = "Email form submitted from {$_SERVER['HTTP_HOST']}";
$message = <<<__TEXT__
You've received an email from the email form here:
[url "http://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME'"]http://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME'[/url]]}

Full name: {$_REQUEST['fullname']}
Email: {$_REQUEST['email']}
Message: {$_REQUEST['message']}

The user who sent this message had the IP address {$_SERVER['REMOTE_ADDR']}.
__TEXT__;
// Note: The above line must be flush left or you'll get an error
// This is a PHP heredoc. See: http://ca2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

// send message
$mailResult = @mail($to, $subject, $message, "From: $from");
if (!$mailResult) { die("Mail Error: $php_errormsg"); }

//
$errorsAndAlerts = "Thank you for contacting Axis Lighting. We will do our best to get back to you as quickly as possible.";
$_REQUEST = array(); // clear form values
}

}

?>



My question is can I make it have a field to upload an attachment as well?

Re: [dccreatives] Form with CMS

By Jason - June 23, 2011

Hi,

I did a google search for "PHP contact form with upload and got quite a few results returned.

Here is one article that looked like it matched what you're looking for:
http://www.html-form-guide.com/email-form/php-email-form-attachment.html

I haven't tried this myself, but it looks like it should get you pointed in the right direction.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Form with CMS

Thanks. I will check it out and let you know if it works.

Do you think I can use it with the form code that I indicated above? IF not, I'll use this one.

Re: [dccreatives] Form with CMS

By Jason - June 23, 2011

Hi,

The form code is probably fine, the issue will be handling the file upload.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/