Text box in email form

This is a discussion on "Text box in email form" within the PHP Forum section. This forum, and the thread "Text box in email form are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 21st, 2007, 17:31
Junior Member
Join Date: Dec 2006
Location: illinois
Age: 20
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Text box in email form

I added a form to a website where there is a long list of products (about 200) and there is a quantity box next to each of them. When the form is sent The email contains all of the products and the ones that were selected have the quantity number next to them. Is it possible to only have the ones that were selected sent? It works fine if I use a check box instead of a text box but I need to have a quantity with it. Also the script I am using to send is PHP.

Thanks
Reply With Quote

  #2 (permalink)  
Old Jun 21st, 2007, 17:51
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

The first thing that comes to mind is a regex test for an if construct, assuming your buyer puts a digit in the textbox.
Reply With Quote
  #3 (permalink)  
Old Jun 21st, 2007, 18:03
Junior Member
Join Date: Dec 2006
Location: illinois
Age: 20
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

Im sorry. I have no idea what that means. I don't know a lot about php. below is a link to the site and the php script i am using(i didnt write it). Hope someone can help me out.

http://temphost.webofamerica.net/midwest%20agri%2Dservice/products.html

It is on a temp domain for right now. and the flash at the top will not load.


This is the php script
PHP: Select all

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject 'Results from Contact form';

// Your email address. This is where the form information will be sent.
$emailadd 'design@webofamerica.net';

// Where to redirect after form is processed.
$url 'http://www.google.com;

// Makes all fields required. If set to '
1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '
0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '
1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('
n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, '
From'.$emailadd.'');
echo '
<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">;
?>
Right now I do not have all of the products set up. When the email sends it will look like this

2,4-D_AMINE__2_1/2: 2
2,4-D_AMINE__30:
2,4-D_LV4: 3
2,4-D_LV6__2_1/2:
2,4-D_LV6__30: 4
ACCENT_DF_:
Name: Mat
Address: 734 4th st sterling il
Phone: 555-6066
Email: gds@hdsj.com
Submit: Submit

There is a 2, 3 and 4 next to the products that were selected. When I have all of them sent there will be just too many to sort through and that Is why I only want the selected boxes to send.

Last edited by karinne; Jun 22nd, 2007 at 18:41. Reason: Please use [ php ]...[ /php ] tags when displaying PHP code!
Reply With Quote
  #4 (permalink)  
Old Jun 21st, 2007, 19:58
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Text box in email form

Try this:

PHP: Select all

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject 'Results from Contact form';

// Your email address. This is where the form information will be sent.
$emailadd 'design@webofamerica.net';

// Where to redirect after form is processed.
$url 'http://www.google.com';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req '0';

// --------------------------Do not edit below this line--------------------------
$text "Results from form:\n\n";
$space ' ';
$line '
'
;
foreach(
$_POST as $key => $value) {
    if (
$req == '1') {
        if (
$value == '') {
            echo 
$key." is empty";
            die;
        }
    }
    if(
$value!="") {
        
$j strlen($key);
        if (
$j >= 20) {
            echo 
"Name of form element ".$key." cannot be longer than 20 characters";
            die;
        }
        
$j 20 $j;
        for(
$i 1$i <= $j$i++) {
            
$space .= ' ';
        }
        
$value str_replace('\n'"$line"$value);
        
$conc "{$key}:$space{$value}$line";
        
$text .= $conc;
        
$space ' ';
    }
}
mail($emailadd$subject$text'From: '.$emailadd.'');
echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
should work like you described.
Reply With Quote
  #5 (permalink)  
Old Jun 21st, 2007, 20:11
Junior Member
Join Date: Dec 2006
Location: illinois
Age: 20
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

That worked Exactly how I wanted it to. Thank you so much. Also How were you able to put the code in a box like that? I was trying to figure that out earlier.
Reply With Quote
  #6 (permalink)  
Old Jun 21st, 2007, 20:15
BGarner's Avatar
Reputable Member
Join Date: Oct 2006
Location: In front of the computer.
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

use [] and a word like html, code, quote. then close it like [/code]
Reply With Quote
  #7 (permalink)  
Old Jun 22nd, 2007, 13:20
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

To add to BG's advice, there is a specific code for php that will give it the right colors.
Reply With Quote
  #8 (permalink)  
Old Jun 22nd, 2007, 18:37
Junior Member
Join Date: Dec 2006
Location: illinois
Age: 20
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

ok thanks.

Something I noticed with the form is that if I put decimals "." in the input name of the text box they do not show up in the email. it changes them to underscores "_" Is there a way to fix that?
Reply With Quote
  #9 (permalink)  
Old Jun 23rd, 2007, 04:17
Junior Member
Join Date: Jun 2007
Location: Los Angeles
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Text box in email form

Use the str_replace() function after the fact.

RalphF
Domains & 4.99 Hosting
GoldRushWebHosting.com
Reply With Quote
Reply

Tags
email, form

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form Email Bravo81 PHP Forum 10 Jan 21st, 2008 23:37
PHP email form not sending email Kurt PHP Forum 1 Oct 12th, 2007 04:26
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
EMail Form Sabin_33 JavaScript Forum 12 Dec 4th, 2006 16:20
Email form using asp QuizToon Classic ASP 2 Mar 28th, 2006 00:25


All times are GMT. The time now is 20:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43