Simple php form help, I think (checkboxes)
I need a bit of help with some checkboxes in a form being proccessed with php.
I'm using an array to collect the information then having it emailed.
<input name="colours[]" value="Red" type="checkbox">Red <br />
<input name="colours[]" value="Blue" type="checkbox">Blue <br />
<input name="colours[]" value="Green" type="checkbox">Green <br />
<input name="colours[]" value="Yellow" type="checkbox">Yellow <br />
What I'm getting back in the email at the moment is:
I'm interested in these colours: Array
Below is the $body of the message:
$body = "Please contact me regarding the following:\r\n\r\n";
$body .= "Name: ".stripslashes($_POST['name'])."\r\n";
$body .= "Address: ".stripslashes($_POST['address'])."\r\n";
$body .= "Postcode: ".stripslashes($_POST['postcode'])."\r\n";
$body .= "Telephone: ".stripslashes($_POST['telephone'])."\r\n";
$body .= "Email: ".stripslashes($_POST['email'])."\r\n";
$body .= "I'm interested these colours: ".$_POST['colours']."\r\n";
I guess I need some more php to desl with the array?????
Thanks
Os
Duplicate post. Original has been moved to Dreamweaver Application Development. Locking this thread.
Similar Messages
-
I just developed a simple php form (my first time). I am
trying to enable the information that is typed in the form by
visitors, to be emailed directly to me. So far I can only get the
person's email address and message left in information box to be
sent to my email address. However, there are other contents within
the form that I also need to receive. Can anyone help.
http://www.newnie.com/informationform.php
http://www.newnie.com/handle_form.phpOn 18 Oct 2007 in macromedia.dreamweaver.appdev, CellaMarr
wrote:
> When I fill out the form and press send the only
information that I
> receive is the "First Name", "Email Address", and
"Project Details".
> All the other info does not show up. Why will it only
send some of
> the information and not all of it? ("Phone Number",
"Profession",
> "Budget", "Hosting", and "Domain")
Because you're not telling it to send them to you. Consider:
$success = mail($to, $subject, $detail, $headers);
This line is correct and sends the email as it should. You're
telling
it that you want $detail as the body of the message. However,
when you
load variables:
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$detail = $_POST['detail'];
$profession = $_POST['profession'];
$entertainer = $_POST['entertainer'];
$domain = $_POST['domain'];
$hosting = $_POST['hosting'];
$subject = 'Message from newnie.com'; // this is the subject
line. you
can make this say whatever you want
$headers = "From: $name <$email>\n";
$headers .= "Reply-To: $name <$email>\n";
$to = '[email protected]'; //change this to your email
you're only putting the contents of the 'detail' form field
into
$detail. You need to do something more like:
$body = 'Name: ' . $_POST['name'] . "\n";
$body .= 'EMail: ' . $_POST['email'] . "\n";
$body .= 'Number: " . $_POST['number'] "\n";
// etc
$subject = 'Message from newnie.com'; // this is the subject
line. you
can make this say whatever you want
$headers = "From: $name <$email>\n";
$headers .= "Reply-To: $name <$email>\n";
And your mail() statement becomes:
$success = mail($to, $subject, $body, $headers);
Joe Makowiec
http://makowiec.net/
Email:
http://makowiec.net/contact.php -
PHP form help - results not appearing in email
Hi I have set up a simple entry form, and I am submiting it
using PHP to my email address, It works well when you fill the form
in and send it, I receive the email however the email only displays
the questions and not the answers that have been filled in on the
form. Itss driving me crazy as top why this is not working. Can
someone please help?
here is my form code, both form and PHP. ThanxI haven't checked the form, but I had a similar problem with
my server when they upgraded their systems recently. I would
receive the email, but it was blank.
Th reason was ...
As long as your scripts do not need "register_globals" they
will work.
The default php mail command works. Again - no
"register_globals".
A lot of old and lazy written scripts rely on it. But it is a
major
security risk - even more so on shared servers - and as such
has been
disabled by default in PHP since version 3.0.3. -
I've made several php forms that work perfectly. I used the NateMail php script.
For some reason this one http://bravocleaningmn.com/contact.html is not working.
Any help would be greatly appreciated!PHP is either not installed and running on the server, or it hasn't been enabled for your hosting account, from what I can tell.
-
I have posted this before a while back, but never figured it
out. I think I am really close.
When my form gets clicked, the following gets triggered:
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
this.tf_showAlertMsg.text = "Thank you for sending us an
email";
} else {
this.tf_showAlertMsg.text = "Email did not go through";
var send_lv:LoadVars = new LoadVars();
send_lv.Name = tName;
send_lv.FromEmail = tEmail;
send_lv.Subject = tSubject;
send_lv.Comments = tMsg;
send_lv.Newsletter = tCheckBox;
send_lv.status = "";
send_lv.sendAndLoad("php/sendContact.php",result_lv,"POST");
this.showAlertMsg("Sending...");
Everything gets sent and all is working great. The only thing
that does not work is the ifStatement in the result_lv never gets
triggered. I think that this has to do with my php. I don't really
speak php and so I am having issues with it.
In the php I have two echos, which I was told I could use
with the result_lv. I think that my result_lv, does either not know
what it is listening to, or that my echos are wrong. The echos in
the php look like this.
//if($debug)
echo "mes1 $ToEmailType $ToEmail $Subject $Message From:
$Name $FromEmail\n ";
and
echo "&Status=Your quote request has been sent.";
What do I have to do, so Flash receives the echo and I can
tell the user that the info has been received.
Thanks a lot for help with this!OK, great, I am getting closer! Thank you so much.
I now get the "Email did not go through" case. The email gets
sent though, so I am not sure why that is happening. I am assuming,
where you say //find out if it's working first is working because
the if statement gets triggered.
How can I proceed from here?
Thank you so much! -
Can you auto-attach files in a PHP form?
Hi there,
Have been looking over everywhere for a solution to my problem. I am going to try and be as clear as I can about the problem.
I have had some experience making simple PHP forms that let the user put their name, email, subject and body text and send it in an email using the form.
But for a project I am currently undertaking - the client has requested a form that will pre-attach a particular document to the email when it is sent. All the user has to do is input the email address of the adressee and their name/email address and all the other fields are custom made (i.e. subject, body text) - and the email will be sent to the selected recepient with the file already attached.
I was envisaging the PHP script would collect the reference for a file that is already sitting on the web server and attach it in the function.
Is there anyway to do this? Because if it isn't I may as well tell the client to go and use outlook - because the web form will really have no purpose.
Thanks in advanceHi have proceeded along the path of inserting links
into PHP generated email but I am having trouble in outputting the body message in HTML - All I get out
in the output email is the HTML tags with the text (plain text).
Did some research and found out that I have to determine the content type/charset.
I have tried to do this in my PHP but to no avail. Also I am not getting the email or name of the sender in the email that is generated....
Anyway, there is the PHP code (and it's not that tight but it works):
AND SOME DEFAULT TEXT THAT WILL CONTAIN LINKS TO NECESSARY FILES TO DOWNLOAD:
link to PDF '.$field_message; $headers = 'From: '.$cf_yremail."\r\n"; $headers .= 'Reply-To: '.$cf_yremail."\r\n"; /* If your e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $mail_to)) { ?>
Any help on this would be much appreciated....
Thanks -
Need help with PHP form with checkboxes, radio buttons and file attachment
Hi guys,
I'm having a nightmare with this PHP form where a user can fill it in, attach a doc/pdf and submit. After trying to sort it out with previous code I've used, I've stripped it out and think I should just start again in the hope you geniuses can help!
Here is the HTML of contact.php:
<form action="" method="post" name="contact" id="contact">
<p>Job Title:*<br />
<input name="position" type="text" /></p>
<p>Nationality:*<br />
<select name="nationality">
<option value="">-- select one --</option>
<option value="Afghan">Afghan</option>
<option value="Albanian">Albanian</option>
<option value="Algerian">Algerian</option>
<option value="Zambian">Zambian</option>
<option value="Zimbabwean">Zimbabwean</option>
</select>
</p>
<p>Which country are you currently living in?*<br />
<select name="country">
<option value="">-- select one --</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Africa">Africa</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>
</p>
<label class="radio" for="checkRight">Yes/No question?</label><br />
<input class="radio" type="radio" name="right" value="Yes" /> Yes
<input class="radio" type="radio" name="right" value="No" /> No
<input class="radio" type="radio" name="right" value="N/A" /> Not applicable
<p>Yes/No question?<br />
<select name="continue">
<option value="">-- select one --</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</p>
<p>Select your resorts:<br />
Resort 1<input name="res1" type="checkbox" value="Resort 1" />
Resort 2<input name="res2" type="checkbox" value="Resort 2" />
Resort 3<input name="res3" type="checkbox" value="Resort 3" />
Resort 4<input name="res4" type="checkbox" value="Resort 4" />
Resort 5<input name="res5" type="checkbox" value="Resort 5" />
Resort 6<input name="res6" type="checkbox" value="Resort 6" />
</p>
<p>Don't send form unless this is checked:* <input type="checkbox" name="parttime" value="Yes" /></p>
<p>Date of arrival: <input name="arrive" id="datepick" /><br />
Date of departure: <input name="depart" id="datepick2" /></p>
<script type="text/javascript" src="assets/scripts/datepickr/datepickr.js"></script>
<link href="assets/scripts/datepickr/datepickr.css" rel="stylesheet">
<script type="text/javascript">
new datepickr('datepick');
new datepickr('datepick2', {
</script>
<p>Name:*<br />
<input name="name" type="text" /></p>
<p>E-mail:*<br />
<input name="email" type="text" /></p>
<p>Telephone:*<br />
<input name="telephone" type="text" class="ctextField" /></p>
<p>Upload CV (Word of PDF formats only):<br />
<input type="file" name="cv" class="textfield"></p>
<p><input name="submit" value="Submit Enquiry" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
</form>
By the way, the date boxes work so excuse the Javascript in there!
To prevent SPAM I've used a trick where there's a hidden URL field which must be left blank for the form to submit which you can see in the PHP.
Below is where I'm at with the PHP which is placed above the header of contact.php...
<?php
if (array_key_exists('submit', $_POST)) {
$position = $_POST['position'];
$arrive = $_POST['arrive'];
$nationality = $_POST['nationality'];
$parttime = $_POST['parttime'];
$depart = $_POST['depart'];
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$to = "[email protected]";
$subject = "Recruitment Application";
$message = $headers;
$message .= "Name: " . $_POST["name"] . "\r\n";
$message .= "E-mail: " . $_POST["email"] . "\r\n";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= 'From: My Website <[email protected]>' . "\r\n";
$message= "
$url = stripslashes($_POST["url"]);
if (!empty($url)) {
header( 'Location: http://www.go-away-spam-robots.com' );
exit();
if (!isset($warning)) {
mail($to, $subject, $message, $headers);
header( 'Location: http://www.mywebsite.co.uk/sent.php' );
?>
I would like to make pretty much all the field compulsory so if a field is left empty (other than the hidden URL field), a warning message is displayed next to that field.
Also I would like the file upload field to attach to the email that is sent to me and have the results come through to me in a table format.
Can anyone help me get my form working?
Thank you and I hope to hear from you!
SMHi Nancy,
Great stuff, thank you for the reply.
I've managed to get the Formm@iler working and running as I need it to.
The only thing I'm struggling with is when the user clicks submit, they are taken to a page of whatever results the form returned but it is just a white background with Times New Roman text.
How can I have it so the user is taken to the form results in the websites' page layout?
I tried sending them to a generic 'thank you' page by adding the following code but it just took them there whatever the results of the form so that's no good...! I have a feeling it's a bit more complicated than that...
header( 'Location: http://www.nofussbus.co.uk/test/sent.php' );
Thank you for your help! -
Php form mailer/Flash help
I have a php form that I am using with my Flash file. It
works great so far, but I would like to get confirmation from the
php in the Flash file, that the info has really been sent. I think
it is already sent up in the php, but I don't know how to handle it
in my Flash file. The php file is attached. Do I use the echo? How
would I do that? What I want, is in my Flash file to say sending,
until I get then feedback from the php, and then say, sent
successfully.
Thanks a lot for any help!It is all inside an ifStatment that is inside a function,
which gets called by the button that send the form. Here is the
full thing.
function validateForm(tName:String, tEmail:String,
tSubject:String, tMsg:String):Void {
trace("validateForm was called");
if (tName == "" || tName == undefined) {
trace("tName if");
this.showAlertMsg("Please enter your name");
} else if (tEmail == "" || tEmail == undefined ||
tEmail.indexOf("@") == -1 || tEmail.indexOf(".") == -1) {
trace("Invalid email address: "+tEmail+" infexOf1:
"+tEmail.indexOf("@")+" indexOf2: "+tEmail.indexOf("."));
this.showAlertMsg("Invalid email address");
} else if (tSubject == "" || tSubject == undefined) {
trace("tSubject if");
this.showAlertMsg("Please enter a subject");
} else if (tMsg == "" || tMsg == undefined) {
trace("tComments if");
this.showAlertMsg("Please enter some comments");
} else {
trace("the else was called...");
var send_lv = new LoadVars();
//send_lv.onLoad = ShowStatus;
//send_lv.EmailType = "Quote";
send_lv.Name = tName;
send_lv.FromEmail = tEmail;
send_lv.Subject = tSubject;
send_lv.Comments = tMsg;
send_lv.status = "";
send_lv.sendAndLoad("php/sendContact.php",result_lv,"Post");
this.showAlertMsg("Sending...");
var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
this.tf_showAlertMsg.text = "Thank you for sending us an
email";
} else {
this.tf_showAlertMsg.text = "Email did not go through";
function showAlertMsg(msg:String):Void {
this.tf_showAlertMsg.text = "";
this.tf_showAlertMsg.text = msg;
this.send_btn.onRelease = function() {
validateForm(tf_Name,tf_Email,tf_Subject,tf_Comments);
I tried the new way Dave posted and it still does not get the
echo from the form.
Thanks so much to both of you for the help! -
I just replaced an adobe formscentral contact form with the muse simple contact form. It is not working, receiving a php server error when submitting. How can I fix this?? I'm hosting through Amazon Route53.
Issue is here: CONTACTHi,
I was able to submit the form, kindly let me know if you are still facing the issue.
Regards
Sonam -
Need help with simple php files
I have simple php files that are setup with includes for a header, sidebar and footer... all other data is within the file. There is no dynamic info on the pages, yet I cannot get the files to load up in InContext. Is there a way to make this work?
I can get an html file to work flawless, but something seems to stop the php file from working.
Thanks,
Ken HendersonWhat I mean is, whenever I try to edit any file with a php extension, I get a 404 error... even a simple file with no includes. I created a php file with one line of text within an editable region and I still could not edit it with InContext.
The site I'm trying to work with is http://www.thunderbirdchemical.com
The homepage is index.php
The simple test file I made is test.php
Thanks for your help.
Ken -
Hi all
would someone beable to help?
I have been using a free php form data script on my website but I am finding that when people fill in the form that not all the form submissions are getting through and I am not sure if it is the php form script
Would any one be to direct me to a good free php data script that is simple to use
many thanks for your help!hi there
many thanks for your help!
ok, am little new to this, so do you mean in my contact.php script I have?
not sure what I would be looking for?
I tried to attach to this post but copuld so zipped it for download here; http://www.thevineproject.org.uk/contact.zip
thanks for your help -
PHP Form Emailing Fields But No Data
Hello,
I am running into a little problem with my PHP form script. I am able to email my form and receive a message, however the message has no data, except for where I have check boxes. Can anyone help me solve this dilemma? Some of the code has been remove intentionally.
I will post my code:
<?php
/* Email Variables */
$emailSubject = ' Registration Form';
$webMaster = 'de';
/* Data Variables */
$registrationname = $_POST['registrationname'];
$registrationphone = $_POST['registrationphone'];
$registrationemail = $_POST['registrationemail'];
$registrationdistrict = $_POST['registrationdistrict'];
$registrationposition = $_POST['registrationposition'];
$onecredit = $_POST['onecredit'];
$twocredit = $_POST['twocredit'];
$threecredit = $_POST['threecredit'];
$body = <<<EOD
<br><hr><br>
Name of Register: $registrationname <br>
Day Time Phone Number: $registrationphone <br>
Email Address of Register: $registrationemail <br>
Name of School District: $registrationdistrict <br>
Position/Job Title: $registrationposition <br>
Register for 1 Credit: Learning to Use the easyCBM Assessment System: $onecredit <br>
Register for 2 Credits: In-Depth Knowledge of the easyCBM Assessment System: $twocredit <br>
Register for 3 Credits: Enroll in Both of the Above Options: $threecredit <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="6;URL=http://.html">
<style type="text/css">
<!--
body {
background-color: #D9D3A9;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #000000;
text-decoration: none;
padding-top: 200px;
margin-left: 200px;
width: 800px;
-->
</style>
</head>
<div align="center">Thank you! Your request has been sent.
You will return to the page in a few moments.</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>1) I would bring the line <cfoutput query="CheckUser"> lower down in the code, for example, just before the first table tag.
2)These are probably mistakes
<<table border="0" align="center" cellpadding="0" cellspacing="0">
<input type="hidden" name="LogDate" value="Now()">
I think they should be
<table border="0" align="center" cellpadding="0" cellspacing="0">
<input type="hidden" name="LogDate" value="#Now()#">
3) You could revise the action page to:
<cfif isDefined("form.logDate")>
<cfinsert datasource="manna_premier" formfields="LogDate,TerritoryManager,Status,DSRName,ServiceName" tablename="TMStatusLog">
<cflocation url="mp_order_form.cfm">
</cfif>
The table TMStatusLog must of course have columns LogDate, TerritoryManager, Status, DSRName and ServiceName. -
I used this script
http://www.visibilityinherit.com/code/php-form-validation.php
to produce a form and everything worked fine on my site, which I
was using for testing. When I transferred over to the client's site
it doesn't send the email. The error and thank you messages work,
but no email. As I have heard that some hosts block some php files
with the name 'formmail' I called it something else.
I have checked and rechecked all the data and only my email
address and the URLs for the error and thank you pages had to be
changed, my email is correct, but still not email.
Any ideas as to what is happening and how I can get around it
please?
RosalindI have been sent the following information and code, but have
not succeeded in working out where to add it. The code I am using
is underneath. Many thanks
- to send emails through our servers you must comply with one
of the following rules
a. The sending email must be from your domain
b. The receiving email must be from your domain
This account could/should be [email protected]
- To avoid a wrong use of our scripts by spammers you must
had a line before you call the “mail” functionality
ini_set("sendmail_from", " [email protected] ");
- Please add to the email send code a functionality
“-f” in the fifth parameter of the function send mail
- This is the simple configuration of sending emails in php
<?php
ini_set("sendmail_from", [email protected]);
mail($email_to, $email_subject, $email_message, $headers,
'-f'[email protected]);
?>
my php code is
<?php
// Input Your Personal Information Here
$mailto = '[email protected]' ;
$from = "FormosaParadise.com" ;
$formurl = "
http://formosaparadise.com/correios.php"
$errorurl = "
http://formosaparadise.com/formmailerror.php"
$thankyouurl = "
http://formosaparadise.com/thankyou.php"
// End Edit
// prevent browser cache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "
GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function remove_headers($string) {
$headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i"
if (preg_replace($headers, '', $string) == $string) {
return $string;
} else {
die('You think Im spammy? Spammy how? Spammy like a clown,
spammy?');
$uself = 0;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" :
"\n" ;
if (!isset($_POST['email'])) {
header( "Location: $errorurl" );
exit ;
// Input Your Personal Information Here
$name = remove_headers($_POST['name']);
$email = remove_headers($_POST['email']);
$phone = remove_headers($_POST['phone']);
$comments = remove_headers($_POST['comments']);
$http_referrer = getenv( "HTTP_REFERER" );
// End Edit
if
(!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i",$email))
header( "Location: $errorurl" );
exit ;
// Input Your Personal Information Here
if (empty($name) || empty($email) || empty($phone)
||empty($comments)) {
header( "Location: $errorurl" );
exit ;
// End Edit
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
// sets max amount of characters in comments area (edit as
nesesary)
if (strlen($comments) > 1250) {
$comments=substr($comments, 0, 1250).'...';
// End Edit
$message =
"This message was sent from:\n" .
"$http_referrer\n\n" .
// Input Your Personal Information Here
"Name: $name\n\n" .
"Email: $email\n\n" .
"Phone No: $phone\n\n" .
"Comments: $comments\n\n" .
"\n\n------------------------------------------------------------\n"
// End Edit
mail($mailto, $from, $message,
"From: \"$name\" <$email>" . $headersep . "Reply-To:
\"$name\" <$email>" . $headersep );
header( "Location: $thankyouurl" );
exit ;
?> -
Hi. I got a program to write a php form processing script. My submit form is for photo submission to my domain email. I published to site and did a test to see if it works i got this error:
Warning: require_once(F:\Domains\mydomain\mydomain.com\wwwroot/includes/Upload_Photos-lib.php): failed to open stream: No such file or directory in F:\Domains\mydomain\mydomain.com\wwwroot\Upload_Photos.php on line 24 Fatal error: require_once(): Failed opening required 'F:\Domains\mydomain\mydomain.com\wwwroot/includes/Upload_Photos-lib.php' (include_path='.;C:\php\pear') in F:\Domains\mydomain\mydomain.com\wwwroot\Upload_Photos.php on line 24
What does this mean? How can i solve this so that i can process my form?See if the below form helps: You need to create a folder on your server named - upload - this is where any files uploaded will be stored (make sure the folder is writable. Also change the email address where the information that someone who has uploaded a file will go to. Look for the following in the code: $to ="XXXXXXXXXXXX.com";
<!DOCTYPE html>
<head>
<meta charset="UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
#wrapper {
width: 400px;
margin: 0 auto;
</style>
</head>
<body>
<div id="wrapper">
<?php if(isset($_POST['submit'])) {
$name = trim($_POST['name']);
if(empty($name)) {
$error['name'] = "Please provide your name";
$location = trim($_POST['location']);
if(empty($location)) {
$error['location'] = "Please provide your location";
$email = trim($_POST['email']);
if(empty($email)) {
$error['email'] = "Please provide your email";
$category_description = trim($_POST['category_description']);
if(empty($category_description)) {
$error['category_description'] = "Please provide the category or description";
$terms_conditions = trim($_POST['terms_conditions']);
if(empty($terms_conditions)) {
$error['terms_conditions'] = "Please accept the terms & conditions";
$allowedExts = array(
"doc",
"docx",
"rtf",
"txt",
"pdf",
"jpeg",
"jpg",
$allowedMimeTypes = array(
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/rtf',
'application/x-rtf',
'text/richtext',
'text/rtf',
'application/plain',
'application/pdf',
'image/gif',
'image/jpeg',
$extension = end(explode(".", $_FILES["file"]["name"]));
if (empty($_FILES["file"]["name"])) {
$selectFile = 'Please select a file to upload';
elseif ( ! ( in_array($extension, $allowedExts ) ) ) {
$fileTypeNotAllowed = 'File type not allowed';
elseif ($_FILES["file"]["size"] > 2097152) {
$fileTooLarge = 'Please provide a smaller file';
elseif (file_exists("upload/" . $_FILES["file"]["name"])) {
$fileExists = $_FILES["file"]["name"] . " already exists, Please change the file name ";
elseif (in_array( $_FILES["file"]["type"], $allowedMimeTypes ) )
if(!empty($_POST['terms_conditions'])) {
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
$fileName = $_FILES["file"]["name"];
$fileUploadSuccessful = 'File uploaded successfully';
$to = "XXXXXXXXXXXXX.com";
$subject = "Upload to website";
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
$message = "Name: $name\n\n";
$message .= "Location: $location\n\n";
$message .= "Email Address: $email\n\n";
$message .= "Category/Description: $category_description\n\n";
$message .= "File: $fileName\n\n";
mail($to, $subject, $message, $headers);
$sent = "Mail was sent successfully";
?>
<h1>Form</h1>
<?php
foreach ($error as $value) {
echo "<p>".$value."</p>";
if(isset($formFieldError)) {
echo "<p>".$formFieldError."</p>";
if(isset($selectFile)) {
echo "<p>".$selectFile."</p>";
if(isset($fileTypeNotAllowed)) {
echo "<p>".$fileTypeNotAllowed."</p>";
if(isset($fileTooLarge)) {
echo "<p>".$fileTooLarge."</p>";
if(isset($fileExists)) {
echo "<p>".$fileExists."</p>";
if(isset($fileUploadSuccessful)) {
echo "<p>".$fileUploadSuccessful."</p>";
?>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<p>
<label for="name">Name<br>
<input type="text" name="name" id="name" value="<?php if(isset($name)) {echo $name; } ?>"/>
</label>
</p>
<p>
<label for="location">Location<br>
<input type="text" name="location" id="location" value="<?php if(isset($location)) {echo $location; } ?>"/>
</label>
</p>
<p>
<label for="email">Email<br>
<input type="text" name="email" id="email" value="<?php if(isset($email)) {echo $email; } ?>" />
</label>
</p>
<p>
<label for="category_description">Category and Description<br>
<input type="text" name="category_description" id="category_description" value="<?php if(isset($category_description)) {echo $category_description; } ?>" />
</label>
</p>
<p>
<label for="file">File Attachment:<br>
<input type="file" name="file" id="file" />
</label>
</p>
<p>
<label for="terms_conditions">Terms & Conditions:
<input name="terms_conditions" type="checkbox" value="accept" <?php if(isset($_POST['terms_conditions'])) {echo "checked"; } ?>> (Please check)
</label>
</p>
<input type="submit" name="submit" value="Submit" />
</form>
</div>
</body>
</html> -
PHP Form Redirect without Header function
I need help with a PHP form that needs to redirect to a thankyou page upon sending. I have tried the header function but it doesnt work because i have multiple PHP references throughout the page that prevent the header function from working. Is there another way to redirect once the email sends? I am leaving out the rest of the form and functions but this is what i have currently that affects the message sending:
In form page requestquote.php:
<? include('sendemail.php'); if($cmsg) echo"<h1>".$cmsg."</h1>"; else { ?>
In sendemail.php:
mail($recipient, $subject, $formcontent, $mailheader) or die("There was an error in your request. Please go back and try again.");
$cmsg="Thank for you requesting a quote. A Blue Grace Representative will contact you shortly." ;
Thanks,
BenI need the thankyou page for conversion tracking on the website, which cant be done with a simple message. Thats what i have currently in the form.
If i put the code in the form action area, will it redirect only upon sending? I want to make sure it goes through the process of validating all the fields and sending the email before it redirects.
Thanks,
Ben
Maybe you are looking for
-
The cost of the games is very high.where can i get the games for free?????
-
Mavericks RAID 1 unreliable?
Short version: RAID 1 array rebuild is failing with one drive working in the set, but failing after an hour or two (variable) attempting to rebuild to another drive. I've changed drive and drive bay and the rebuild still fails. The apparently working
-
Hello, I have a link to a pdf file in a table which is displayed in a report. How do I open the pdf file from the report. Any help greatly appreciated. Sharon
-
Oracle AQ - dequeue multiple threads
Hi, I have a single consumer AQ queue containing 1000 records. I have a bpel process that dequeues from the queue and performs some action. I need to have 10 processed polling from the queue at a time and performing the post xyz task. When any one of
-
Validation expression, with a Boolean field
Hello, My issue is as follow: I want to make sure that if attribute 'A' = "1"; then attribute 'B' has values. Note: attribute 'A' is boolean. I did not succeed in setting up such a formula [I succeeded in setting up the opposite formula only: IF(Att