Novahq.net Forum

Novahq.net Forum (https://novahq.net/forum/index.php)
-   phphq.Net Forums (https://novahq.net/forum/forumdisplay.php?f=277)
-   -   phMailer.php Help Please......! (https://novahq.net/forum/showthread.php?t=46296)

mccoy230023 10-24-2011 10:54 PM

phMailer.php Help Please......!
 
I'm trying to have the submit button on the phMailer form disable until my terms and agreement box is checked. Is there anyway to have this function written out in PHP and not JavaScript?

mccoy230023 10-24-2011 11:04 PM

If there is no way to disable the submit button until checkbox is checked in PHP and not Script, is there a way to have the emailed form to include the fact that the checkbox was checked?

Scott 10-25-2011 09:05 AM

Yes the form can tell you if the checkbox was checked. You just need to add the variable to the body of the message. I can't think of a way to do it without using javascript unless you want the page to reload after the user clicks the box. That would erase anything they have already typed into the form though. Why not just use Javascript?

mccoy230023 10-26-2011 01:21 PM

when I use JavaScript for some reason I don't get the email. I'm not sure if I have everything in the correct place or not. Everything works but for some reason I never get the email, here is how I have it written.

<script type="text/javascript">
var error="";
e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;

function Checkit(theform) {
if(theform.yourname.value=="") {
error+="You did not enter your name\n";
}

if(theform.youremail.value=="") {
error+="You did not enter your email\n";
} else if(!e_regex.test(theform.youremail.value)) {
error+="Invalid email address\n";
}

if(theform.yourmessage.value=="") {
error+="You did not enter your message\n";
}

if(error) {
alert('**The form returned the following errors:**\n\n' + error);
error="";
return false;
} else {
return true;
}
}
</script>

<!------ script for disable submite button before checkbox is check ----->
<script type="text/javascript">
function apply()
{
document.phmailer.sub.disabled=true;
if(document.phmailer.chk.checked==true)
{
document.phmailer.sub.disabled=false;
}
if(document.phmailer.chk.checked==false)
{
document.phmailer.sub.enabled=false;
}
}
</script>




</head>
<center>
<body>

<div class="container">
<div class="header"><a href="index.html"><img src="NewLogo.jpg" width="1069" height="135" alt="logo" /></a>

<!-- end .header --></div>
<div>
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="index.html">Home</a> </li>
<li><a href="writers' guideline.html">Writers Guideline</a></li>
<li><a href="After the Service.php">After the Service</a> </li>
<li><a href="Contact Us.html">Contact Us</a></li>
</ul>
</div>
<div class="content">
<h1>After the Service </h1>
<p>How would you like to be possibly printed in the next <strong><em>Gospel Roads</em></strong> <strong><em>Magazine</em></strong> issue?</p>
<p>&ldquo;After the Service&rdquo; is the center spread in which <strong><em>Gospel Roads</em></strong> showcases YOU as you exit your church services. Smile because we know you just met with God!</p>
<p>Please keep your photos to four people or less. We need high resolution shots, so send photos that are 600 pixels or higher. </p>
<p>If your photo is chosen, please give us permission to print it in the magazine.<em><u> Please provide names of indiviuals in the photo and the location in which the photo was taken in the comment box provided below.</u></em> Sorry, there&rsquo;s no payment for either the photographer or those featured in the shot. However, we consider it an honor for you to allow your picture to grace the pages of an upcoming issue of Gospel Roads. </p>
<p>Your acknowledgement of the terms and condition below grants Gospel Roads the permission to print your picture, your name, the name of your church, and your city. We&rsquo;ll review the images for quality and notify you when and what issue your photo will be printed. ****</p>
<p><br />
</p>





<?If($display_message) {?>

<div align="center" class="error_message"><b><?=$display_message;?></b></div>
<br />

<?}?>

<?If($sent_mail!=true) {?>

<form method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data" name="phmailer" onsubmit="return Checkit(this);">
<table align="center" width="739" class="table" border="5" bordercolor="#8E740B" cellpadding="5">

<?If($allowattach > 0) {?>
<tr>
<td width="100%" class="attach_info" colspan="2">
<b>Please use file types"</b> <?=implode($allowtypes, ", ");?><br />
<b>Max size per photo:</b> <?=$max_file_size?>kb.<br />
<b>Max combined file size:</b> <?=$max_file_total?>kb.
</td>
</tr>
<?}?>

<tr>
<td width="30%" class="table_body">First & Last Name:</td>
<td width="70%" class="table_body"><input name="yourname" type="text" size="30" value="<?=stripslashes(htmlspecialchars($yourname) );?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="30%" class="table_body">Your E-Mail:</td>
<td width="70%" class="table_body"><input name="youremail" type="text" size="30" value="<?=stripslashes(htmlspecialchars($youremail ));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="30%" class="table_body">Regarding:</td>
<td width="70%" class="table_body">

<?If($use_subject_drop AND is_array($subjects)) {?>
<select name="emailsubject" size="1">
<?while(list($key,$val)=each($subjects)) {?>

<option value="<?=intval($key);?>"><?=htmlspecialchars(str ipslashes($val));?></option>

<?}?>
</select>


<?} Else {?>

<input name="emailsubject" type="text" size="30" value="<?=stripslashes(htmlspecialchars($emailsubj ect));?>" />

<?}?>

</td>
</tr>

<?For($i=1;$i <= $allowattach; $i++) {?>
<tr>
<td width="30%" class="table_body">Attach File:</td>
<td width="70%" class="table_body"><input name="attachment[]" type="file" size="30" /></td>
</tr>
<?}?>

<tr>
<td colspan="2" width="100%" class="table_body">Comments:<span class="error_message">*</span><br />
<div align="center">
<textarea name="yourmessage" rows="8" cols="60"><?=stripslashes(htmlspecialchars($yourme ssage));?></textarea>
</div>
</td>
</tr>
<tr>
<!--------- code for the disabled submite button enable after checkbox is checked ---->
<td colspan="2" width="100%" class="table_footer">
<input type="checkbox" name="chk" onclick="apply()"/>
<a href="terms.pdf" target="_blank">Terms and Agreements</a> &nbsp;&nbsp;&nbsp;
<input type="hidden" name="submit" value="true" />
<input type="submit" name="sub" value="<?=$submitvalue;?>" disabled /> &nbsp;&nbsp;

<input type="reset" value="<?=$resetvalue;?>" />
</td>
</tr>
</table>
</form>

<?} Else {?>

<div align="center" class="thanks_message"><?=$thanksmessage;?></div>
<br />
<br />

<?}

mccoy230023 10-26-2011 05:57 PM

Got it to work looks like I needed to keep the "<input type="hidden" name="submit" value="true" />" above the "<input type="submit" name="sub" value="<?=$submitvalue;?>" disabled /> " code which is how I have it on the code above.

Thanks for your help and an great mailing form you created.

Scott 10-26-2011 06:24 PM

Glad you got it figured out!


All times are GMT -5. The time now is 01:14 PM.

Powered by vBulletin®