i have this code (it's a newsletter script) and i have made my own kind of captcha to this script, but i can not get the error message for the captcha to show in the same place as the error messages as for the name and email fields. I can only get the error message for the captcha using java alert message, but i dont want that. The fields for the captcha code are named: kontaktaEditbox2 and kontaktaEditbox55. The kontaktaEditbox2 is a read only field that puts out a 6 digit random code, and the kontaktaEditbox55 field is the the text field that you typ in the rabdom code before submiting to the newsletter.

And just to be clere. The name and email are are in Mysql DB, but the captcha function is only in the code, it has nothing to do with the Mysql DB.

Here is a demo site: http://test3.fcab.se/Easy_newsletter/

Hope that some one can help.

Thank you.

Regards.

//Patrik Iden

Here is the code:

Code:
<?php
session_start();
$_SESSION['errors']="Wrong Code!";
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Easy Newsletter Sytem</title>
<meta name="generator" content="WYSIWYG Web Builder 8 - http://www.wysiwygwebbuilder.com">
<style type="text/css">
div#container
{
   width: 1280px;
   position: relative;
   margin-top: 0px;
   margin-left: auto;
   margin-right: auto;
   text-align: left;
}
body
{
   text-align: center;
   margin: 0;
   background-color: #000000;
   color: #000000;
}
</style>
<style type="text/css">
@font-face
{
   font-family: 'Open Sans Condensed Light';
   src: url('opensans-condlight.eot');
   src: url('opensans-condlight.eot?iefix') format('embedded-opentype'),
        url('opensans-condlight.ttf') format('truetype');
}
a
{
   color: #0000FF;
   text-decoration: underline;
}
a:visited
{
   color: #FF0000;
}
a:active
{
   color: #FF0000;
}
a:hover
{
   color: #0000FF;
   text-decoration: underline;
}
a.style1:link
{
   color: #4B4B4B;
}
a.style1:visited
{
   color: #4B4B4B;
   text-decoration: underline;
}
a.style1:active
{
   color: #4B4B4B;
   text-decoration: underline;
}
a.style1:hover
{
   color: #000000;
   text-decoration: underline;
}
</style>
<style type="text/css">
#indexImage1
{
   border: 0px #000000 solid;
}
#indexImage2
{
   border: 0px #000000 solid;
}
#indexImage4
{
   border: 0px #000000 solid;
}
#wb_indexText1 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_indexText1 div
{
   text-align: left;
}
#wb_indexText2 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_indexText2 div
{
   text-align: left;
}
#indexImage3
{
   border: 0px #000000 solid;
}
#wb_indexText3 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_indexText3 div
{
   text-align: left;
}

.error 
{
   color: #FF0000;
}
#kontaktaEditbox2
{
   border: 0px #C0C0C0 solid;
   background-color: transparent;
   color :#FF0000;
   font-family: Verdana;
   font-size: 11px;
   text-align: left;
   vertical-align: middle;
}
</style>
<style type="text/css">
a 
{
  -moz-outline: none 0;
  outline: none 0;
}

</style>


<script type="text/javascript">
<!--
function ValidateindexForm1(theForm)
{
   var regexp;
   regexp = /^[-+]?\d*\.?\d*$/;
   if (!regexp.test(theForm.kontaktaEditbox55.value))
   {
      alert("<?php echo $_SESSION['errors']; ?>");
      theForm.kontaktaEditbox55.focus();
      return false;
   }
   if (theForm.kontaktaEditbox55.value == "")
   {
      alert("<?php echo $_SESSION['errors']; ?>");
      theForm.kontaktaEditbox55.focus();
      return false;
   }
   if (theForm.kontaktaEditbox55.value.length < 6)
   {
      alert("<?php echo $_SESSION['errors']; ?>");
      theForm.kontaktaEditbox55.focus();
      return false;
   }
   if (theForm.kontaktaEditbox55.value.length > 6)
   {
      alert("<?php echo $_SESSION['errors']; ?>");
      theForm.kontaktaEditbox55.focus();
      return false;
   }
if (theForm.kontaktaEditbox55.value != theForm.kontaktaEditbox2.value)
   {
      alert("<?php echo $_SESSION['errors']; ?>");
      theForm.kontaktaEditbox55.focus();
      return false;
   }
   return true;
}
//-->
</script>
<script type="text/javascript">
<!--
function SetStyle(id, className)
{
   var elem=document.getElementById(id);
   if(elem)
   {
      elem.className=className;
   }
}
//-->
</script>
</head>
<body>
<div id="container">
<div id="wb_indexShape1" style="position:absolute;left:99px;top:78px;width:1082px;height:725px;z-index:0;">
<img src="images/index_0001.gif" id="indexShape1" alt="" style="border-width:0;width:1082px;height:725px;"></div>
<div id="wb_indexShape5" style="position:absolute;left:117px;top:548px;width:406px;height:250px;z-index:1;">
<img src="images/index_0005.png" id="indexShape5" alt="" style="border-width:0;width:406px;height:250px;"></div>
<div id="wb_indexExtension1" style="position:absolute;left:144px;top:604px;width:350px;height:165px;z-index:2;">

<?php
  //load configuration
  require("config.php");
?>

<?php  
  //form submitted
  if(isset($_POST["submit"])){
    //connect to database
    @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php");
    @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php");



    $name = $_POST["name"];
    $email = $_POST["email"];



    //subscribe
    if($_POST["action"]=="subscribe"){
      //check if name is long enough
      if(strlen($name)<3){
        ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">Name must consist of at least 3 characters.</div><?php
     //check if email is valid
      }else if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$email)){
        ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">Email address is not valid.</div><?php
     //check if email already exists
      }else if(@mysql_num_rows(@mysql_query("SELECT id FROM $db_table WHERE email='$email';"))){
        ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">Email address exists already.</div>




      <?php
       //insert values
      }else{
        @mysql_query("INSERT INTO $db_table (email,name) VALUES ('$email','$name');");

        //error occurred
        if(@mysql_error()){
          ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">An unknown error occurred. Please try again later.</div><?php
        //successful
        }else{
          ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">Subscription was successful. Thank you!</div><?php
        }
      }
    //unsubscribe
    }else{
      @mysql_query("DELETE FROM $db_table WHERE email='$email';");

      //error occurred
      if(@mysql_error()){
        ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">An unknown error occurred. Please try again later.</div><?php
      //email not found
      }else if(@mysql_affected_rows()==0){
        ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">Email address not found.</div><?php
      //successful
      }else{
        ?><div><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">You have unsubscribed successfully!</div><?php
      }
    }
  }
?>

<?php
   //close database connection
  @mysql_close();
?>

<form name="indexForm1" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="indexForm1" onsubmit="return ValidateindexForm1(this)">
  <table>
      <td><div style="color:#000000;font-family:'Open Sans Condensed Light';font-size:15px;">Your name:</td></div>
      <td><input type="text" name="name" value="" style="width:186px; maxlength="255"></td>
    </tr>
    <tr>
      <td><div style="color:#000000;font-family:'Open Sans Condensed Light';font-size:15px;">Your email address:</td></div>
      <td><div align="right"><input type="text" name="email" value="" style="width:186px; maxlength="255"></td></div>
    </tr>
    <tr>
<td><div style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:16px;">State this code:  
  <input type="number" id="kontaktaEditbox2" style="width:50px;font-family:'Open Sans Condensed Light';font-size:14px;z-index:2" name="kontaktaEditbox2" value="<?php $random = substr(number_format(time() * rand(),0,'',''),0,6); echo $random?>" readonly="readonly" autocomplete="off">  <input type="number" id="kontaktaEditbox55" style="width:187px; position:absolute;" name="kontaktaEditbox55" value="" maxlength="6" autocomplete="off"></td></div>

</tr>
    <tr>
<td>&nbsp;</td>
      <td><input type="radio" name="action" value="subscribe" id="action_subscribe" checked> <label for="action_subscribe"><span style="color:#000000;font-family:'Open Sans Condensed Light';font-size:14px;">Subscribe</label>&nbsp;<input type="radio" name="action" value="unsubscribe" id="action_unsubscribe"> <label for="action_unsubscribe">Unsubscribe</label><div align="right"></td>
   </tr>
      <td>&nbsp;</td>
      <td><div align="right"><input type="submit" name="submit" style="color:#000000;font-family:'Open Sans Condensed Light';font-size:14px;value="subscribe"></td></div>
    </tr>
<td><span style="color:#FF0000;font-family:'Open Sans Condensed Light';font-size:12px;"><a href="admin.php"> Admin area - Login </a></span></td>
</table>
</form>
</div>
<div id="wb_indexShape2" style="position:absolute;left:129px;top:93px;width:1022px;height:80px;z-index:3;">
<img src="images/index_0002.gif" id="indexShape2" alt="" style="border-width:0;width:1022px;height:80px;"></div>
<div id="wb_indexShape3" style="position:absolute;left:115px;top:174px;width:1050px;height:380px;z-index:4;">
<img src="images/index_0004.png" id="indexShape3" alt="" style="border-width:0;width:1050px;height:380px;"></div>
<div id="wb_indexImage1" style="position:absolute;left:1073px;top:98px;width:70px;height:68px;visibility:hidden;z-index:5;">
<img src="images/mail.png" id="indexImage1" alt="" border="0" style="width:70px;height:68px;"></div>
<div id="wb_indexImage2" style="position:absolute;left:1140px;top:378px;width:0px;height:0px;z-index:6;">
<img src="" id="indexImage2" alt="" border="0" style="width:0px;height:0px;"></div>
<div id="wb_indexImage4" style="position:absolute;left:626px;top:300px;width:506px;height:240px;opacity:0.50;-moz-opacity:0.50;-khtml-opacity:0.50;filter:alpha(opacity=50);z-index:7;">
<img src="images/photodune-1614598-mail-concept-s.jpg" id="indexImage4" alt="" border="0" style="width:506px;height:240px;"></div>
<div id="wb_indexShape8" style="position:absolute;left:130px;top:188px;width:1020px;height:53px;z-index:8;">
<img src="images/index_0007.gif" id="indexShape8" alt="" style="border-width:0;width:1020px;height:53px;"></div>
<div id="wb_indexText1" style="position:absolute;left:150px;top:200px;width:825px;height:313px;z-index:9;text-align:left;">
<span style="color:#000000;font-family:'Open Sans Condensed Light';font-size:21px;">Description of the Easy Newsletter System</span><span style="color:#000000;font-family:Arial;font-size:21px;"><br></span><span style="color:#000000;font-family:Arial;font-size:13px;"><br><br></span><span style="color:#4B4B4B;font-family:'Open Sans Condensed Light';font-size:17px;">Hello, This is a small yet powerfull Newsletter system, with Admin login to send a message to all the users that have subscribed to your Newsletter.<br>In the Admin area you can: Write a standard message to send to all users, You can add users and you can delete users. Users are automaticly deleted from email list when unsubscribed.<br><br>Original script from: <a href="http://www.plohni.com/wb/content/php/Free_scripts.php" target="_blank" class="style1">http://www.plohni.com/wb/content/php/Free_scripts.php</a><br><br>Hope you like this extension, and that you have some use for it.<br><br>Regards<br><br>//Patrik Iden</span></div>
<div id="wb_indexShape4" style="position:absolute;left:758px;top:548px;width:406px;height:250px;z-index:10;">
<img src="images/index_0003.png" id="indexShape4" alt="" style="border-width:0;width:406px;height:250px;"></div>
<div id="wb_indexShape7" style="position:absolute;left:772px;top:562px;width:378px;height:36px;z-index:11;">
<img src="images/index_0008.gif" id="indexShape7" alt="" style="border-width:0;width:378px;height:36px;"></div>
<div id="wb_indexText2" style="position:absolute;left:784px;top:566px;width:347px;height:106px;z-index:12;text-align:left;">
<span style="color:#000000;font-family:'Open Sans Condensed Light';font-size:19px;">Download</span><span style="color:#000000;font-family:'Open Sans Condensed Light';font-size:13px;"><br><br><br></span><span style="color:#4B4B4B;font-family:'Open Sans Condensed Light';font-size:16px;">Download this extension incl, all the source files:<br><a href="http://dl.dropbox.com/u/3182310/Easy_Newsletter.rar" class="style1">http://dl.dropbox.com/u/3182310/Easy_Newsletter.rar</a></span></div>
<div id="wb_indexExtension2" style="position:absolute;left:854px;top:190px;width:290px;height:53px;z-index:13;">
</div>
<div id="wb_indexImage3" style="position:absolute;left:1117px;top:564px;width:30px;height:30px;z-index:14;">
<a href="http://dl.dropbox.com/u/3182310/Easy_Newsletter.rar" target="_self"><img src="images/Button_Down.png" id="indexImage3" alt="" border="0" style="width:30px;height:30px;"></a></div>
<div id="wb_indexImage5" style="position:absolute;left:538px;top:617px;width:208px;height:111px;z-index:15;">
<img src="images/index_0006.png" id="indexImage5" alt="" border="0" style="width:208px;height:111px;"></div>
<div id="wb_indexShape6" style="position:absolute;left:131px;top:562px;width:378px;height:36px;z-index:16;">
<img src="images/index_0009.gif" id="indexShape6" alt="" style="border-width:0;width:378px;height:36px;"></div>
<div id="wb_indexText3" style="position:absolute;left:146px;top:566px;width:314px;height:26px;z-index:17;text-align:left;">
<span style="color:#000000;font-family:'Open Sans Condensed Light';font-size:19px;">Newsletter</span>
</div>
</body>
</html>