Jump to content

Warning: session_start() [function.session-start]:


varun7952

Recommended Posts

i m addding feedback form on my site but its showing

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /public_html/2.php:3) in /home/xxxxx/public_html/xxxx/contact.php on line 15

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xxxxx/public_html/xxxx/2.php:3) in /home/xxxxx/public_html/xxxx/contact.php on line 15

 

Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /home/xxxxx/public_html/xxxx/contact.php on line 16

 

i m not advance user of php but still i cant find ne correction in this please help me

here is my files

 

CONTACT.PHP

<?php

include 'config.php';

error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;

//Start a session if one isn't already started
if(!session_id()){
    session_start();
    session_regenerate_id();
}
if(!$post)
{
    // Only generate when user not POST'ing data
    $_SESSION['first'] = rand(1,10); $_SESSION['second'] = rand(1,10); //generate two random numbers for math validation
    $_SESSION['result'] = $_SESSION['first'] + $_SESSION['second']; // add the two together
}

if($post)
{
include 'functions.php';

$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);
$human = stripslashes($_POST['human']);
$error = '';

// Check name

if(!$name)
{
	$error .= 'Please enter your name.<br />';
}

// Check email

if(!$email)
{
	$error .= 'Please enter an e-mail address.<br />';
}

if($email && !ValidateEmail($email))
{
	$error .= 'Please enter a valid e-mail address.<br />';
}

// Check message (length)

if(!$message || strlen($message) < 15)
{
	$error .= "Please enter your message. It should have at least 15 characters.<br />";
}

// Check for human with math validation

if($human != $_SESSION['result']) // check to see if they match
{
	$error .= "Please validate that you are human.<br />";
}
if(!$error) // send email
{
	$mail = mail(WEBMASTER_EMAIL, $subject, $message,
		 'From: '.$name.' <'.$email.'>\r\n'
		.'Reply-To: '.$email.'\r\n'
		.'X-Mailer: PHP/' . phpversion());

	if($mail)
	{
		echo 'OK';
	}

}
else
{
	echo '<div class="notification_error">'.$error.'</div>'; // set up error div for jQuery/Ajax
}

}

?>

 

 

 

Link to comment
Share on other sites

thanks u for your reply but problem is i can't figure out where is my problem is so please help me :(

Well, the answer to your problem is in the link. What is in that link is what your problem is. Also the error message says it too.

 

It means something has already been sent to the webbrowser, like some HTML (and with that some header data). ;)

 

Also, in the code you posted, this is line 15:

// Only generate when user not POST'ing data

And that would not generate such an error message...

 

What happens in the config.php file?

 

check the html source of the page you get the error on, is there any text before the errors?

Link to comment
Share on other sites

thats the config php file

 


<?php
// Set your email address here
define("WEBMASTER_EMAIL", 'youremail@yourdomain.com');
?>

 

thats the main core file

 

<!-- JQuery -->

<script type="text/javascript" src="xxxx/xxxx/jquery-1.3.2.min.js"></script>

<script type="text/javascript" src="xxxx/xxxxx/slide.js"></script>

<script type="text/javascript" src="xxxx/xxxxx/validation.js"></script>

<link rel="stylesheet" type="text/css" href="xxxx/css/contactpanel.css" />

<?php include('xxxx/xxxx/contact.php'); ?>

<!--Color options are: scBlue, scGray, scLight, scDark, scBlack

You may also include "scTrans" to make the panel slightly transparent

-->

<div id="scTopPanel" class="scBlue scTrans"> <!--start scTopPanel-->

<!--[if IE]>

<div id="ie">

<![endif]-->

<div id="slidingContactPanel"><!--start slidingContactPanel-->

 

<div class="column"><!--start column 1-->

 

 

<div id="note"></div> <!--notification area used by jQuery/Ajax -->

 

<div id="fields"><!--start fields-->

<!--the contact form fields-->

<form id="sliding-contact-forms">

 

<!-- labels can be customized to whatever you like -->

<label>Name</label><input class="textbox" type="text" name="name" value=""><br />

 

<label>E-Mail</label><input class="textbox" type="text" name="email" value=""><br />

 

<label>Subject</label><input class="textbox" type="text" name="subject" value=""><br />

 

<label>Comments</label><textarea class="textbox"name="message" rows="5" cols="25"></textarea><br />

 

<label>Human?</label><input class="math" type="text" name="human" value="">

 

<?php echo $_SESSION['first'] . " + " . $_SESSION['second']; ?>

 

<label> </label><input class="submit" type="submit" name="submit" value="Submit">

 

</form>

</div><!--end fields-->

 

</fieldset>

</div><!--end column 1-->

 

<div class="column"><!--start column 2-->

<!--the social media icons-->

 

 

 

</div><!--end column 2-->

 

</div><!--end slidingContactPanel-->

<!--the tab-->

<div class="scWrapper"><!--start scWrapper-->

<div class="scTab">

<ul class="scButton">

<li id="scToggle">

<a id="scOpen" class="scOpen" href="#">Feedback</a>

<a id="scClose" style="display: none;" class="scClose" href="#">Close</a>

</li>

</ul>

</div> <!--end scTab -->

 

</div> <!--end scWrapper-->

<!--[if IE]>

</div>

<![endif]-->

</div><!--end scTopPanel-->

</body>

</html>

 

Link to comment
Share on other sites

thats the config php file

 


<?php
// Set your email address here
define("WEBMASTER_EMAIL", 'youremail@yourdomain.com');
?>

 

Did you read the link? Because if that's really the contents of your file, it's quite obvious where the problem is. Whitespace before <?php.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.