Form Code Problem
Posted: Sun Feb 01, 2009 10:27 am
Hi all,
I wandering if I can get some help please, I have this PHP code to process my form, but the page doesn't do anything when submitted, now I can make edits etc to PHP but am not good enough to write it from scratch yet so dont know what the problem could be! I would be grateful of any help
Many thanks in advance
my page which holds the form is called contactus.php (this holds the form, and the processing code is on that same page)
code at the top of my page:
<?php
function isEmailAddressValid($email)
{
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email))
{
$result = FALSE;
}
return $result;
}
$headers = "MIME-Version: 1.0\r";
$headers .= "Content-type: text/html; charset=iso-8859-1\r";
$headers .= "From:<".$_REQUEST['emailAddress'].">\r";
$headers .= "Reply-To:<".$_REQUEST['emailAddress'].">\r";
$headers .= "To:<>\r";
$headers .= "Cc: <>\r";
if ((isset($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc6502574']) && (strcmp($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc6502574'],"")==0)) && (isset($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc65025741']) && (strcmp($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc65025741'],"")==0)))
{
if (isset($_REQUEST['emailAddress']) && (!isEmailAddressValid($_REQUEST['emailAddress'])))
$message=$message."<div style=\"color:#FF0000;\">The e-mail address is invalid!</div>";
if (isset($_REQUEST['comments']) && (strcmp($_REQUEST['comments'],"")==0))
$message=$message."<div style=\"color:#FF0000;\">Please fill in a comment!</div>";
$message=$message.'<br/>';
if ( ((isEmailAddressValid($_REQUEST['emailAddress']))==true) && isset($_REQUEST['comments']) && (strcmp($_REQUEST['comments'],"")!=0))
{
$content=$content.'<strong>Your name </strong> '. $_REQUEST['textName'].'<br/>';
$content=$content.'<strong>Your phone number </strong> '. $_REQUEST['textName1'].'<br/>';
$content=$content.'<strong>Your email address </strong> '. $_REQUEST['textName2'].'<br/>';
$content=$content.'<strong>Brief description of enquiry/claim </strong> '. $_REQUEST['textName3'].'<br/>';
mail('myemail@adress.com','Claim/enquiry from the web site',$content,$headers);
$message='<p style=\"color:#FF0000;\">Your message has been submited!</p><br/>';
}
}
?>
form code:
<?php print $message?> <form method="post" action="contactus.php">
<div style="width:600x">
<label for="textName" class="formCreatorLabel">Your name</label><br>
<input type="text" name="textName" id="textId" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName'].'"'?>/>
<br><br>
<label for="textName1" class="formCreatorLabel">Your phone number</label><br>
<input type="text" name="textName1" id="textId1" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName1'].'"'?>/>
<br><br>
<label for="textName2" class="formCreatorLabel">Your email address</label><br>
<input type="text" name="textName2" id="textId2" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName2'].'"'?>/>
<br><br>
<label for="textName3" class="formCreatorLabel">Brief description of enquiry/claim</label><br>
<input type="text" name="textName3" id="textId3" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName3'].'"'?>/>
<br><br>
<input type="submit" value="Submit"/>
</div>
</form>
I wandering if I can get some help please, I have this PHP code to process my form, but the page doesn't do anything when submitted, now I can make edits etc to PHP but am not good enough to write it from scratch yet so dont know what the problem could be! I would be grateful of any help
Many thanks in advance
my page which holds the form is called contactus.php (this holds the form, and the processing code is on that same page)
code at the top of my page:
<?php
function isEmailAddressValid($email)
{
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email))
{
$result = FALSE;
}
return $result;
}
$headers = "MIME-Version: 1.0\r";
$headers .= "Content-type: text/html; charset=iso-8859-1\r";
$headers .= "From:<".$_REQUEST['emailAddress'].">\r";
$headers .= "Reply-To:<".$_REQUEST['emailAddress'].">\r";
$headers .= "To:<>\r";
$headers .= "Cc: <>\r";
if ((isset($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc6502574']) && (strcmp($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc6502574'],"")==0)) && (isset($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc65025741']) && (strcmp($_REQUEST['Hiddenf5ac0663a66a75698d225b8bc65025741'],"")==0)))
{
if (isset($_REQUEST['emailAddress']) && (!isEmailAddressValid($_REQUEST['emailAddress'])))
$message=$message."<div style=\"color:#FF0000;\">The e-mail address is invalid!</div>";
if (isset($_REQUEST['comments']) && (strcmp($_REQUEST['comments'],"")==0))
$message=$message."<div style=\"color:#FF0000;\">Please fill in a comment!</div>";
$message=$message.'<br/>';
if ( ((isEmailAddressValid($_REQUEST['emailAddress']))==true) && isset($_REQUEST['comments']) && (strcmp($_REQUEST['comments'],"")!=0))
{
$content=$content.'<strong>Your name </strong> '. $_REQUEST['textName'].'<br/>';
$content=$content.'<strong>Your phone number </strong> '. $_REQUEST['textName1'].'<br/>';
$content=$content.'<strong>Your email address </strong> '. $_REQUEST['textName2'].'<br/>';
$content=$content.'<strong>Brief description of enquiry/claim </strong> '. $_REQUEST['textName3'].'<br/>';
mail('myemail@adress.com','Claim/enquiry from the web site',$content,$headers);
$message='<p style=\"color:#FF0000;\">Your message has been submited!</p><br/>';
}
}
?>
form code:
<?php print $message?> <form method="post" action="contactus.php">
<div style="width:600x">
<label for="textName" class="formCreatorLabel">Your name</label><br>
<input type="text" name="textName" id="textId" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName'].'"'?>/>
<br><br>
<label for="textName1" class="formCreatorLabel">Your phone number</label><br>
<input type="text" name="textName1" id="textId1" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName1'].'"'?>/>
<br><br>
<label for="textName2" class="formCreatorLabel">Your email address</label><br>
<input type="text" name="textName2" id="textId2" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName2'].'"'?>/>
<br><br>
<label for="textName3" class="formCreatorLabel">Brief description of enquiry/claim</label><br>
<input type="text" name="textName3" id="textId3" class="formCreatorText" value=<?php print '"'.$_REQUEST['textName3'].'"'?>/>
<br><br>
<input type="submit" value="Submit"/>
</div>
</form>