|
-
Apr 26th, 2007, 12:02 AM
#1
Thread Starter
Junior Member
Please help me with this Email Form
I have a Form from where user Will put the Name, Message and his mail Id. And The details will be mailed to specified Mail BOX. Now I Need to put a image instead of a Submit Button. If i put the Submit Button the Mail Easily Delivered to me. If i put the Image then its not delivering.. please help me what to do??
Code:
<?php
$error = "";
$success = FALSE;
if(isset($_POST['submit']))
{
foreach($_POST as $key => $val)
{
if(empty($_POST[$key]))
{
$error .= "You must enter a value for " .
ucwords(str_replace("_"," ",$key)) . ". ";
}
else
{
if(get_magic_quotes_gpc())
{
$_POST[$key] = stripslashes($val);
}
}
if($key != 'enquiry')
{
$_POST[$key] = preg_replace('/[\r\n]/', ' ', $val);
}
}
if($_POST['email'] == 0)
{
//$error .= "'{$_POST['email']}' does not appear to be a valid email address. ";
}
$to = "xxx@***.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$_POST['email']."\r\n";
$mail = @mail($to,$_POST['name'],$_POST['enquiry'],$headers);
if(!$mail)
{
$error .= "There was an unknown error occurred ";
}
else
{
$error .= "Your message has been successfully sent. ";
}
}
?>
<form name="ContactUs" method="post" action="../index.php?main_page=contact_us&action=success">
<table width="100%" border="0" cellspacing="2" cellpadding="2" >
<tr>
<td class="plainBoxHeading" colspan="2">NAME</td>
</tr>
<tr>
<td class="main" colspan="2"><input name="name" type="text"></td>
</tr>
<tr>
<td class="plainBoxHeading" colspan="2">EMAIL</td>
</tr>
<tr>
<td class="main" colspan="2"><input name="email" type="text" size="50"></td>
</tr>
<tr>
<td class="plainBoxHeading" colspan="2">Message</td>
</tr>
<tr>
<td class="main" colspan="2"><textarea name="enquiry" cols="50" rows="15"></textarea></td>
</tr>
<tr>
<td align="right" class="main"><a href =" javascript : submitForm(); "><img src="../includes/templates/template_default/buttons/english/button_send.gif" alt="send now"></a></td>
</tr>
</table>
</form>
<script language = "javascript">
function submitForm() {
document.ContactUs.submit();
}
</script>
Last edited by mishu007; Apr 26th, 2007 at 01:16 AM.
-
Apr 26th, 2007, 12:16 AM
#2
Re: Please help me with this Email Form
Just style your submit button instead.
You shouldn't use a link to execute JavaScript, and certainly not by using the javascript: pseudo-protocol like that. That's just bad style.
Also, by using JS to submit the form, you're cutting out any users that don't have a JS engine installed or enabled. That's a big concern, accessibility-wise.
css Code:
input[type='submit'] {
background: url('images/submit.png') top left no-repeat;
width: n px;
height : n px
}
For compatibility with IE 6 and below, you might want to change that to use a class instead.
-
Apr 26th, 2007, 01:15 AM
#3
Thread Starter
Junior Member
Re: Please help me with this Email Form
thanks a lot.. its ok now.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|