Log in

View Full Version : Adding a confirmation email?



Bengal313
07-29-2010, 04:45 PM
I have created this form using one of those online generators. I need to modify it just a little bit. I have an email field at the bottom of the form. I need to add another email field so they can confirm the email address. If the email matches continue to submit. If it doesn't, pop up a message saying email doesn't match. Can someone help me with that? Here is the code



<?php

# This block must be placed at the very top of page.
# --------------------------------------------------
require_once( dirname(__FILE__).'/form.lib.php' );
phpfmg_display_form();
# --------------------------------------------------



function phpfmg_form( $sErr = false ){
$style=" class='form_text' ";

?>

<form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'>
<input type='hidden' name='formmail_submit' value='Y'>
<div id='err_required' class="form_error" style='display:none;'>
<label class='form_error_title'>Please check the required fields</label>
</div>


<ol class='phpfmg_form' >

<li class='field_block' id='field_0_div'><div class='col_label'>
<label class='form_field'>Ticket Number</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_0" id="field_0" value="<?php phpfmg_hsc("field_0"); ?>" class='text_box'>
<div id='field_0_tip' class='instruction'>Enter Ticket Number</div>
</div>
</li>

<li class='field_block' id='field_1_div'><div class='col_label'>
<label class='form_field'>Ticket Issue Date</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php
selectList( "field_1_MM", $_POST["field_1_MM"], 1, 12, "MM", $style ) ;
selectList( "field_1_DD", $_POST["field_1_DD"], 1, 31, "DD", $style ) ;
selectList( "field_1_YYYY", $_POST["field_1_YYYY"], date("Y")-100, date("Y"), "YYYY", $style ) ;
?>

<div id='field_1_tip' class='instruction'>Enter Date (MM-DD-YYYY)</div>
</div>
</li>

<li class='field_block' id='field_2_div'><div class='col_label'>
<label class='form_field'>Full Name</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_2" id="field_2" value="<?php phpfmg_hsc("field_2"); ?>" class='text_box'>
<div id='field_2_tip' class='instruction'>Enter First and Last Name</div>
</div>
</li>

<li class='field_block' id='field_3_div'><div class='col_label'>
<label class='form_field'>Address 1</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_3" id="field_3" value="<?php phpfmg_hsc("field_3"); ?>" class='text_box'>
<div id='field_3_tip' class='instruction'>Enter Address</div>
</div>
</li>

<li class='field_block' id='field_4_div'><div class='col_label'>
<label class='form_field'>Address 2</label> <label class='form_required' >&nbsp;</label> </div>
<div class='col_field'>
<input type="text" name="field_4" id="field_4" value="<?php phpfmg_hsc("field_4"); ?>" class='text_box'>
<div id='field_4_tip' class='instruction'>Enter Address</div>
</div>
</li>

<li class='field_block' id='field_5_div'><div class='col_label'>
<label class='form_field'>City</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_5" id="field_5" value="<?php phpfmg_hsc("field_5"); ?>" class='text_box'>
<div id='field_5_tip' class='instruction'>Enter City</div>
</div>
</li>

<li class='field_block' id='field_6_div'><div class='col_label'>
<label class='form_field'>State</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_6" id="field_6" value="<?php phpfmg_hsc("field_6"); ?>" class='text_box'>
<div id='field_6_tip' class='instruction'>Enter State</div>
</div>
</li>

<li class='field_block' id='field_7_div'><div class='col_label'>
<label class='form_field'>Zip Code</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_7" id="field_7" value="<?php phpfmg_hsc("field_7"); ?>" class='text_box'>
<div id='field_7_tip' class='instruction'>Enter Zip Code</div>
</div>
</li>

<li class='field_block' id='field_8_div'><div class='col_label'>
<label class='form_field'>Day Time Phone</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_8" id="field_8" value="<?php phpfmg_hsc("field_8"); ?>" class='text_box'>
<div id='field_8_tip' class='instruction'>Enter Telephone with area code</div>
</div>
</li>

<li class='field_block' id='field_9_div'><div class='col_label'>
<label class='form_field'>E-mail</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_9" id="field_9" value="<?php phpfmg_hsc("field_9"); ?>" class='text_box'>
<div id='field_9_tip' class='instruction'>Enter your email address</div>
</div>
</li>


<li class='field_block' id='phpfmg_captcha_div'>
<div class='col_label'><label class='form_field'>Security Code:</label> <label class='form_required' >*</label> </div><div class='col_field'>
<?php phpfmg_show_captcha(); ?>
</div>
</li>


<li>
<div class='col_label'>&nbsp;</div>
<div class='form_submit_block col_field'>

<input type='submit' value='Submit' class='form_button'>
<span id='phpfmg_processing' style='display:none;'>
<img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&amp;func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label>
</span>
</div>
</li>

</ol>




</form>




<?php

phpfmg_javascript($sErr);

}
# end of form




function phpfmg_form_css(){
?>
<style type='text/css'>

body{
margin-left: 18px;
margin-top: 18px;
}

body{
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 13px;
color : #474747;
background-color: transparent;
}

select, option{
font-size:13px;
}

ol.phpfmg_form{
list-style-type:none;
padding:0px;
margin:0px;
}

ol.phpfmg_form li{
margin-bottom:5px;
clear:both;
display:block;
overflow:hidden;
width: 100%
}


.form_field, .form_required{
font-weight : bold;
}

.form_required{
color:red;
margin-right:8px;
}

.field_block_over{
}

.form_submit_block{
padding-top: 3px;
}

.text_box, .text_area, .text_select {
width:300px;
}

.text_area{
height:80px;
}

.form_error_title{
font-weight: bold;
color: red;
}

.form_error{
background-color: #F4F6E5;
border: 1px dashed #ff0000;
padding: 10px;
margin-bottom: 10px;
}

.form_error_highlight{
background-color: #F4F6E5;
border-bottom: 1px dashed #ff0000;
}

div.instruction_error{
color: red;
font-weight:bold;
}

hr.sectionbreak{
height:1px;
color: #ccc;
}




<?php

phpfmg_text_align();
echo "</style>\n";

}
# end of css

# By: formmail-maker.com
?>

fastsol1
07-29-2010, 05:19 PM
Here is a great tutorial for this, it is a multi part tutorial and I'm not sure exactly wich one has the code for you but it's in there.
http://www.youtube.com/user/phpacademy#p/u/136/ngqeWUIDlnk

Bengal313
08-05-2010, 06:53 PM
Okay did some searching and came across this script.

http://lab.artlung.com/compare-fields/



<script type="text/javascript" language="JavaScript">
<!--
//--------------------------------
// This code compares two fields in a form and submit it
// if they're the same, or not if they're different.
//--------------------------------
function checkEmail(theForm) {
if (theForm.EMAIL_1.value != theForm.EMAIL_2.value)
{
alert('Those emails don\'t match!');
return false;
} else {
return true;
}
}
//-->
</script>




<form action="../" onsubmit="return checkEmail(this);">
<p> Enter Your Email Address:<br>
<input type="TEXT" name="EMAIL_1" size="20" maxlength="20">
<br>
Please Confirm Your Email Address:
<br>
<input type="TEXT" name="EMAIL_2" size="20" maxlength="20">
<br>
<input type="SUBMIT" value="Send Address!"></p>
</form>






Got everything figured out except. How do I integrate the new function to the existing form properties.?

Exsiting code:
<form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'>


Code need to be integrated:

<form action="../" onsubmit="return checkEmail(this);">