-1

this my code : plz solve this problem immediately

<?php session_start();?>
<!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">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GYM jobs</title>
<link href="style/style3.css" rel="stylesheet" type="text/css" />
 <link rel="stylesheet" type="text/css" href="ui.dropdownchecklist.css" />
    
    <script type="text/javascript" src="jquery.js"></script>
    
    <script type="text/javascript" src="jquery-1.3.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$('input[type="text"]').addClass("idleField");
       		$('input[type="text"]').focus(function() {
       			$(this).removeClass("idleField").addClass("focusField");
    		    if (this.value == this.defaultValue){ 
    		    	this.value = '';
				}
				if(this.value != this.defaultValue){
	    			this.select();
	    		}
    		});
    		$('input[type="text"]').blur(function() {
    			$(this).removeClass("focusField").addClass("idleField");
    		    if ($.trim(this.value) == ''){
			    	this.value = (this.defaultValue ? this.defaultValue : '');
				}
    		});
		});			
	</script>
    <script type="text/javascript" language="javascript">
    function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(txtnamefit,"Name of Fitness Center must be filled out!")==false)
  {txtnamefit.focus();return false;}
  
  if (validate_required(txtcontact,"ContactPerson must be filled out!")==false)
  {txtcontact.focus();return false;}
  
  if (validate_required(txtphone,"Phone number must be filled out!")==false)
  {txtphone.focus();return false;}
  
  if (validate_required(email,"Email id must be filled out!")==false)
  {email.focus();return false;}
  
  if (validate_required(captchacode,"Word Verifications must be filled out!")==false)
  {captchacode.focus();return false;}
  }
}
    
    </script>
</head>
<body>
<div class="main">
  <div class="outer">
    <div class="fl" style="width:440px; padding-top:8px;"><a href="index.php"><img src="images/logo.gif" width="431" height="77" border="0" /></a></div>
    <div class="iconsouter"><a href="index.php" class="icon1">Home</a> &nbsp; &nbsp; | &nbsp; &nbsp; <a href="about_us.html" class="icon1">About Us</a> &nbsp; &nbsp; | &nbsp; &nbsp; <a href="vajra_fitness.html" class="icon1">Vajra School of Fitness</a> &nbsp; &nbsp; | &nbsp; &nbsp; <a href="contact_us.html" class="icon1">Contact Us</a></div>
    <br/>
    <br/>
  </div>
  <div class="outer" align="center"><img src="images/lk.gif" width="731" height="140" /><br/>
    <br/>
  </div>
  <div class="boxouter1">
    <div class="resume">
      <form method="post" action="" name="emp" onsubmit="return validate_form(this)" >
        <div class="textboxouter1">
          <div class="reumerinner">
            <table width="90%" border="0" cellspacing="0" cellpadding="0">
              <tr >
                <td width="33%" height="36" class="fontasall brdclr">Name :</td>
                <td width="55%"  class="pl8"><input type="text" id="status" name="txtnamefit"  /></td>
                <td width="12%">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" class="fontasall brdclr">Name of Contact Person : </td>
                <td style="height: 28px"  class="pl8"><input type="text" id="status" name="txtcontact" /></td>
                <td style="height: 28px">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" class="fontasall brdclr">Address and Location :</td>
                <td style="height: 32px"  class="pl8">&nbsp;
                  <input type="text" id="status" name="txtadd" /></td>
                <td style="height: 32px">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" class="fontasall brdclr">Phone No :</td>
                <td style="height: 32px"  class="pl8">&nbsp;
                  <input type="text" id="status" name="txtphone" /></td>
                <td style="height: 32px">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" class="fontasall brdclr">Email id :</td>
                <td  class="pl8">&nbsp;
                  <input type="text" id="status" name="email" /></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td height="36" class="fontasall brdclr">Looking for :</td>
                <td style="height: 32px"  class="pl8">&nbsp;
                  <textarea name="txtlookfor" cols="" rows="" onfocus="this.style.background = 'url(images/2.gif)';" onblur="this.style.background='url(images/1.gif)';" class="textarea1" ></textarea></td>
                <td style="height: 32px">&nbsp;</td>
              </tr>
              <tr>
                <td height="36" class="fontasall brdclr">Other Info :</td>
                <td  class="pl8">&nbsp;
                  <input type="text" id="status" name="txtother" /></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td height="43" class="fontasall brdclr">Word Verifications :</td>
                <td  class="pl8">
	(antispam code, 3 black symbols)<br>
	<table><tr><td><img src="captcha.php" alt="captcha image"></td><td><input type="text" name="captcha" size="3" maxlength="3"></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
            </table>
          </div>
          <div class="textboxouter1">
            <table width="827">
              <tr>
                <td width="630" align="center" style="height: 35px"><input name="submit" type="submit" value="" class="button1" onclick="return validate_form(this)" /></td>
                <td width="185" style="height: 35px">&nbsp;</td>
              </tr>
            </table>
          </div>
        </div>
      </form>
    </div>
  </div>
  <div class="footer">Copyright 2009 <span class="gym">GYM</span> Jobs. All rights reserved.</div>
</div>

</body>
</html>

<?php
if(isset($_POST["captcha"]))
if($_SESSION["captcha"]==$_POST["captcha"])
{
    //CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
	echo 'CAPTHCA is valid; proceed the message';
}
else
{
	echo 'CAPTHCA is not valid; ignore submission';
}
?>

captcha.php

<?php
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); 

function _generateRandom($length=6)
{
	$_rand_src = array(
		array(48,57) //digits
		, array(97,122) //lowercase chars
//		, array(65,90) //uppercase chars
	);
	srand ((double) microtime() * 1000000);
	$random_string = "";
	for($i=0;$i<$length;$i++){
		$i1=rand(0,sizeof($_rand_src)-1);
		$random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
	}
	return $random_string;
}

$im = @imagecreatefromjpeg("captcha.jpg"); 
$rand = _generateRandom(3);
$_SESSION['captcha'] = $rand;
ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));
$rand = _generateRandom(3);
ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0));
Header ('Content-type: image/jpeg');
imagejpeg($im,NULL,100);
ImageDestroy($im);
?>

Edited by nav33n: Wrap your code in [code][/code] tags for easy readability.

Votes + Comments
How difficult is it for you to use [code] tags ?
4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by cwarn23
0

You cannot use session_start() or the header() functions after you've made any output. Try moving all your output below instances of session_start() or header().

0

thank u for replay.. same problem in coming ,, can edit the above the code..

0

Did you make sure that there is no white spacing before the <?php . Also what IDE are you using. Try opening your file in the old fashion windows notepad and delete any invisible white spacing before the < symbol at the beginning of the file. Some IDE's place a binary identification code at the beginning of the file making it impossible to use headers without a secondary editor. If that doesn't work then it's like being between a rock and a hard place. I don't know why so many people experience this glitch even when there is no ascii output before the headers and I would like to hear some of the suggestions too.

Edited by cwarn23: n/a

0

There are two session_starts, line 1, line 174
fix it
there shouldnt really be a session_start in the image generating script, it is supposed to use the session established in the calling file

Edited by almostbob: n/a

1

I assume it is 2 files.

I do too, but the file is simply an image generatior and should be using the session established in the calling file, (shouldnt it??)

0

I do too, but the file is simply an image generatior and should be using the session established in the calling file, (shouldnt it??)

O' I see. As it is sessions are used in both files (the $_SESSION array) but I believe that since the second file is an image there is a chance that the session header is colliding with the image header. So perhaps use hashes/encryption and url variables instead.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.