[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

Change text color when invalid CAPTCHA

Hello guys,

I have just implemented a CAPTCHA routine (with help from the experts here) and want to manage the invalid CAPTCH by changing the text color of the following: "Please enter the code appearing in the following picture" as shown in the code snipet.

Rgds,
Etienne
<?php
// START THE SESSION EVERY TIME
error_reporting(E_ALL);
session_start();
 
// TEST FOR THE CAPTCHA
if(isset($_POST["captcha"]))
{
	if($_SESSION["captcha"]==$_POST["captcha"])
	{
	    require_once("ProcessMail.php");
	}
	else
	{
	    echo 'CAPTCHA is not valid; Please try adgain';
			// VISUALIZE THE SUPERGLOBAL ARRAYS
		echo "<pre>";
		echo "POST: ";var_dump($_POST);
		echo "\n\n\n";
		echo "SESSION: ";var_dump($_SESSION);
	}
 
 	// NO FURTHER PROCESSING
	die();
}
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<head>
<title>Oceanlogics :: Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
        background-color: #1A6173;
        text-align: center;
}
.oneColFixCtr #container {
        width: 750px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
        background: #1A6173;
        margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
        text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColFixCtr #mainContent {
        padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.style3 {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        color: #1A6173;
        font-weight: bold;
}
.style4 {font-size: 18px}
.style6 {font-size: 24px}
.style7 {
	font-family: Georgia, "Times New Roman", Times, serif;
	margin-left: 3px;
	margin-top: 3px;
	font-size: 10px;
	color: #1A6173;
}
-->
 
</style></head>
 
<body class="oneColFixCtr">
 
<div id="container">
  <div id="mainContent">
    <table border=0 cellspacing=0 cellpadding=0 width=750 height=650>
<tr>
<td><img border=0 src="Images/header_top.jpg" height=147 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=21>
<tr>
<td><img border=0 src="Images/spacer_1.jpg" height=21 width=11></td>
<td><a href="Home.html"><img border=0 src="Images/nav_home.jpg" height=21 width=95 onMouseOver="this.src = 'Images/nav_home_hot.jpg' " onMouseOut="this.src = 'Images/nav_home.jpg' "></a></td>
<td><img border=0 src="Images/spacer_2.jpg" height=21 width=10></td>
<td><img border=0 src="Images/nav_services.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_services_hot.jpg' " onMouseOut="this.src = 'Images/nav_services.jpg' "></td>
<td><img border=0 src="Images/spacer_3.jpg" height=21 width=9></td>
<td><img border=0 src="Images/nav_products.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_products_hot.jpg' " onMouseOut="this.src = 'Images/nav_products.jpg' "></td>
<td><img border=0 src="Images/spacer_4.jpg" height=21 width=10></td>
<td><img border=0 src="Images/nav_downloads.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_downloads_hot.jpg' " onMouseOut="this.src = 'Images/nav_downloads.jpg' "></td>
<td><img border=0 src="Images/spacer_5.jpg" height=21 width=9></td>
<td><a href="phpBB2/index.php"><img border=0 src="Images/nav_forum.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_forum_hot.jpg' " onMouseOut="this.src = 'Images/nav_forum.jpg' "></a></td>
<td><img border=0 src="Images/spacer_6.jpg" height=21 width=9></td>
<td><img border=0 src="Images/nav_news.jpg" height=21 width=97 onMouseOver="this.src = 'Images/nav_news_hot.jpg' " onMouseOut="this.src = 'Images/nav_news.jpg' "></td>
<td><img border=0 src="Images/spacer_7.jpg" height=21 width=9></td>
<td><a href="Contact.html"><img border=0 src="Images/nav_contact_us_hot.jpg" height=21 width=95></a></td>
 
<td><img border=0 src="Images/spacer_8.jpg" height=21 width=12></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/header_bottom.jpg" height=27 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=386>
<tr>
<td><img border=0 src="Images/border_left.jpg" height=386 width=20></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=200 height=386>
<tr>
<td background="Images/body_div_1.jpg" height=25 width=200><span class="style3">Name</span></td>
</tr><tr>
<td background="Images/body_div_2.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Name" type="text" class="form m_text" id="Name" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div3.jpg" height=25 width=200><span class="style3">Company</span></td>
</tr><tr>
<td background="Images/body_div_4.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Company" type="text" class="form m_text" id="Company" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div_5.jpg" height=25 width=200><span class="style3">Phone</span></td>
</tr><tr>
<td background="Images/body_div_6.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Phone" type="text" class="form m_text" id="Phone" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div_7.jpg" height=25 width=200><span class="style3">Email</span></td>
</tr><tr>
<td background="Images/body_div_8.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Email" type="text" class="form m_text" id="Email" size="28" />
</span></td>
</tr><tr>
<td width=200 height=136 valign="bottom" background="Images/body_div_9.jpg"><p align="left" class="style3 style4"><span class="style6">Oceanlogics Inc</span><Br>
  1141 des Trilles<Br>
  Prevost, Quebec<Br>
   Canada J0R 1T0<Br>
</td>
</tr><tr>
<td background="Images/body_div_10.jpg" height=25 width=200><span class="style3">P/F: +001 (450) 669-8859</span></td>
</tr><tr>
<td background="Images/body_div_11.jpg" height=25 width=200> </td>
</tr>
</table></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=510 height=386>
<tr>
<td background="Images/body_div_12.jpg" height=25 width=510><div align="right"><span class="style3" style="margin-top0:px;">Subject</span></div></td>
</tr><tr>
<td background="Images/body_div_13.jpg" height=25 width=510><div align="right"><span class="form_div" style="margin-top0:px;">
  <input name="Subject" type="text" class="form m_text" id="Subject" size="77" />
</span></div></td>
</tr><tr>
<td width=510 height=25 background="Images/body_div_14.jpg" class="style3"><div align="right">Message</div></td>
</tr><tr>
<td width=510 height=286 valign="top" background="Images/body_div_15.jpg"><div align="right"><span style="margin-top:0px">
  <textarea name="Message" cols="60" rows="10" class="form m_text" id="Message" style="height:260px; overflow:hidden"></textarea>
</span></div></td>
</tr><tr>
<td width=510 height=25 valign="bottom" background="Images/body_div_16.jpg"><div align="right" class="oneColFixCtr">
  <span style="margin-left:3px; margin-top:3px;"><span class="style7">Please enter the code appearing in the following picture</span><span style="margin-left:3px; margin-top:3px;"> <img src="Captcha.php" alt="captcha image" height="20" /></span></span><span class="_text" style="margin-left:3px; margin-top:3px;"><span class="_text" style="margin-left:3px; margin-top:3px;">
  <input type="text" name="captcha" size="6" maxlength="6">
  </span>
  <input type="submit" value="Submit">
  </span></div></td>
</tr>
</table></td>
<td><img border=0 src="Images/border_right.jpg" height=386 width=20></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_top.jpg" height=47 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=11>
<tr>
<td><img border=0 src="Images/spacer_9.jpg" height=11 width=51></td>
<td><img border=0 src="Images/nav_company.jpg" height=11 width=54></td>
<td><img border=0 src="Images/nav_support.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_links.jpg" height=11 width=34></td>
<td><img border=0 src="Images/nav_upcoming_events.jpg" height=11 width=100></td>
<td><img border=0 src="Images/nav_faq.jpg" height=11 width=26></td>
<td><img border=0 src="Images/nav_our_clients.jpg" height=11 width=65></td>
<td><img border=0 src="Images/nav_pictures.jpg" height=11 width=52></td>
<td><img border=0 src="Images/nav_intranet.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_webmail.jpg" height=11 width=53></td>
<td><img border=0 src="Images/nav_site_map.jpg" height=11 width=56></td>
<td><a href="Terms.html"><img border=0 src="Images/nav_terms_and_conditions.jpg" height=11 width=116></a></td>
<td><img border=0 src="Images/spacer_10.jpg" height=11 width=43></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_bottom.jpg" height=11 width=750></td>
</tr>
</table>
  <!-- end #mainContent --></div>
</div>
 
</body>

Open in new window

0
etiennedemers
Asked:
etiennedemers
  • 9
  • 7
1 Solution
 
sunithnairCommented:
you can either change the color in the span7 or change the color for this span alone
chaange the color of style7
 
<span class="style7">Please enter the code appearing in the following picture</span>
 
OR
 
<span class="style7" style="color:red;">Please enter the code appearing in the following picture</span>

Open in new window

0
 
etiennedemersAuthor Commented:
Thanks,

I am actually looking for the exact code to replace line 15 to 20 of my original code snippet.

Alternativelly, would it be possible to have the sumbit button disabled until the CAPTCHA is good?
0
 
sunithnairCommented:
Line 15-20 replacement. The submit button can be disabled but in this case it cannot be because the captcha check is done after posback so if you disable submit button they cannot postback
echo "<span style='color:red'>CAPTCHA is not valid; Please try adgain";
                        // VISUALIZE THE SUPERGLOBAL ARRAYS
                echo "<pre>";
                echo "POST: ";var_dump($_POST);
                echo "\n\n\n";
                echo "SESSION: ";var_dump($_SESSION);
echo "</span>"

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
etiennedemersAuthor Commented:
I end up with this displayed in red in the browser when I want to keep the same page, just change the color of the text specified in the original question in order for the end-used to know he has entered invalid CAPTCHA or none.

CAPTCHA is not valid; Please try adgain
POST: array(7) {
  ["Name"]=>
  string(0) ""
  ["Company"]=>
  string(0) ""
  ["Phone"]=>
  string(0) ""
  ["Email"]=>
  string(0) ""
  ["Subject"]=>
  string(0) ""
  ["Message"]=>
  string(0) ""
  ["captcha"]=>
  string(0) ""
}



SESSION: array(1) {
  ["captcha"]=>
  string(6) "YjBM6b"
}

cheers
0
 
sunithnairCommented:
Then try it this way
echo "<span style='color:red'>CAPTCHA is not valid; Please try again</span>";
                        // VISUALIZE THE SUPERGLOBAL ARRAYS
                echo "<pre>";
                echo "POST: ";var_dump($_POST);
                echo "\n\n\n";
                echo "SESSION: ";var_dump($_SESSION);

Open in new window

0
 
etiennedemersAuthor Commented:
OK the reason why my page was reseting was because I had die in line 24 of original snippet.

I might not have been clear.

I have the following line "Please enter the code appearing in the following picture" (line 154) whitch uses "style7" (line 57).

The goal, as you suggested, is to modify style7 color to red.

echo will not work as it puts text on the web page.

Do you any any other ideas?

Cheers
0
 
sunithnairCommented:
May be we are not on the same page yet. Can you explain what is the exact requirement?
0
 
etiennedemersAuthor Commented:
OK

please follow this link: http://www.oceanlogics.com/Contact.php

it will all come clear.

do not put anything in, just click submit.

There are no indications to the end user that the captcha is invalid.

I just want to change the color of the text beside the captcha to red.
0
 
sunithnairCommented:
Now i see what you need. My php skills are not very good but this is what you need to do
<?php
// START THE SESSION EVERY TIME
error_reporting(E_ALL);
session_start();
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<head>
<title>Oceanlogics :: Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
        background-color: #1A6173;
        text-align: center;
}
.oneColFixCtr #container {
        width: 750px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
        background: #1A6173;
        margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
        text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColFixCtr #mainContent {
        padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.style3 {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        color: #1A6173;
        font-weight: bold;
}
.style4 {font-size: 18px}
.style6 {font-size: 24px}
<?php
if(isset($_POST["captcha"]))
{
        if($_SESSION["captcha"]==$_POST["captcha"])
        {
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: #1A6173;
}
<?php
        }
        else
        {
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: red;
}
<?php
        }
else
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: #1A6173;
}
<?php
}
}
?>
-->
 
</style></head>
 
<body class="oneColFixCtr">
 
<div id="container">
  <div id="mainContent">
    <table border=0 cellspacing=0 cellpadding=0 width=750 height=650>
<tr>
<td><img border=0 src="Images/header_top.jpg" height=147 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=21>
<tr>
<td><img border=0 src="Images/spacer_1.jpg" height=21 width=11></td>
<td><a href="Home.html"><img border=0 src="Images/nav_home.jpg" height=21 width=95 onMouseOver="this.src = 'Images/nav_home_hot.jpg' " onMouseOut="this.src = 'Images/nav_home.jpg' "></a></td>
<td><img border=0 src="Images/spacer_2.jpg" height=21 width=10></td>
<td><img border=0 src="Images/nav_services.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_services_hot.jpg' " onMouseOut="this.src = 'Images/nav_services.jpg' "></td>
<td><img border=0 src="Images/spacer_3.jpg" height=21 width=9></td>
<td><img border=0 src="Images/nav_products.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_products_hot.jpg' " onMouseOut="this.src = 'Images/nav_products.jpg' "></td>
<td><img border=0 src="Images/spacer_4.jpg" height=21 width=10></td>
<td><img border=0 src="Images/nav_downloads.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_downloads_hot.jpg' " onMouseOut="this.src = 'Images/nav_downloads.jpg' "></td>
<td><img border=0 src="Images/spacer_5.jpg" height=21 width=9></td>
<td><a href="phpBB2/index.php"><img border=0 src="Images/nav_forum.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_forum_hot.jpg' " onMouseOut="this.src = 'Images/nav_forum.jpg' "></a></td>
<td><img border=0 src="Images/spacer_6.jpg" height=21 width=9></td>
<td><img border=0 src="Images/nav_news.jpg" height=21 width=97 onMouseOver="this.src = 'Images/nav_news_hot.jpg' " onMouseOut="this.src = 'Images/nav_news.jpg' "></td>
<td><img border=0 src="Images/spacer_7.jpg" height=21 width=9></td>
<td><a href="Contact.html"><img border=0 src="Images/nav_contact_us_hot.jpg" height=21 width=95></a></td>
 
<td><img border=0 src="Images/spacer_8.jpg" height=21 width=12></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/header_bottom.jpg" height=27 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=386>
<tr>
<td><img border=0 src="Images/border_left.jpg" height=386 width=20></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=200 height=386>
<tr>
<td background="Images/body_div_1.jpg" height=25 width=200><span class="style3">Name</span></td>
</tr><tr>
<td background="Images/body_div_2.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Name" type="text" class="form m_text" id="Name" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div3.jpg" height=25 width=200><span class="style3">Company</span></td>
</tr><tr>
<td background="Images/body_div_4.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Company" type="text" class="form m_text" id="Company" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div_5.jpg" height=25 width=200><span class="style3">Phone</span></td>
</tr><tr>
<td background="Images/body_div_6.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Phone" type="text" class="form m_text" id="Phone" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div_7.jpg" height=25 width=200><span class="style3">Email</span></td>
</tr><tr>
<td background="Images/body_div_8.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Email" type="text" class="form m_text" id="Email" size="28" />
</span></td>
</tr><tr>
<td width=200 height=136 valign="bottom" background="Images/body_div_9.jpg"><p align="left" class="style3 style4"><span class="style6">Oceanlogics Inc</span><Br>
  1141 des Trilles<Br>
  Prevost, Quebec<Br>
   Canada J0R 1T0<Br>
</td>
</tr><tr>
<td background="Images/body_div_10.jpg" height=25 width=200><span class="style3">P/F: +001 (450) 669-8859</span></td>
</tr><tr>
<td background="Images/body_div_11.jpg" height=25 width=200> </td>
</tr>
</table></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=510 height=386>
<tr>
<td background="Images/body_div_12.jpg" height=25 width=510><div align="right"><span class="style3" style="margin-top0:px;">Subject</span></div></td>
</tr><tr>
<td background="Images/body_div_13.jpg" height=25 width=510><div align="right"><span class="form_div" style="margin-top0:px;">
  <input name="Subject" type="text" class="form m_text" id="Subject" size="77" />
</span></div></td>
</tr><tr>
<td width=510 height=25 background="Images/body_div_14.jpg" class="style3"><div align="right">Message</div></td>
</tr><tr>
<td width=510 height=286 valign="top" background="Images/body_div_15.jpg"><div align="right"><span style="margin-top:0px">
  <textarea name="Message" cols="60" rows="10" class="form m_text" id="Message" style="height:260px; overflow:hidden"></textarea>
</span></div></td>
</tr><tr>
<td width=510 height=25 valign="bottom" background="Images/body_div_16.jpg"><div align="right" class="oneColFixCtr">
  <span style="margin-left:3px; margin-top:3px;"><span class="style7">Please enter the code appearing in the following picture</span><span style="margin-left:3px; margin-top:3px;"> <img src="Captcha.php" alt="captcha image" height="20" /></span></span><span class="_text" style="margin-left:3px; margin-top:3px;"><span class="_text" style="margin-left:3px; margin-top:3px;">
  <input type="text" name="captcha" size="6" maxlength="6">
  </span>
  <input type="submit" value="Submit">
  </span></div></td>
</tr>
</table></td>
<td><img border=0 src="Images/border_right.jpg" height=386 width=20></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_top.jpg" height=47 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=11>
<tr>
<td><img border=0 src="Images/spacer_9.jpg" height=11 width=51></td>
<td><img border=0 src="Images/nav_company.jpg" height=11 width=54></td>
<td><img border=0 src="Images/nav_support.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_links.jpg" height=11 width=34></td>
<td><img border=0 src="Images/nav_upcoming_events.jpg" height=11 width=100></td>
<td><img border=0 src="Images/nav_faq.jpg" height=11 width=26></td>
<td><img border=0 src="Images/nav_our_clients.jpg" height=11 width=65></td>
<td><img border=0 src="Images/nav_pictures.jpg" height=11 width=52></td>
<td><img border=0 src="Images/nav_intranet.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_webmail.jpg" height=11 width=53></td>
<td><img border=0 src="Images/nav_site_map.jpg" height=11 width=56></td>
<td><a href="Terms.html"><img border=0 src="Images/nav_terms_and_conditions.jpg" height=11 width=116></a></td>
<td><img border=0 src="Images/spacer_10.jpg" height=11 width=43></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_bottom.jpg" height=11 width=750></td>
</tr>
</table>
  <!-- end #mainContent --></div>
</div>
 
</body>

Open in new window

0
 
sunithnairCommented:
Or using a single condition
<?php
if(isset($_POST["captcha"]) && $_SESSION["captcha"]!=$_POST["captcha"])
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: red
}
<?php
}
else
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: #1A6173;
}
<?php
}
?>

Open in new window

0
 
etiennedemersAuthor Commented:
unfortunatelly this doesn't wotk, eror msg
0
 
sunithnairCommented:
I might have missed some opening or closing tag but this is the way to do it. Please see if I have missed any php tags as I am not sure about PHP. I work on .NET
0
 
sunithnairCommented:
Try this code
<?php
// START THE SESSION EVERY TIME
error_reporting(E_ALL);
session_start();
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<head>
<title>Oceanlogics :: Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
        background-color: #1A6173;
        text-align: center;
}
.oneColFixCtr #container {
        width: 750px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
        background: #1A6173;
        margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
        text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColFixCtr #mainContent {
        padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.style3 {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        color: #1A6173;
        font-weight: bold;
}
.style4 {font-size: 18px}
.style6 {font-size: 24px}
<?php
if(isset($_POST["captcha"]) && $_SESSION["captcha"]!=$_POST["captcha"])
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: red
}
<?php
}
else
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: #1A6173;
}
<?php
}
?>
-->
 
</style></head>
 
<body class="oneColFixCtr">
 
<div id="container">
  <div id="mainContent">
    <table border=0 cellspacing=0 cellpadding=0 width=750 height=650>
<tr>
<td><img border=0 src="Images/header_top.jpg" height=147 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=21>
<tr>
<td><img border=0 src="Images/spacer_1.jpg" height=21 width=11></td>
<td><a href="Home.html"><img border=0 src="Images/nav_home.jpg" height=21 width=95 onMouseOver="this.src = 'Images/nav_home_hot.jpg' " onMouseOut="this.src = 'Images/nav_home.jpg' "></a></td>
<td><img border=0 src="Images/spacer_2.jpg" height=21 width=10></td>
<td><img border=0 src="Images/nav_services.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_services_hot.jpg' " onMouseOut="this.src = 'Images/nav_services.jpg' "></td>
<td><img border=0 src="Images/spacer_3.jpg" height=21 width=9></td>
<td><img border=0 src="Images/nav_products.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_products_hot.jpg' " onMouseOut="this.src = 'Images/nav_products.jpg' "></td>
<td><img border=0 src="Images/spacer_4.jpg" height=21 width=10></td>
<td><img border=0 src="Images/nav_downloads.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_downloads_hot.jpg' " onMouseOut="this.src = 'Images/nav_downloads.jpg' "></td>
<td><img border=0 src="Images/spacer_5.jpg" height=21 width=9></td>
<td><a href="phpBB2/index.php"><img border=0 src="Images/nav_forum.jpg" height=21 width=96 onMouseOver="this.src = 'Images/nav_forum_hot.jpg' " onMouseOut="this.src = 'Images/nav_forum.jpg' "></a></td>
<td><img border=0 src="Images/spacer_6.jpg" height=21 width=9></td>
<td><img border=0 src="Images/nav_news.jpg" height=21 width=97 onMouseOver="this.src = 'Images/nav_news_hot.jpg' " onMouseOut="this.src = 'Images/nav_news.jpg' "></td>
<td><img border=0 src="Images/spacer_7.jpg" height=21 width=9></td>
<td><a href="Contact.html"><img border=0 src="Images/nav_contact_us_hot.jpg" height=21 width=95></a></td>
 
<td><img border=0 src="Images/spacer_8.jpg" height=21 width=12></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/header_bottom.jpg" height=27 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=386>
<tr>
<td><img border=0 src="Images/border_left.jpg" height=386 width=20></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=200 height=386>
<tr>
<td background="Images/body_div_1.jpg" height=25 width=200><span class="style3">Name</span></td>
</tr><tr>
<td background="Images/body_div_2.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Name" type="text" class="form m_text" id="Name" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div3.jpg" height=25 width=200><span class="style3">Company</span></td>
</tr><tr>
<td background="Images/body_div_4.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Company" type="text" class="form m_text" id="Company" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div_5.jpg" height=25 width=200><span class="style3">Phone</span></td>
</tr><tr>
<td background="Images/body_div_6.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Phone" type="text" class="form m_text" id="Phone" size="28" />
</span></td>
</tr><tr>
<td background="Images/body_div_7.jpg" height=25 width=200><span class="style3">Email</span></td>
</tr><tr>
<td background="Images/body_div_8.jpg" height=25 width=200><span class="form_div" style="margin-top0:px;">
  <input name="Email" type="text" class="form m_text" id="Email" size="28" />
</span></td>
</tr><tr>
<td width=200 height=136 valign="bottom" background="Images/body_div_9.jpg"><p align="left" class="style3 style4"><span class="style6">Oceanlogics Inc</span><Br>
  1141 des Trilles<Br>
  Prevost, Quebec<Br>
   Canada J0R 1T0<Br>
</td>
</tr><tr>
<td background="Images/body_div_10.jpg" height=25 width=200><span class="style3">P/F: +001 (450) 669-8859</span></td>
</tr><tr>
<td background="Images/body_div_11.jpg" height=25 width=200> </td>
</tr>
</table></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=510 height=386>
<tr>
<td background="Images/body_div_12.jpg" height=25 width=510><div align="right"><span class="style3" style="margin-top0:px;">Subject</span></div></td>
</tr><tr>
<td background="Images/body_div_13.jpg" height=25 width=510><div align="right"><span class="form_div" style="margin-top0:px;">
  <input name="Subject" type="text" class="form m_text" id="Subject" size="77" />
</span></div></td>
</tr><tr>
<td width=510 height=25 background="Images/body_div_14.jpg" class="style3"><div align="right">Message</div></td>
</tr><tr>
<td width=510 height=286 valign="top" background="Images/body_div_15.jpg"><div align="right"><span style="margin-top:0px">
  <textarea name="Message" cols="60" rows="10" class="form m_text" id="Message" style="height:260px; overflow:hidden"></textarea>
</span></div></td>
</tr><tr>
<td width=510 height=25 valign="bottom" background="Images/body_div_16.jpg"><div align="right" class="oneColFixCtr">
  <span style="margin-left:3px; margin-top:3px;"><span class="style7">Please enter the code appearing in the following picture</span><span style="margin-left:3px; margin-top:3px;"> <img src="Captcha.php" alt="captcha image" height="20" /></span></span><span class="_text" style="margin-left:3px; margin-top:3px;"><span class="_text" style="margin-left:3px; margin-top:3px;">
  <input type="text" name="captcha" size="6" maxlength="6">
  </span>
  <input type="submit" value="Submit">
  </span></div></td>
</tr>
</table></td>
<td><img border=0 src="Images/border_right.jpg" height=386 width=20></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_top.jpg" height=47 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=11>
<tr>
<td><img border=0 src="Images/spacer_9.jpg" height=11 width=51></td>
<td><img border=0 src="Images/nav_company.jpg" height=11 width=54></td>
<td><img border=0 src="Images/nav_support.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_links.jpg" height=11 width=34></td>
<td><img border=0 src="Images/nav_upcoming_events.jpg" height=11 width=100></td>
<td><img border=0 src="Images/nav_faq.jpg" height=11 width=26></td>
<td><img border=0 src="Images/nav_our_clients.jpg" height=11 width=65></td>
<td><img border=0 src="Images/nav_pictures.jpg" height=11 width=52></td>
<td><img border=0 src="Images/nav_intranet.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_webmail.jpg" height=11 width=53></td>
<td><img border=0 src="Images/nav_site_map.jpg" height=11 width=56></td>
<td><a href="Terms.html"><img border=0 src="Images/nav_terms_and_conditions.jpg" height=11 width=116></a></td>
<td><img border=0 src="Images/spacer_10.jpg" height=11 width=43></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_bottom.jpg" height=11 width=750></td>
</tr>
</table>
  <!-- end #mainContent --></div>
</div>
 
</body>

Open in new window

0
 
sunithnairCommented:
I had an extra closing braces in my 1st code i pasted may be that might have caused the problem
0
 
etiennedemersAuthor Commented:
Many thanks its exactly what I wanted.
0
 
etiennedemersAuthor Commented:
There was a little mistake in the solution where the valid captcha was not assigned.

see code snippet for final and complete solution.

(basically add line 5 to 8)

Cheers
<?php
// START THE SESSION EVERY TIME
error_reporting(E_ALL);
session_start();
if(isset($_POST["captcha"]) && $_SESSION["captcha"]==$_POST["captcha"])
{
	    require_once("ProcessMail.php");
}
?>
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<head>
<title>Oceanlogics :: Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
    background-color: #006070;
    text-align: center;
	margin: 0;
	padding: 0;
}
.style3 {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        color: #1A6173;
        font-weight: bold;
}
.style4 {font-size: 18px}
.style6 {font-size: 24px}
<?php
if(isset($_POST["captcha"]) && $_SESSION["captcha"]!=$_POST["captcha"])
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: red
}
<?php
}
else
{
?>
.style7 {
        font-family: Georgia, "Times New Roman", Times, serif;
        margin-left: 3px;
        margin-top: 3px;
        font-size: 10px;
        color: #1A6173;
}
<?php
}
?>
 
 
-->
 
</style></head>
 
<body>
 
<div id="mainContent">
    <table border=0 cellspacing=0 cellpadding=0 width=750 height=650>
<tr>
<td><img border=0 src="Images/header_top.jpg" height=147 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=21>
<tr>
<td><img border=0 src="Images/spacer_1.jpg" height=21 width=8></td>
<td><a href="Home.html"><img border=0 src="Images/nav_home.jpg" height=21 width=101 onMouseOver="this.src = 'Images/nav_home_hot.jpg' " onMouseOut="this.src = 'Images/nav_home.jpg' "></a></td>
<td><img border=0 src="Images/spacer_2.jpg" height=21 width=4></td>
<td><img border=0 src="Images/nav_services.jpg" height=21 width=100 onMouseOver="this.src = 'Images/nav_services_hot.jpg' " onMouseOut="this.src = 'Images/nav_services.jpg' "></td>
<td><img border=0 src="Images/spacer_3.jpg" height=21 width=5></td>
<td><img border=0 src="Images/nav_products.jpg" height=21 width=101 onMouseOver="this.src = 'Images/nav_products_hot.jpg' " onMouseOut="this.src = 'Images/nav_products.jpg' "></td>
<td><img border=0 src="Images/spacer_4.jpg" height=21 width=5></td>
<td><img border=0 src="Images/nav_downloads.jpg" height=21 width=100 onMouseOver="this.src = 'Images/nav_downloads_hot.jpg' " onMouseOut="this.src = 'Images/nav_downloads.jpg' "></td>
<td><img border=0 src="Images/spacer_5.jpg" height=21 width=4></td>
<td><a href="phpBB2/index.php"><img border=0 src="Images/nav_forum.jpg" height=21 width=102 onMouseOver="this.src = 'Images/nav_forum_hot.jpg' " onMouseOut="this.src = 'Images/nav_forum.jpg' "></a></td>
<td><img border=0 src="Images/spacer_6.jpg" height=21 width=4></td>
<td><img border=0 src="Images/nav_news.jpg" height=21 width=101 onMouseOver="this.src = 'Images/nav_news_hot.jpg' " onMouseOut="this.src = 'Images/nav_news.jpg' "></td>
<td><img border=0 src="Images/spacer_7.jpg" height=21 width=4></td>
<td><a href="Contact.html"><img border=0 src="Images/nav_contact_us_hot.jpg" height=21 width=102></a></td>
<td><img border=0 src="Images/spacer_8.jpg" height=21 width=9></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/header_bottom.jpg" height=27 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=386>
<tr>
<td><img border=0 src="Images/border_left.jpg" height=386 width=20></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=200 height=386>
<tr>
<td background="Images/body_div_1.jpg" height=25 width=200><div align="left"><span class="style3">Name</span></div></td>
</tr><tr>
<td background="Images/body_div_2.jpg" height=25 width=200><div align="left"><span class="form_div" style="margin-top0:px;">
  <input name="Name" type="text" class="form m_text" id="Name" size="28" />
</span></div></td>
</tr><tr>
<td background="Images/body_div3.jpg" height=25 width=200><div align="left"><span class="style3">Company</span></div></td>
</tr><tr>
<td background="Images/body_div_4.jpg" height=25 width=200><div align="left"><span class="form_div" style="margin-top0:px;">
  <input name="Company" type="text" class="form m_text" id="Company" size="28" />
</span></div></td>
</tr><tr>
<td background="Images/body_div_5.jpg" height=25 width=200><div align="left"><span class="style3">Phone</span></div></td>
</tr><tr>
<td background="Images/body_div_6.jpg" height=25 width=200><div align="left"><span class="form_div" style="margin-top0:px;">
  <input name="Phone" type="text" class="form m_text" id="Phone" size="28" />
</span></div></td>
</tr><tr>
<td background="Images/body_div_7.jpg" height=25 width=200><div align="left"><span class="style3">Email</span></div></td>
</tr><tr>
<td background="Images/body_div_8.jpg" height=25 width=200><div align="left"><span class="form_div" style="margin-top0:px;">
  <input name="Email" type="text" class="form m_text" id="Email" size="28" />
</span></div></td>
</tr><tr>
<td width=200 height=136 valign="bottom" background="Images/body_div_9.jpg"><p align="left" class="style3 style4"><span class="style6">Oceanlogics Inc</span><Br>
  1141 des Trilles<Br>
  Prevost, Quebec<Br>
   Canada J0R 1T0<Br>
</td>
</tr><tr>
<td background="Images/body_div_10.jpg" height=25 width=200><div align="left"><span class="style3">P/F: +001 (450) 669-8859</span></div></td>
</tr><tr>
<td background="Images/body_div_11.jpg" height=25 width=200> </td>
</tr>
</table></td>
<td><table border=0 cellspacing=0 cellpadding=0 width=510 height=386>
<tr>
<td background="Images/body_div_12.jpg" height=25 width=510><div align="right"><span class="style3" style="margin-top0:px;">Subject</span></div></td>
</tr><tr>
<td background="Images/body_div_13.jpg" height=25 width=510><div align="right"><span class="form_div" style="margin-top0:px;">
  <input name="Subject" type="text" class="form m_text" id="Subject" size="77" />
</span></div></td>
</tr><tr>
<td width=510 height=25 background="Images/body_div_14.jpg" class="style3"><div align="right">Message</div></td>
</tr><tr>
<td width=510 height=286 valign="top" background="Images/body_div_15.jpg"><div align="right"><span style="margin-top:0px">
  <textarea name="Message" cols="60" rows="10" class="form m_text" id="Message" style="height:260px; overflow:hidden"></textarea>
</span></div></td>
</tr><tr>
<td width=510 height=25 valign="bottom" background="Images/body_div_16.jpg"><div align="right" class="oneColFixCtr">
  <span style="margin-left:3px; margin-top:3px;"><span class="style7">Please enter the code appearing in the following picture</span><span style="margin-left:3px; margin-top:3px;"> <img src="Captcha.php" alt="captcha image" height="20" /></span></span><span class="_text" style="margin-left:3px; margin-top:3px;"><span class="_text" style="margin-left:3px; margin-top:3px;">
  <input type="text" name="captcha" size="6" maxlength="6">
  </span>
  <input type="submit" value="Submit">
  </span></div></td>
</tr>
</table></td>
<td><img border=0 src="Images/border_right.jpg" height=386 width=20></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_top.jpg" height=47 width=750></td>
</tr><tr>
<td><table border=0 cellspacing=0 cellpadding=0 width=750 height=11>
<tr>
<td><img border=0 src="Images/spacer_9.jpg" height=11 width=51></td>
<td><img border=0 src="Images/nav_company.jpg" height=11 width=54></td>
<td><img border=0 src="Images/nav_support.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_links.jpg" height=11 width=34></td>
<td><img border=0 src="Images/nav_upcoming_events.jpg" height=11 width=100></td>
<td><img border=0 src="Images/nav_faq.jpg" height=11 width=26></td>
<td><img border=0 src="Images/nav_our_clients.jpg" height=11 width=65></td>
<td><img border=0 src="Images/nav_pictures.jpg" height=11 width=52></td>
<td><img border=0 src="Images/nav_intranet.jpg" height=11 width=50></td>
<td><img border=0 src="Images/nav_webmail.jpg" height=11 width=53></td>
<td><img border=0 src="Images/nav_site_map.jpg" height=11 width=56></td>
<td><a href="Terms.html"><img border=0 src="Images/nav_terms_and_conditions.jpg" height=11 width=116></a></td>
<td><img border=0 src="Images/spacer_10.jpg" height=11 width=43></td>
</tr>
</table></td>
</tr><tr>
<td><img border=0 src="Images/footer_bottom.jpg" height=11 width=750></td>
</tr>
</table>
</div>
 
</body>

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 9
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now