code fields niet wissen bij verkeerde captcha

Status
Niet open voor verdere reacties.

Suchard

Gebruiker
Lid geworden
24 feb 2011
Berichten
140
Beste,

Ik heb een contactformulier in php.
Ik heb het formulier in de eerste 3 fields nu zover dat hij de velden niet wist wanneer de captcha fout is.
Behalve bij het textarea Uw bericht, daar werkt het niet.

Heeft iemand daar de code voor en waar ik die precies moet plaatsen.

<?php
//CAPTCHA***
session_start();
$captcha_error_message="";
$captcha_var="";
//Has the Action variable been submitted?
if(isset($_POST["verstuur"])){
//store captcha field value
if(isset($_POST['captcha'])){
$captcha_var=$_POST['captcha'];
}else if(isset($_GET['captcha'])){
$captcha_var=$_GET['captcha'];
}
$captcha_var=strtoupper($captcha_var);
//Check for failure:
//1. Is there $_SESSION['captcha']?
//2. Is $_SESSION['captcha'] blank?
//3. Is captcha string blank (it is by deafault)?
//4. Is there a match?
if(!isset($_SESSION['captcha']) || $_SESSION['captcha']=="" || $captcha_var=="" || (isset($_SESSION['captcha']) && md5($captcha_var)!=$_SESSION['captcha'])){
unset($_POST["verstuur"]);
$captcha_error_message="<div class=\"captcha_error_message\">De verificatiecode is onjuist.</div><script>function setCaptchaFocus(){var c=document.getElementById('captcha');c.scrollIntoView(true);c.select()};function addEvt(){if (window.addEventListener){window.addEventListener('load',setCaptchaFocus,null);return true}else if(window.attachEvent){return window.attachEvent('onload',setCaptchaFocus)}}; addEvt();</script>";
}
}
function makeCaptcha($im,$len,$t1,$t2,$t3,$b1,$b2,$b3,$error_message){
echo "<input name=\"captcha\" type=\"text\" autocomplete=\"off\" id=\"captcha\" /><br /><img onclick=\"rfr='&'+(new Date()).getTime();this.src+=rfr\" style=\"cursor:pointer\" src=\"captcha.php?image_file=".$im."&len=".$len."&t1=".$t1."&t2=".$t2."&t3=".$t3."&b1=".$b1."&b2=".$b2."&b3=".$b3."\" />".$error_message;
}


//Linecraft PHP Form mail v.1.2.0
if(isset($_POST["verstuur"])){
$mail_form="[object FormElt]";
$exception_fields=array("captcha","verstuur","wis");
$to="mijn@emailadres.nl";
$from=$_POST['Emailadres'];
$cc="";
$bcc="";
$host="";
$username="";
$password="";
$subject="Contactformulier";
$message_header="";
$message_footer="";
$message_body="";
$format_html="\r\nContent-type: text/plain; charset=utf-8";
$html="";
$success_page="succes.php";
$error_page="failure.php";
$o_t="";
$c_t="";
$br="\n";
//If HTML
if($html=="1"){
$o_t="<b>";
$c_t="</b>";
$br="<br>";
$format_html="\r\nContent-type: text/html; charset=utf-8";
}
foreach($_POST as $fieldName => $value){
if(!in_array($fieldName,$exception_fields)){
$fieldName=str_replace("_"," ",$fieldName);
$message_body=$message_body.$o_t.$fieldName.$c_t.": ".$value.$br;
}
}
$message=$message_header.$br.$message_body.$br.$message_footer;
@include_once "Mail.php";
@include_once("Mail/mime.php");
if(!class_exists('Mail') || !class_exists('Mail_mime')){
$headers="From:".$from.$format_html;
$headers.=($cc!="")?("\r\nCc: " . $cc):"";
$headers.=($bcc!="")?("\r\nBcc: " . $bcc):"";
if(mail($to, stripslashes($subject), stripslashes($message),$headers)){
if($success_page!=""){
header("Location:".$success_page);
}
}else{
if($error_page!=""){
header("Location:".$error_page);
}
}
}else{
if($cc!=""){$to.=", ".$cc;}
if($bcc!=""){$to.=", ".$bcc;}
if($host!="" && $username!="" && $password!=""){
$contructor = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));
}else{
$contructor = Mail::factory('mail');
}
$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
if($cc!=""){$headers['Cc']=$cc;}
if($html=="1"){
$mime = new Mail_mime("\n");
$mime->setHTMLBody($message);
$message = $mime->get();
$headers = $mime->headers($headers);
}
$mail = $contructor->send($to, $headers, $message);

if (PEAR::isError($mail)){
if($error_page!=""){
header("Location:".$error_page);
}
}else{
if($success_page!=""){
header("Location:".$success_page);
}
}
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/TempContact.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<!-- InstanceBeginEditable name="doctitle" -->
<title>SUUS-DESIGN - Contacttest</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
margin: 0;
color: #6CF;
font-family: "Courier New", Courier, monospace;
line-height: 1.4;
background-color: #FFF;
font-weight: bold;
padding-top: 0;
padding-right: 0;
padding-bottom: 0;
padding-left: 14;
}

/* ~~this fixed width container surrounds the other divs~~ */
.container {
width: 980px;
background: #FFF; /* the auto value on the sides, coupled with the width, centers the layout */
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
}

/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
background: #ADB96E;
height: 124px;
width: 980px;
}

/* ~~ These are the columns for the layout. ~~

1) Padding is only placed on the top and/or bottom of the divs. The elements within these divs have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.

2) No margin has been given to the columns since they are all floated. If you must add margin, avoid placing it on the side you're floating toward (for example: a right margin on a div set to float right). Many times, padding can be used instead. For divs where this rule must be broken, you should add a "display:inline" declaration to the div's rule to tame a bug where some versions of Internet Explorer double the margin.

3) Since classes can be used multiple times in a document (and an element can also have multiple classes applied), the columns have been assigned class names instead of IDs. For example, two sidebar divs could be stacked if necessary. These can very easily be changed to IDs if that's your preference, as long as you'll only be using them once per document.

4) If you prefer your nav on the right instead of the left, simply float these columns the opposite direction (all right instead of all left) and they'll render in reverse order. There's no need to move the divs around in the HTML source.

*/
.sidebar1 {
float: left;
width: 148px;
background-color: #0FC;
}
.content {
width: 655px;
float: left;
height: 559px;
padding-right: 0px;
padding-left: 15px;
background-color: #FFF;
padding-top: 25px;
font-family: "Courier New", Courier, monospace;
font-size: 10pt;
font-weight: bold;
color: #6CF;
line-height: normal;
}

/* ~~ The footer ~~ */
.footer {
position: relative;/* this gives IE6 hasLayout to properly clear */
clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
height: 27px;
padding-top: 5px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
width: 980px;
font-family: "Courier New", Courier, monospace;
color: #FFF;
background-color: #6CF;
font-weight: bold;
font-size: 10pt;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0;
padding-left: 14px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}

/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #FFF; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
text-decoration: none;
}
.linkemail {
font-family: "Courier New", Courier, monospace;
font-size: 10pt;
font-weight: bold;
color: #6CF;
}
a:visited {
color: #FFF;
text-decoration: none;
}
.visitedeama {
font-family: "Courier New", Courier, monospace;
font-size: 10pt;
font-weight: bold;
color: #F0C;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}

/* ~~ This grouped selector gives the lists in the .content area space ~~ */
.content ul, .content ol {
padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */
}

/* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */
ul.nav {
list-style: none; /* this removes the list marker */
border-top: 1px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */
margin-bottom: 15px; /* this creates the space between the navigation on the content below */
}
ul.nav li {
border-bottom: 1px solid #666; /* this creates the button separation */
}
ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */
display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */
width: 160px; /*this width makes the entire button clickable for IE6. If you don't need to support IE6, it can be removed. Calculate the proper width by subtracting the padding on this link from the width of your sidebar container. */
text-decoration: none;
background: #C6D580;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 15px;
}
ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */
background: #ADB96E;
color: #FFF;
}

/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
</script>
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.captcha_error_message {
font-family: "Courier New", Courier, monospace;
font-size: 10pt;
font-weight: bold;
color: #CCC;
float: left;
padding-left: 15px;
}
</style>
<!-- InstanceEndEditable -->
</head>

<body>

<div class="container">
<div class="header"><!-- end .header --><img src="images/header.jpg" width="980" height="124" alt="header" /></div>
<div class="sidebar1"><img src="images/logo.jpg" width="148" height="64" alt="logo" />
<ul id="MenuBar1" class="MenuBarVertical">
<li><a href="home.html">Home</a> </li>
<li><a href="about_suus.html">About Suus</a></li>
<li><a href="outerwear.html">Outerwear</a></li>
<li><a href="night_&amp;_underwear.html">Night &amp; Underwear</a></li>
<li><a href="legwear.html">Legwear</a></li>
<li><a href="other.html">Other</a></li>
<li><a href="contactformulier.php">Contact</a></li>
</ul>
</div>
<!-- InstanceBeginEditable name="Portfolio" -->
<div class="content">
<!-- end .content -->
<form action="" method="post" name="contact" id="contact">
<p>
<label for="Naam">Naam:<br />
</label>
<span id="sprytextfield1">
<label for="Naam"></label>
<input type="text" name="Naam" id="Naam" value="<?php echo $_POST['Naam'];?>"/>
<span class="textfieldRequiredMsg">Er is geen naam ingevuld.</span><span class="textfieldInvalidFormatMsg">Er is geen naam ingevuld.</span></span> </p>
<p>
<label for="Emailadres">Uw emailadres: <br />
</label>
<span id="sprytextfield2">
<label for="Emailadres"></label>
<input type="text" name="Emailadres" id="Emailadres" value="<?php echo $_POST['Emailadres'];?>"/>
<span class="textfieldRequiredMsg">Onjuist emailadres.</span><span class="textfieldInvalidFormatMsg">Onjuist emailadres.</span></span> </p>
<p>
<label for="Onderwerp">Onderwerp:<br />
</label>
<span id="sprytextfield3">
<label for="Onderwerp"></label>
<input type="text" name="Onderwerp" id="Onderwerp" value="<?php echo $_POST['Onderwerp'];?>"/>
<span class="textfieldRequiredMsg">Er is geen onderwerp ingevuld.</span><span class="textfieldInvalidFormatMsg">Er is geen onderwerp ingevuld.</span></span></p>
<p>
<label for="Bericht">Uw bericht:<br />
</label>
<span id="sprytextarea1">
<textarea name="Bericht" id="Bericht" cols="55" rows="6"></textarea>
<span class="textareaRequiredMsg"> </span></span> <br />
</p>
<p>
Type de verificatiecode na:
<?php makeCaptcha("ikhebje.png","7","102","102","102","233","235","235",$captcha_error_message);?>
</p>
<p>&nbsp; </p>
<p>
<input type="submit" name="verstuur" id="verstuur" value="Verstuur" />
<input type="reset" name="wis" id="wis" value="Wis" />
</p>
</form>
<p>adres</p>
</div>
<script type="text/javascript">
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {validateOn:["blur"]});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});
</script>
<!-- InstanceEndEditable --><img src="images/suus speak.jpg" width="162" height="584" alt="suus speak" />
<div class="footer">
<p><a href="disclaimer.html" class="footer">Disclaimer</a></p>
<!-- end .footer --></div>
<!-- end .container --></div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
<!-- InstanceEnd --></html>
 
Bij een textarea plaats je de standaardtekst tussen de tags, dus:
PHP:
<textarea name="Bericht" id="Bericht" cols="55" rows="6"><?php echo $_POST['Bericht'];?></textarea>
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan