Use Form Value To Derive Email Address

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

LVL 1
Ryan RoodAsked:
Who is Participating?
 
sunithnairCommented:
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
 
sunithnairCommented:
You mean you want a PHP script for doing this?
0
 
sunithnairCommented:
You can start with this
NewUserReq.php
 
<?php
$emailto = $_POST["emailto"];
//use the variable $emailto so send the mail
?>

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Ryan RoodAuthor Commented:
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
 
sunithnairCommented:
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
 
Ryan RoodAuthor Commented:
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
 
Ryan RoodAuthor Commented:
Well it worked, I thought I had tried that before I posted but something must have been wrong.

Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.