Hello all i'm GREEN when it comes to PHP. I had a buddy dev a quick PHP site that has a few drop downs and input boxes. Then a "Send Email" button that sends an email. That all works.
I added a dropdown list that displays peoples names, and the value of the names are their email address.
example: dropdown displays "Matt Loflin" but the value is "matt.loflin@mail.com" I have 3 (i think easy questions)
1. I would like for the email to appear to be "from" "matt.loflin...." but I can't figure it out.
Here is the code of the page:
Here is the email function
there is an index function that is populating all the dropdowns in a format like:
again I don't know much about it.
2.Another thing i'd like it to do is beside the Dropdown for name, when they select a name then have it populate a label with their email.
ex. I select Matt Loflin - then a label right next to it populates my email.
3.In the email it is sending it is swapping the name with their email (i'm assuming because of the "value) could that be in the format of "Matt Loflin - matt.loflin@mail.com" so it shows the text and the value?
Thanks in advance
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
I added a dropdown list that displays peoples names, and the value of the names are their email address.
example: dropdown displays "Matt Loflin" but the value is "matt.loflin@mail.com" I have 3 (i think easy questions)
1. I would like for the email to appear to be "from" "matt.loflin...." but I can't figure it out.
Here is the code of the page:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<link href="<?=base_url()?>css/Style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?=base_url()?>javascript/jquery.simplemodal.js"></script>
<script type="text/javascript" src="<?=base_url()?>javascript/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?=base_url()?>javascript/custom.js"></script>
<title>SWAC</title>
<style type="text/css">
@media print
{
#wrapper { display: none; }
#bottom_btns { display: none; }
#information { display: block; }
}
</style>
</head>
<body class="ss-base-body" dir="ltr">
<form method="post" name="SWACCC" action="email" id="SWACCC" class="validate" onsubmit="return validate();">
<div id="wrapper" class="ss-form-container">
<h1 class="ss-form-title">SWAC CREDIT CARD CHARGE FORM</h1>
</div>
<div id="information" class="information">
<div class="denote">* Denotes Required Field</div>
<input value="Name" name="legend0" type="hidden"></input>
<?php echo form_label('<b>Full Name <span class="req_txt">*</span></b>')?><br />
<?php echo form_dropdown('name', $name,"class='req' id='name'")?><br /><br />
<input value="Name of Charge Card" name="legend1" type="hidden"></input>
<?php echo form_label('<b>Name of Charge Card <span class="req_txt">*</span></b>')?><br />
<?php echo form_dropdown('chargeName',$chargeName, '', "class='req' id='chargeName'");?><br /><br />
<input value="Date of Purchase" name="legend2" type="hidden"></input>
<?php echo form_label('<b>Date of Purchase <span class="req_txt">*</span></b>')?><br />
<?php echo form_input('dop', $dop,"class='req' id='dop'")?><br /><br />
<input value="Amount of Purchase" name="legend3" type="hidden"></input>
<?php echo form_label('<b>Amount of Purchase <span class="req_txt">*</span></b>')?><br />
<?php echo form_input('amount',$amount,"class='req' id='amount'")?><br /><br />
<input value="Place of Purchase" name="legend4" type="hidden"></input>
<?php echo form_label('<b>Place of Purchase <span class="req_txt">*</span></b>')?><br />
<?php echo form_input('pop',$pop,"class='req' id='pop'")?><br /><br />
<input value="Charge to Budget Account" name="legend5" type="hidden"></input>
<?php echo form_label('<b>Charge to Budget Account <span class="req_txt">*</span></b>')?><br />
<i>Please select the Budget Account that this expense is to be charged to:</i><br />
<?php echo form_dropdown('budget', $budget, '', "class='req' id='budget'")?><br /><br />
<input value="Charge to Reserve Account" name="legend6" type="hidden"></input>
<?php echo form_label('<b>Charge to Reserve Account <span class="req_txt">*</span></b>')?><br />
<i>Please select the Reserve Account that this expense is to be charged to:</i><br />
<?php echo form_dropdown('reserve', $reserve, '', "class='req' id='reserve'")?><br /><br />
</div>
<div id="bottom_btns" class="information" align="center">
<?=form_submit('Submit', 'Send E-mail')?> <input type="button" value="Print Form" onClick="window.print()" />
</div>
</form>
<div id="error_alert" style="display:none;">
<div id="dialog_wrap">
<div id="popup_content"> Please complete all required fields,
hightlighted in red.
</div>
<a href="#" id="modal_close" class="modal_close">OK</a>
</div>
</div>
</body>
</html>
Here is the email function
Code:
function email() {
$this->load->helper('url');
if ($_POST) {
$message = '';
$values = array_values($_POST);
//$count = 0;
//$prevKey = "";
foreach($_POST as $key => $value) {
if($value!='Send'){
if (strlen(strstr($key,'legend'))>0){
$message = $message.'<b>'.$value.': </b>';
} else {
$from = "$value"; //since the first value is the email... i'm grabbing it
$message = $message.$value.'<br /><br />';
}
}
}
$to = "matt.loflin@mail.com";
$subject = "SWAC Credit Card Charge Form";
$message = $message.'</html>';
// To send HTML mail, the Content-type header must be set
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$email = '<html><h4>Charge Description</h1>'.$message;
mail($to, $subject, $email, $headers);
echo "<html><h4>Thank you for your submission! Your message was successfully sent.</h4>".$message;
} else {
echo "<h4 style='margin-left:20px;width:250px'>Sorry, no form data has been received.</h4>";
}
}
}
there is an index function that is populating all the dropdowns in a format like:
Code:
'matt.loflin@mail.com'=>'Matt Loflin',
again I don't know much about it.
2.Another thing i'd like it to do is beside the Dropdown for name, when they select a name then have it populate a label with their email.
ex. I select Matt Loflin - then a label right next to it populates my email.
3.In the email it is sending it is swapping the name with their email (i'm assuming because of the "value) could that be in the format of "Matt Loflin - matt.loflin@mail.com" so it shows the text and the value?
Thanks in advance
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008