Click to See Complete Forum and Search --> : Form To Mail - PHP


bookwala
04-17-2007, 02:09 AM
Hi Guys...

I have a problem with this form. I was trying to make a form and link it to PHP page so that when a user fills the form the content of the form is mail to a particular mail id. The problem is I am not able to link the form page with the PHP page. The coding is given below for your reference. Help Required!!!

<form name=login_frm1 action=thanks.php method=post onSubmit="return validateForm(this)">
<TABLE width="90%" border=0 align=center cellPadding=0 cellSpacing=0 class="enquirytable" style="BORDER-RIGHT: #eaeaea 1px solid; BORDER-TOP: #eaeaea 1px solid; BORDER-LEFT: #eaeaea 1px solid; BORDER-BOTTOM: #eaeaea 1px solid">
<TBODY>
<TR vAlign=top>
<TD>
<table cellspacing="0" cellpadding="0" width="90%"
border="0">
<!--
<tr><td colspan="3">

</tr></td>-->
<tbody>
<tr valign="top">
<td class="paneltitle02" colspan="3"><img
src="img/value_arrow01.gif" width="9" height="6" /> &nbsp;Product Enquiry </td>
</tr>
<tr valign="top">
<td width="9" class="txtcol01">&nbsp;</td>
<td width="233" class="enquiryfeatures01">&nbsp;</td>
<td width="248" class="features02"><span class="txtcol01">*</span> all fields are
Mandatory </td>
</tr>
<tr valign="top">
<td class="txtcol01">*</td>
<td class="enquiryfeatures01"><b>Name:</b></td>
<td class="features02"><p>
<input class="txtfield02" name="firstname" onkeypress="return OnlyLetters(event);"/>
<br />
<img src="img/blankimage.gif" name="firstnameerror" width="350" height="10" border="0"/> </p>
</td>
</tr>
<tr valign="top">
<td class="txtcol01" style="HEIGHT: 23px">*</td>
<td class="enquiryfeatures01" style="HEIGHT: 23px"><b>Organisation:</b></td>
<td class="features02" style="HEIGHT: 23px"><p>
<input
class="txtfield02" maxlength="20" name="organisation" />
<br />
<img src="img/blankimage.gif" name="organisationerror" width="350" height="10" border="0" id="organisationerror" /><br />
</p></td>
</tr>
<tr valign="top">
<td class="txtcol01">*</td>
<td class="enquiryfeatures01"><b>Email:</b></td>
<td class="features02"><input class="txtfield02" maxlength="60" name="email" />
<br />
<img src="img/blankimage.gif" name="emailerror" width="350" height="10" border="0" id="emailerror" /></td>
</tr>
<tr valign="top">
<td class="txtcol01" style="HEIGHT: 23px">*</td>
<td class="enquiryfeatures01" style="HEIGHT: 23px"><b>Telephone:</b></td>
<td class="features02" style="HEIGHT: 23px"><p>
<input class="txtfield02" maxlength="20" name="phoneno" onkeypress="return OnlyNumbers(event);" />
<br />
<img src="img/blankimage.gif" name="phoneerror" width="350" height="10" border="0" id="phoneerror" /></p></td>
</tr>
<tr valign="top">
<td class="txtcol01" style="HEIGHT: 23px">*</td>
<td class="enquiryfeatures01" style="HEIGHT: 23px"><b>Address:</b></td>
<td class="features02" style="HEIGHT: 23px"><p>
<textarea name="address" cols="30" rows="4" class="txtfield02"></textarea>
<br />
<img src="img/blankimage.gif" name="addresserror" width="350" height="10" border="0" id="addresserror" /></p></td>
</tr>
<tr valign="top">
<td class="txtcol01" style="HEIGHT: 23px">&nbsp;</td>
<td class="enquiryfeatures01" style="HEIGHT: 23px">&nbsp;</td>
<td class="features02" style="HEIGHT: 23px"><p><span class="style4">*</span> Please fill the details in the Comments box provided below:<br />
Product Code, Quantity and any other Information you find relevant for us to help you. </p></td>
</tr>
<tr valign="top">
<td class="txtcol01" style="HEIGHT: 23px">*</td>
<td class="enquiryfeatures01" style="HEIGHT: 23px"><b>Comments:</b></td>
<td class="features02" style="HEIGHT: 23px"><p>
<textarea name="comments" cols="30" rows="4" class="txtfield02"></textarea>
<br />
<img src="img/blankimage.gif" name="commentserror" width="350" height="10" border="0" id="commentserror" /></p></td>
</tr>
</tbody>
</table>
</table>
<table width="91%" border="0" align="center" cellpadding="0"
cellspacing="0"
style="BORDER-RIGHT: #eaeaea 1px solid; BORDER-TOP: #eaeaea 1px solid; BORDER-LEFT: #eaeaea 1px solid; BORDER-BOTTOM: #eaeaea 1px solid">
<tbody>
<tr>
<td class="features03"><input class="btn01" type="submit" value="Submit" name="submit"/>

<input class="btn01" id="Reset" type="reset" value="Reset" name="Reset" />
</td>
</tr>
</tbody>
</table>
</form>

bookwala
04-22-2007, 05:17 AM
Hey can anyone help me with this. The HTML coding was posted earlier on the same thread. Attached below is the scripting. However if the form is filled correctly on submit it does not connect to the PHP file.... Guys I m in a real fix due to this. Please HELP!!!

<!-- Begin
//Only Numbers
function OnlyNumbers(e)
{
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8)
{ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}

//Only Letters
function OnlyLetters(e)
{
var key = window.event ? e.keyCode : e.which;
var keychar = String.fromCharCode(key);
reg = /\d/;
return !reg.test(keychar);
}

// Preload images
var empty = new Image(); empty.src = "img/fieldempty.gif";
var email = new Image(); email.src = "img/emailerror.gif";

var haveerrors = 0;
function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
if (!haveerrors && errors) haveerrors = errors;
}

function validateForm(f) {

haveerrors = 0;
(f.firstname.value.length < 1) // validate first name length
? showImage("firstnameerror", "img/fieldempty.gif", true) // no semi-colon after this line!
: showImage("firstnameerror", "img/blankimage.gif", false); // true = errors, false = no errors

(f.organisation.value.length < 1) // validate first name length
? showImage("organisationerror", "img/fieldempty.gif", true) // no semi-colon after this line!
: showImage("organisationerror", "img/blankimage.gif", false); // true = errors, false = no errors

(f.email.value.search("@") == -1 || f.email.value.search("[.*]") == -1) // validate email
? showImage("emailerror", "img/emailerror.gif", true)
: showImage("emailerror", "img/blankimage.gif", false);

(f.phoneno.value.length < 1) // validate comments length
? showImage("phoneerror", "img/fieldempty.gif", true)
: showImage("phoneerror", "img/blankimage.gif", false);

(f.address.value.length < 1) // validate comments length
? showImage("addresserror", "img/fieldempty.gif", true)
: showImage("addresserror", "img/blankimage.gif", false);

(f.comments.value.length < 1) // validate comments length
? showImage("commentserror", "img/fieldempty.gif", true)
: showImage("commentserror", "img/blankimage.gif", false);

return false;

}

End --!>

NogDog
04-22-2007, 05:26 AM
If you want to encourage people to read your code, please make use of the [php] vbcode tag (http://www.webdeveloper.com/forum/misc.php?do=bbcode#php) around your code samples. There is also a [html] tag (http://www.webdeveloper.com/forum/misc.php?do=bbcode#html) for HTML mark-up with no PHP code in it. This will make your code much easier to read in your posts.

bookwala
04-25-2007, 02:42 AM
Please Help

hastx
04-25-2007, 01:18 PM
I think we need to see the code on the "thanks.php" page....or is that what you need help with generating?

If i understand correctly, your not having problems "linking" a page...you need help with a form to email script?

bruinDesign
04-25-2007, 02:13 PM
It looks like validateForm function is always returning false so the form will never actually submit. It looks like you should be using the following return statement:

return !haveerrors;

That should make it work how you want.