Hello everyone.
I am a real newbie to php, and this is my first attempt at writing anything.
I have created a Contact Form in html with a drop down selection box, which sends the completed form content to a different recipient depending on which option is selected in the drop down box.
All is working fine (much to my amazement and with a little help from others) EXCEPT, I am stuck with one part. When the form content is sent to the recipient, it shows the option value rather than the option text, and I cannot work my head around how to get it to show the text.
The relevant part of the Contact Form HTML code is: - <select name="Nature" size="1" id="Nature">
-
<option>Please Select</option>
-
<option value="recipient_1">General Enquiries</option>
-
<option value="recipient_2">Hall Hire</option>
-
<option value="recipient_3">Marquee Hire</option>
-
<option value="recipient_4">Parish Church</option>
-
<option value="recipient_5">Parish Council</option>
-
<option value="recipient_6">Recreation Area</option>
-
<option value="recipient_7">Other</option>
-
</select>
and the PHP code is: - /* Email Variables */
-
$emailSubject = 'website_enquiry';
-
$recipients = array(
-
-
'recipient_1' => 'kim@example.com',
-
'recipient_2' => 'kim2@example.com',
-
'recipient_3' => 'kms3@example.com',
-
'recipient_4' => 'kim4@example.com',
-
'recipient_5' => 'kim5@example.com',
-
'recipient_6' => 'kim6@example.com',
-
'recipient_7' => 'kim7@example.com'
-
);
-
-
$my_email = $recipients[$_POST['Nature']];
-
-
-
/* Data Variables */
-
$Name = $_POST['Name'];
-
$Telephone = $_POST['Telephone'];
-
$Email = $_POST['Email'];
-
$Nature = $_POST['Nature'];
-
$Questions = $_POST['Questions'];
-
-
-
$body = <<<EOD
-
<br><hr><br>
-
Name: $Name <br>
-
Telephone: $Telephone <br>
-
Email: $Email <br>
-
Nature: $Nature <br>
-
Questions: $Questions <br>
-
EOD;
-
$headers = "From: $Email\r\n";
-
$headers .= "Content-type: text/html\r\n";
-
$success = mail($my_email, $emailSubject, $body,
-
$headers);
So, basically, in the php above, within the 'body' i.e. the information being emailed, I have "Nature: $Nature", which returns the option value. I am trying to get it to return the option text itself to clarify the nature of the enquiry ( there are a couple of recipients who will receive emails for more than 1 type of enquiry and I need to show them which one it covers)Example: Assuming a user selects Hall Hire, it will currently send "recipient 2". I want it to send "Hall Hire" i.e the option text itself rather than the option value.
Is there a simple way of doing this ? Can anyone guide me please ?
2 1689 Dormilich 8,658
Recognized Expert Moderator Expert
When the form content is sent to the recipient, it shows the option value rather than the option text, and I cannot work my head around how to get it to show the text.
that’s simple: you can’t. the form will only transmit the assigned value (name-value pair), nothing else.
what you can do is putting the value of interest in the value attribute, i.e. if you need "Hall Hire" but not "recipient_ 2" just make "Hall Hire" the value.
another way were to use a data mapper (in this case a simple array would suffice) where you have the option’s value as array key and the option’s text as array value.
Doh !
Thanks Dormilich - couldn't see the wood for the trees when trying to protect the email addresses.
Have simply changed i.e. 'recipient_2' to 'Hall_Hire' in both html & php and it works perfectly.
Thanks so much.
Regards
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: melvynadam |
last post by:
If I open a new page with very little text on it such as
a bugmenot
results page is there a way to select some of the text there and
assign it to variables?
Selecting all and copying to the clipboard can be done with:
document.execCommand("SelectAll");
document.execCommand("Copy");
but I'm looking for something a little more refined.
The page contains seven lines of text and I'd like a simple way to say:
|
by: mitch-co2 |
last post by:
What I am trying to do is when someone clicks on the YES radio button I
want the text field called MYTEXT to equal the text field named DATE.
The below code works as long as I do NOT UN-COMMENT the NO radio
button, once I do that it will not work.
Any help would be greatly appreciated.
Mitch
|
by: BGS |
last post by:
Is there some setting that will allow users to select the text displayed in
a Label on a Windows Form? I would just like to be able to highlight the
text so that I could use Ctrl-Ins to capture the text to the Windows
clipboard. (I understand I could have the text display in a TextBox rather
than a Label, but for various reasons, I would prefer a Label display, but
one where the text could be copied).
All help most appreciated.
Bruce
|
by: d.steininger |
last post by:
Hi there!
Is there a way to bind a Textbox.Text to a ScrollBar.Value (not the
Textbox-own Scrollbar) and vice versa?
The Problem:
I have to deal with two controls. The Textbox should accept integers as
input, limited by a ScrollBar's Minimum- and Maximum. Changing the
ScrollBar-Value should update the Textbox-Text and vice versa. So the
textbox-text and scrollbar-value represent the same value. The user is
|
by: KwonNam Son |
last post by:
Is this possible to align select box's option text?
I tried <select style="text-align: center;"> and <option style="text-align:
center;>text</option>, it didn't work properly.
Any idea, please?
Regards,
KwonNam.
| |
by: cj |
last post by:
When I select textbox1 I want all text in it to be selected. I used the
textbox1_enter event to run textbox1.selectall()
This works if I tab to the box but not if it is selected by clicking on
it. I hat to have to put textbox1.selectall() in the click event too.
GotFocus event doesn't work any better than the enter event. I could
swear that back in VB4 I used the gotfocus event to select all text no
matter how the box was entered. ...
|
by: ASP Developer |
last post by:
I have a variety of pages that use a master page. For some reason when I
attempt to copy any of the label text on the screen it seems to highlight
most of the screen randomly and I can't simply copy the text. I can select
all text that is inside a control such as a text box. It is only the labels
that I can't get a hold of. Any suggestions would be greatly appreciated.
|
by: Advo |
last post by:
Having major issues with this simple task, and I cant work out why its
not doing as it should/expected.
Basically, ive got a drop down box with the added bit of php:
<select name="title" id="title">
<?php
if($_SESSION != "") {
echo '<option value="'. $_SESSION .'"
|
by: =?Utf-8?B?bWNhdWxpZmZl?= |
last post by:
I have an old application ( pre-VB5) that I need to add a select/option list
to. This is an edit program so the values for the form will be retrieved
from a database. How do I set the value of the dropdown with the value from
the database. The value in the database is either new, trial, maint.,
employee, beta, or null. I need to set the dropdrown to one of these values.
An example of the select;
<td>
<select name="ordReason">...
|
by: ahighfidelity |
last post by:
Hi.
I wonder if someone can help me. I have just recently finished our designing and building our company website...
www.mediajunction.co.uk
All appears fine when viewing it fully on Firefox and all IE web browsers. However, my boss has raised a couple of concerns which are driving me mad.
The problem is, as you can see from the Page Source below, the main copy from each page appears via an iframe. Is there a way to make this text...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |