Link to home
Start Free TrialLog in
Avatar of Ryan Rood
Ryan RoodFlag for Canada

asked on

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

Avatar of sunithnair
sunithnair

You mean you want a PHP script for doing this?
You can start with this
NewUserReq.php
 
<?php
$emailto = $_POST["emailto"];
//use the variable $emailto so send the mail
?>

Open in new window

Avatar of Ryan Rood

ASKER

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.
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?
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?
ASKER CERTIFIED SOLUTION
Avatar of sunithnair
sunithnair

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well it worked, I thought I had tried that before I posted but something must have been wrong.

Thanks!