473,800 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Form Help!

22 New Member
I have this form setup to allow customers to fill in a little info and send an email to particular departments that they have their questions in. For some reason I cannot get it to work and in further playing around with it I get an HTTP 500 IS Error and it won't even load the page. Please help! Oh and I took the @ addres off the emails for this post. I know they're not there.

Expand|Select|Wrap|Line Numbers
  1.   $Dept   = $_REQUEST['Department'];
  2.   $First  = $_REQUEST['firstname'];
  3.   $Last   = $_REQUEST['lastname'];
  4.   $Com    = $_REQUEST['company'];
  5.   $Acc    = $_REQUEST['account'];
  6.   $Add    = $_REQUEST['adderss'];
  7.   $City   = $_REQUEST['city'];
  8.   $State  = $_REQUEST['state'];
  9.   $Zip    = $_REQUEST['zip'];
  10.   $Phone  = $_REQUEST['phone'];
  11.   $Email  = $_REQUEST['email'];
  12.   $Help   = $_REQUEST['help'];
  13.   $Sub    = $_REQUEST['subject'];
  14.   $Mess   = $_REQUEST['message'];
  15.  
  16.   $message = $First." ".$Last."\n";
  17.   $message .= $Com."\n";
  18.   $message .= $Acc."\n\n";
  19.   $message .= $Add."\n";
  20.   $message .= $City." ".",".$State." ".",".$Zip."\n";
  21.   $message .= $Phone."\n";
  22.   $message .= $Email."\n";
  23.   $message .= $Help."\n\n";
  24.   $message .= $Mess;
  25.  
  26.   switch ($Dept) 
  27.   {
  28.     case "Repair Parts":
  29.       $email_to = "rlacey", "hrichwine";
  30.       break;
  31.     case "Rebuilt Exchange Parts":
  32.       $email_to="rlacey", "hrichwine";
  33.       break;
  34.      case "Conversions & Conversion Kits":
  35.       $email_to="rlacey", "hrichwine";
  36.       break;
  37.     case "Test Equipment & Specialty Items":
  38.       $email_to="rlacey", "hrichwine";
  39.       break;
  40.     case "Test Equipment & Specialty Items":
  41.       $email_to="rlacey", "hrichwine";
  42.       break;
  43.     case "Customer Service":
  44.       $email_to="rlacey", "hrichwine";
  45.       break;
  46.     case "Account Receivable":
  47.       $email_to="kfatherree", "tfraker";
  48.       break;
  49.     case "Accounts Payable":
  50.       $email_to="jlehman", "tfraker";
  51.       break;
  52.     case "Service Schools":
  53.       $email_to="hrichwine";
  54.       break;
  55.     case "Rebuilt Exchange Parts":
  56.       $email_to="sfrank";
  57.       break;
  58.     case "Operations":
  59.       $email_to="ecowan", "eburkhart";
  60.       break;
  61.     case "President":
  62.       $email_to="bbowman", "hrichwine";
  63.       break;
  64.     case "Service Center":
  65.       $email_to="eburkhart", "ecowan";
  66.       break;
  67.     case "Sales / Marketing":
  68.       $email_to="pjones", "tgasull";
  69.       break;
  70.     case "Tech Support":
  71.       $email_to="dfreet", "ssteinour";
  72.       break;
  73.     default:
  74.       $email_to = "ijimenez";  // fail-safe value    
  75.   }
  76.   mail( $email_to, "Feedback Form Results", $message, "From: $email" );
Nov 28 '08
17 1947
Nyris
22 New Member
What kind of file does this need to point to? I'm still somewhat confused. Sorry x.x!
Dec 1 '08 #11
Dormilich
8,658 Recognized Expert Moderator Expert
any file that does form data processing. this includes PHP, ASP, Perl or any Server Side Script Language. but in your case it's the php file you originally posted.

regards
Dec 1 '08 #12
Nyris
22 New Member
The PHP file that I posted at the beginning is apart of the page that contains the form in. I put the PHP right above the form. So then I would just point it back to itself?
Dec 2 '08 #13
Dormilich
8,658 Recognized Expert Moderator Expert
@Nyris
yes. but make sure you do not process the script when loading the page for the first time. this is usually one by a check for post data
Expand|Select|Wrap|Line Numbers
  1. if (isset($_POST['send'])) // this should be the name of the submit button
  2. {
  3.   // process form data
  4. }
and one more note. when you specify the post protocol for data sending, you should use $_POST instead of $_REQUEST (for security reasons).
Dec 2 '08 #14
Nyris
22 New Member
I no longer get an error when I hit the send button!!! Getting somewhere, thanks a lot for your help so far Dormilich. I still didn't receive an email from it though, however.

This is how I have it setup now with the above if statement you suggested to me.

Expand|Select|Wrap|Line Numbers
  1.  <td colspan="2"><div align="center"><input type="submit" value="Send" name="send"/>
  2.     <?php
  3.     if (isset($_POST['send'])) // this should be the name of the submit button 
  4.   $Dept   = $_POST['Department'];
  5.   $First  = $_POST['firstname'];
  6.   $Last   = $_POST['lastname'];
  7.   $Com    = $_POST['company'];
  8.   $Acc    = $_POST['account'];
  9.   $Add    = $_POST['adderss'];
  10.   $City   = $_POST['city'];
  11.   $State  = $_POST['state'];
  12.   $Zip    = $_POST['zip'];
  13.   $Phone  = $_POST['phone'];
  14.   $Email  = $_POST['email'];
  15.   $Help   = $_POST['help'];
  16.   $Sub    = $_POST['subject'];
  17.   $Mess   = $_POST['message'];
  18.  
  19.   $message = $First." ".$Last."\n";
  20.   $message .= $Com."\n";
  21.   $message .= $Acc."\n\n";
  22.   $message .= $Add."\n";
  23.   $message .= $City." ".",".$State." ".",".$Zip."\n";
  24.   $message .= $Phone."\n";
  25.   $message .= $Email."\n";
  26.   $message .= $Help."\n\n";
  27.   $message .= $Mess;
  28.  
  29.   switch ($Dept) 
  30.   {
  31.     case "Repair Parts":
  32.       $email_to = "rlacey". "hrichwine";
  33.       break;
  34.     case "Rebuilt Exchange Parts":
  35.       $email_to="rlacey". "hrichwine";
  36.       break;
  37.      case "Conversions & Conversion Kits":
  38.       $email_to="rlacey". "hrichwine";
  39.       break;
  40.     case "Test Equipment & Specialty Items":
  41.       $email_to="rlacey". "hrichwine";
  42.       break;
  43.     case "Test Equipment & Specialty Items":
  44.       $email_to="rlacey". "hrichwine";
  45.       break;
  46.     case "Customer Service":
  47.       $email_to="rlacey". "hrichwine";
  48.       break;
  49.     case "Account Receivable":
  50.       $email_to="kfatherree". "tfraker";
  51.       break;
  52.     case "Accounts Payable":
  53.       $email_to="jlehman". "tfraker";
  54.       break;
  55.     case "Service Schools":
  56.       $email_to="hrichwine";
  57.       break;
  58.     case "Rebuilt Exchange Parts":
  59.       $email_to="sfrank";
  60.       break;
  61.     case "Operations":
  62.       $email_to="ecowan". "eburkhart";
  63.       break;
  64.     case "President":
  65.       $email_to="bbowman". "hrichwine";
  66.       break;
  67.     case "Service Center":
  68.       $email_to="eburkhart". "ecowan";
  69.       break;
  70.     case "Sales / Marketing":
  71.       $email_to="pjones". "tgasull";
  72.       break;
  73.     case "Tech Support":
  74.       $email_to="dfreet". "ssteinour";
  75.       break;
  76.     default:
  77.       $email_to = "ijimenez";  // fail-safe value     
  78.   }
  79.   mail( $email_to, "Feedback Form Results", $message, "From: $email" );
  80.   }
  81. ?>
Dec 2 '08 #15
Dormilich
8,658 Recognized Expert Moderator Expert
if you want to send email to several persons don't forget that the addresses mus be comma-separated.
Expand|Select|Wrap|Line Numbers
  1. $email_to="name1@host.tld, name2@host.tld";
maybe a more convenient way to do the email addresses is to store the addresses in an array and call that.
Expand|Select|Wrap|Line Numbers
  1. $emails = array("john" => "jdoe@host.tld", "don" => "don.t.worry@host.tld");
  2. // and so forth
  3.  
  4. switch ($Dept)
  5. {
  6.   case "Repair Parts":
  7.     $email_to = $emails['don'] . ", " . $emails['john']; break;
  8.   // ...
  9. }
you could also define a constant for each email address
Expand|Select|Wrap|Line Numbers
  1. define("EMAIL_ADDR_JDOE", "jdoe@host.tld");
  2. // ...
  3. $email_to = EMAIL_ADDR_JDOE . ", " . EMAIL_ADDR_DWORRY;
  4.  
though that's only a possibility, I'd go for the array.

if that's not working do a var_dump() on the variables just before sending. this could give you a clue, if a variable has an invalid value.

regards

note: to protect your co-workers from spam, do not post any email addresses. every reasonable editor has a search function that can remove these via a regex. if it's too late to edit, ask a moderator to do it for you.
Dec 2 '08 #16
Nyris
22 New Member
It works! You're a genius Dormilich. Thanks a lot for your help!
Dec 2 '08 #17
Dormilich
8,658 Recognized Expert Moderator Expert
@Nyris
no, I'm a XML god.... kidding. I'm glad I could help, that's why we're here.
Dec 2 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6028
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
4
2192
by: Tonya | last post by:
Hi, Does anyone have any example of how i can manage forms in my application?? I want to be able to reference my form instances that are currently open from other forms. why cant i open and close forms as easily as in VB6??
10
19362
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
0
1980
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of fields. I'd like to create a page in which all of this is stored as you move along as hidden variables, until the end, when the user submits. I can't figure out one thing: I have dynamic form elements (dropdowns), that I'd like to use instead of...
25
10275
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
4
1447
by: Dave Guenthner | last post by:
I have a csharp form1.cs created with VS. I have added a menu bar with one option called help. I then created another form in VS called help.cs. How can I launch the help form from the main form called form1. Seems simple. private void menuItem5_Click(object sender, System.EventArgs e) { // Menuitem5_Click is the help menu item user sees
10
6921
by: Kathy Burke | last post by:
HI. in asp.net app, I have an xmlDocument that I transform to the client html. Using xsl I create a few textboxes to capture user input. Each of these are related to <data> elements in the xmlDoc. I want to use the Forms collection to post the html form back to an asp.net page, and process each request.form object (textbox) via an xml node.value update. For any given xmlDocument there is an unknown number of items resulting in...
13
3942
by: Lee Newson | last post by:
Hi, I have just written my first application using VB.NET. The app works fine when i am running it within .NET for debugging purposes, however when i try to run the app from the .exe file that .NET creates i get the following error message: "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in VisioTimeline.exe
9
12853
by: mohit.akl | last post by:
Hey guys & gals I am havng trouble modifying the control box. I want to make the maximise button invisible and have minimisise button instead of it. Like this _ X (not like _ o X ) How to do this... and eventually i want to modify the control box in the form of ? _ X ... I.e. adding a new button to control box. I need to detect the click events.
9
3880
by: MikeB | last post by:
Hi, I'd appreciate some help, please. I'm writing a VS2005 VB project for school and one of the requirements is that every screen should have a "Help" button. I could do it by writing a clumsy case statement like this: sub showHelp(byval frm as String) Select Case (frm) Case "Form1" dim help as new Form1
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10275
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.