Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Use Form Value To Derive Email Address

Posted on 2009-02-13
7
Medium Priority
?
268 Views
Last Modified: 2013-12-13
Hi,

I am trying to make a form that will pull the value from the form to send to that specific email address. Please see attached code. So the value from "emailto" needs to somehow be referenced in the form post under the recipients value.

Thanks in advance,
Ryan
<html>
<head>
	<title>Request For Scheduling Consideration</title>
</head>
 
<body OnLoad="document.TimeOffReq.LastName.focus();" background="background.png">
 
<form method="post" action="NewUserReq.php" name="TimeOffReq" onSubmit="return checkEmail(this)">
    <input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER">
    <input type="hidden" name="required" value="FirstName:Your First Name,LastName:Your Last Name,DateRequested:Date Required">
	<input type="hidden" name="subject" value="Request For Scheduling Consideration" />
	 <input name="recipients" value="emailto" type="hidden" />
	
	<font face="verdana">
	<table width="400" border="0" cellpadding="0" cellspacing="0" align="center">
	<div align="center">
	<img src="logo.png" alt="">
	<br>
	
	<tr>
	<td>
		<select name="emailto" size="1">
		<option value="a@a.com" selected>Ryan - DT</option>
		<option value="b@b.com">Carolyn - DT</option>
		<option value="c@c.com">Doug - LA</option>
		<option value="d@d.com">Blair - HP</option>
		<option value="e@e.com">Randy - LE</option>
		</select> 
	</td>
	</tr>
	
	<tr>
		<td align="center" colspan="2"><strong><br><u>Requestor Information</u></strong></td>
	</tr>
    <tr>
        <td><br>Last Name:</td>
        <td><br>
								<input type="text" name="LastName" onChange="javascript:this.value=this.value.toUpperCase();">
        </td>
    </tr>
	<tr>
        <td>First Name:</td>
        <td><input type="text" name="FirstName" onChange="javascript:this.value=this.value.toUpperCase();">
        </td>
    </tr>
	
	<tr>
	<td>
	<br>Date Requested: </td>
	<td>
	<input type="text" name="DateRequested" onChange="javascript:this.value=this.value.toUpperCase();">
	</td>
	</tr>
		
    <tr>
		<td colspan="2" align="center"><br>
        Comments / Special Requests:<br>
        <textarea name="comments" rows="7" cols="49" style="overflow:hidden;"></textarea>
        </td>
						</tr>
	<br><br>
    <tr>
        <td><br><input type="submit" value="Submit" /></td>
        <td><br><input type="reset" value="Reset" /></td>
    </tr></div>
	</font>
   </table>
</form>
</body>
</html>

Open in new window

0
Comment
Question by:Ryan Rood
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:sunithnair
ID: 23635391
You mean you want a PHP script for doing this?
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23635436
You can start with this
NewUserReq.php
 
<?php
$emailto = $_POST["emailto"];
//use the variable $emailto so send the mail
?>

Open in new window

0
 
LVL 1

Author Comment

by:Ryan Rood
ID: 23635549
Sorry, I have a form processor now, it is a PHP script from Tectite. It requires the value be fed in through this variable. I want it to send to the email address that is selected when the form is submitted.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:sunithnair
ID: 23635595
I think if your php script is expecting a post variable by the name "emailto" then your html should work. Have you named your script NewUserReq.php? Are you getting any error?
0
 
LVL 1

Author Comment

by:Ryan Rood
ID: 23635624
emailto is my variable, i need to pass  <input name="recipients" value="emailto" type="hidden" /> to the php script in this format ... except it generally wants an actual email address in "value=""". How can i submit a variable that will change when the form is processed and passed?
0
 
LVL 16

Accepted Solution

by:
sunithnair earned 2000 total points
ID: 23635750
Simple just name your select box as recipients and remove the input field like this
<html>
<head>
        <title>Request For Scheduling Consideration</title>
</head>
 
<body OnLoad="document.TimeOffReq.LastName.focus();" background="background.png">
 
<form method="post" action="NewUserReq.php" name="TimeOffReq" onSubmit="return checkEmail(this)">
    <input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER">
    <input type="hidden" name="required" value="FirstName:Your First Name,LastName:Your Last Name,DateRequested:Date Required">
        <input type="hidden" name="subject" value="Request For Scheduling Consideration" />
        
        <font face="verdana">
        <table width="400" border="0" cellpadding="0" cellspacing="0" align="center">
        <div align="center">
        <img src="logo.png" alt="">
        <br>
        
        <tr>
        <td>
                <select name="recipients" size="1">
                <option value="a@a.com" selected>Ryan - DT</option>
                <option value="b@b.com">Carolyn - DT</option>
                <option value="c@c.com">Doug - LA</option>
                <option value="d@d.com">Blair - HP</option>
                <option value="e@e.com">Randy - LE</option>
                </select> 
        </td>
        </tr>
        
        <tr>
                <td align="center" colspan="2"><strong><br><u>Requestor Information</u></strong></td>
        </tr>
    <tr>
        <td><br>Last Name:</td>
        <td><br>
                                                                <input type="text" name="LastName" onChange="javascript:this.value=this.value.toUpperCase();">
        </td>
    </tr>
        <tr>
        <td>First Name:</td>
        <td><input type="text" name="FirstName" onChange="javascript:this.value=this.value.toUpperCase();">
        </td>
    </tr>
        
        <tr>
        <td>
        <br>Date Requested: </td>
        <td>
        <input type="text" name="DateRequested" onChange="javascript:this.value=this.value.toUpperCase();">
        </td>
        </tr>
                
    <tr>
                <td colspan="2" align="center"><br>
        Comments / Special Requests:<br>
        <textarea name="comments" rows="7" cols="49" style="overflow:hidden;"></textarea>
        </td>
                                                </tr>
        <br><br>
    <tr>
        <td><br><input type="submit" value="Submit" /></td>
        <td><br><input type="reset" value="Reset" /></td>
    </tr></div>
        </font>
   </table>
</form>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:Ryan Rood
ID: 31546691
Well it worked, I thought I had tried that before I posted but something must have been wrong.

Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question