I created a contact us script...

Discussion in 'PHP' started by anthonyr, Sep 15, 2008.

  1. #1
    Well i created a contact us script and added a captcha script to it... but unfortunately, It all went wrong:S:S:S For verifying if the code entered is similar to the one in the captcha image, the script used sessions:S However, each time i try it out i get this error:


    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\xampp\htdocs\WarZone\contact.php:12) in D:\xampp\htdocs\WarZone\captcha\captcha\captchac_lib.php on line 9


    here is the whole code:


    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Warzone - Welcome to Wazone Paintball Arena.</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="header">
    	<div id="logo">
    		<h1><a href="index.html">WarZone</a></h1>
    		<h2><a href="http://www.freecsstemplates.org/">It's not a game...<br />It's a war.</a></h2>
    		</div><a name="top"></a>
    	<div id="menu">
    		<ul>
    			<li class="first"><a href="index.php" title="Home">Home</a></li>
    			<li><a href="about.php" title="About">About</a></li>
    			<li><a href="games.php" title="">Games</a></li>
    			<li><a href="packages_prices.php" title="">Packages/Prices</a></li>
    			<li><a href="contact.php" title="">Contact</a></li>
    		</ul>
    	</div>
    </div>
    <!-- end #header -->
    <div id="page">
    	<div id="content">
    		<div class="boxed">
    			<h2>Contact us!</h2>
    			<div class="content">
    				<p><form method='post' action='contact.php'><table width='457' border='0'>
      <tr>
        <td width='184'><strong>Full Name:</strong></td>
        <td width='263'><input type='text' name='name' value="<? echo $_POST['name'] ?>"/></td>
      </tr>
      <tr>
        <td><strong>e-mail:</strong></td>
        <td><input type='text' name='email' value="<? echo $_POST['email'] ?>"/></td>
      </tr>
      <tr><td>Choose:</td>
      <td><select name="degree">
      <Option name="choice" value="1">Webmaster</option>
      <option name="choice" value="2">Information</option>
      <option name="choice" value="3">Feedback</option>
      <option name="choice" value="4">Comment</option>
      </select></td>
      </tr>
      <tr>
        <td><strong>Subject:</strong></td>
        <td><input type='text' name='subject' value="<? echo $_POST['subject'] ?>"/></td>
      </tr>
      <tr>
        <td><strong>Your Message:</strong></td>
        <td><textarea name='message' value="<? echo $_POST['message'] ?>"></textarea></td>
      </tr>
      <tr>
        <td><strong>Image Validator:</strong></td>
        <td><table cellpadding=5 cellspacing=0 bgcolor="#E4F8E4">
    <tr>
    <td style="padding: 2px;" width="40em"><img src="captcha/captcha/captchac_code.php" id="captcha"><br><font color="#000000">Please enter the text from the image</font> &nbsp; </td></tr><tr>
    <td valign="top"><br><input type="text" name="Turing" value="" maxlength="100" size="10"><br>
    [ <a href="#" onclick=" document.getElementById('captcha').src = document.getElementById('captcha').src + '?' + (new Date()).getMilliseconds()">Refresh Image</a> ] [ <a href="captcha/captcha/captcha/whatisturing.html" onClick="window.open('captcha/captcha/whatisturing.html','_blank','width=400, height=300, left=' + (screen.width-450) + ', top=100');return false;">What's This?</a> ]
    </td>
    </tr>
    </table></td>
      </tr>
    
    
    
    </table><font color="#FF0000">
    HTML:
    <?php
    	include('captcha/captcha/captchac_lib.php');
    	$Turing_code = $_REQUEST["Turing"];
    	if ( CheckCaptcha($Turing_code) !=1 )
        {
            echo "<b><font color=red>The Captcha Code you entered is invalid. Please press the Back button of your browser and try again</font></b><br>";
    	return 1;
        }
    
    ?>
    
    
    <?
    
    
    
    if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject=$_POST['subject'];
    $message = $_POST['message'];
    if (empty($name) ) {echo "Please Type Your Name";}
    elseif(empty($email)) {echo"Please Type Your Email";}
    elseif(!preg_match("/^.+?@.+?\..+?/i" , $email)){echo"Please Type a Valid Email";}
    elseif(empty($subject)) {echo"Please Type the Subject";}
    elseif(empty($message)) {echo"Please Type Your Message";}
    elseif($_POST['choice']== 1){ $send=mail("webmaster@rz-group.com", $subject , $message, "FROM:" .$email);}
    elseif($_POST['choice']== 2){$send2=mail("info@rz-group.com", $subject , $message, "FROM:" .$email);}
    elseif($_POST['choice'] == 3){$send3=mail("feedback@rz-group.com" , $subject , $message, "FROM:" .$email);}
    elseif($_POST['choice'] == 4){$send4=mail("comment@rz-group.com" , $subject , $message, "FROM:" .$email);}
    
    elseif(!$send1 || !$send2 || !$send3 || !$send4){echo"Message Was Not Send... Try Again At a Later Time.";}
    else{echo"Message Sent Successfully";}}
    
    ?>
    
    PHP:
    </font>  <br>
    <input type="submit" name="submit" />
    </form> </p>
    		  </div>
    	  </div>
    		
    	</div>
    	<!-- end #content -->
    	<div id="sidebar">
    		<ul>
    			<li>
    				<h2>News &amp; Events</h2>
                    
    				<dl>
                    <dt><?PHP include('news.php') ; ?></dt>
    				</dl>
    			</li>
    	  <li>
    				<h2>Voting Poll</h2>
    				Here I'll put a voting poll...
    		  
    		  </li>
    			
    		</ul>
    	</div>
    	<!-- end #sidebar -->
    	<div style="clear: both;">&nbsp;</div>
    </div>
    <!-- end #page -->
    <div id="footer">
    	<p id="legal">Copyright &copy; 2008 WarZone. All Rights Reserved. Designed by <a href="mailto:anthony.riachy@gmail.com">Anthony Riachy</a>.</p>
    	<p id="links"><a href="#top">Top</a> | <a href="http://www.facebook.com/group.php?gid=14866987869">Facebook Group</a></p>
    </div>
    </body>
    </html>
    HTML:
     
    anthonyr, Sep 15, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    session_start() ;)
     
    EricBruggema, Sep 15, 2008 IP
  3. anthonyr

    anthonyr Peon

    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    didnt really understand:S:S
     
    anthonyr, Sep 15, 2008 IP