Jump to content

Recommended Posts

hi before i was having problem with PHP version 4.4.9 with header function that i solved by adding a line "AddType x-mapp-php5 .php" now my problem is this when i click submit i get this error :

 

Warning: Cannot modify header information - headers already sent by (output started at /homepages/21/d295542507/htdocs/includes/registration.php:19) in /homepages/21/d295542507/htdocs/includes/registration.php on line 73

 

and my line 73 is:

 

	  else {header('Location: payments.php');}

 

and this is code between page you can see line 73 where it redirect:

 

<?php 

if(isset($_POST['sub1'])){

$title = $_POST['title'];
$name = $_POST['name'];
$insurance = $_POST['insurance'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['title'];
$registration = $_POST['registration'];
$comments = $_POST['comments'];


$_SESSION['title'] = $_POST['title'];
$_SESSION['name'] = $_POST['name'];
$_SESSION['insurance'] = $_POST['insurance'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['email'] = $_POST['title'];
$_SESSION['registration'] = $_POST['registration'];
$_SESSION['comments'] = $_POST['comments'];

$error = "";

if (!$title)
$error = $error."<font color=\"red\">Title </font><br />";
if (!$name)
$error = $error."<font color=\"red\">Name</font> <br />";
if (!$insurance)
$error = $error."<font color=\"red\">National Insurance Number</font> <br />";
if (!$address)
$error = $error."<font color=\"red\">Address</font> <br />";
if (!$phone)
$error = $error."<font color=\"red\">Telephone Number</font> <br />";
if (!$email)
$error = $error."<font color=\"red\">Email Address</font> <br />";
if (!$error =="")
  echo "<font color=\"red\"><b>Please Fill in The Following Required Fields: </b></font><br /> $error";
  else {header('Location: payments.php');}
}elseif(isset($_POST['sub2'])){

$title = $_POST['title'];
$name = $_POST['name'];
$insurance = $_POST['insurance'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$registration = $_POST['registration'];
$comments = $_POST['comments'];


$_SESSION['title'] = $_POST['title'];
$_SESSION['name'] = $_POST['name'];
$_SESSION['insurance'] = $_POST['insurance'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['email'] = $_POST['title'];
$_SESSION['registration'] = $_POST['registration'];
$_SESSION['comments'] = $_POST['comments'];

$error = "";

if (!$title)
$error = $error. "<font color=\"red\">Title</font> <br />";
if (!$name)
$error = $error. "<font color=\"red\">Name</font> <br />";
if (!$insurance)
$error = $error. "<font color=\"red\">National Insurance Number</font> <br />";
if (!$address)
$error = $error. "<font color=\"red\">Address</font> <br />";
if (!$phone)
$error = $error. "<font color=\"red\">Telephone Number</font> <br />";
if (!$email)
$error = $error. "<font color=\"red\">Email Address</font> <br />";
if (!$error =="")
  echo "<font color=\"red\"><b>Please Fill in The Following Required Fields:</b></font> <br /> $error";
  else {
  header('Location: confirmation.php');}}?>

 

thanks for any help

 

here is my complete code file:

<?php session_start();

$title = "";
$name = "";
$insurance = "";
$address = "";
$phone = "";
$email = "";
$registration = "";
$comments = "";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Your description goes here..." />
<meta name="keywords" content="your,keywords,goes,here" />
<link rel="stylesheet" type="text/css" href="../style.css" title="1024px style" media="screen,projection" />
<title>My title</title>
</head>

<body>
<?php include_once("include_header.php");?>

<h2>CSCS Registration Form</h2>
<br />
<div border="1"><h3>     First Registration 
				     <a href="bulkregistration.php">Bulk Registration Two</a> </h3></div>
<br />Thank you for choosing to book your test with us.


<div id="form" style="margin: 20px 90px 10px 90px;">
<?php 

if(isset($_POST['sub1'])){

$title = $_POST['title'];
$name = $_POST['name'];
$insurance = $_POST['insurance'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['title'];
$registration = $_POST['registration'];
$comments = $_POST['comments'];


$_SESSION['title'] = $_POST['title'];
$_SESSION['name'] = $_POST['name'];
$_SESSION['insurance'] = $_POST['insurance'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['email'] = $_POST['title'];
$_SESSION['registration'] = $_POST['registration'];
$_SESSION['comments'] = $_POST['comments'];

$error = "";

if (!$title)
$error = $error."<font color=\"red\">Title </font><br />";
if (!$name)
$error = $error."<font color=\"red\">Name</font> <br />";
if (!$insurance)
$error = $error."<font color=\"red\">National Insurance Number</font> <br />";
if (!$address)
$error = $error."<font color=\"red\">Address</font> <br />";
if (!$phone)
$error = $error."<font color=\"red\">Telephone Number</font> <br />";
if (!$email)
$error = $error."<font color=\"red\">Email Address</font> <br />";
if (!$error =="")
  echo "<font color=\"red\"><b>Please Fill in The Following Required Fields: </b></font><br /> $error";
  else {header('Location: payments.php');}
}elseif(isset($_POST['sub2'])){

$title = $_POST['title'];
$name = $_POST['name'];
$insurance = $_POST['insurance'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$registration = $_POST['registration'];
$comments = $_POST['comments'];


$_SESSION['title'] = $_POST['title'];
$_SESSION['name'] = $_POST['name'];
$_SESSION['insurance'] = $_POST['insurance'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['email'] = $_POST['title'];
$_SESSION['registration'] = $_POST['registration'];
$_SESSION['comments'] = $_POST['comments'];

$error = "";

if (!$title)
$error = $error. "<font color=\"red\">Title</font> <br />";
if (!$name)
$error = $error. "<font color=\"red\">Name</font> <br />";
if (!$insurance)
$error = $error. "<font color=\"red\">National Insurance Number</font> <br />";
if (!$address)
$error = $error. "<font color=\"red\">Address</font> <br />";
if (!$phone)
$error = $error. "<font color=\"red\">Telephone Number</font> <br />";
if (!$email)
$error = $error. "<font color=\"red\">Email Address</font> <br />";
if (!$error =="")
  echo "<font color=\"red\"><b>Please Fill in The Following Required Fields:</b></font> <br /> $error";
  else {
  header('Location: confirmation.php');}}?>
<br />
<form action="registration.php" method="POST">
<table>
	<tr>
	<td align="right">
	Title:<span style="color:red;">*</span>
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="title" value="<?php echo "$title" ?>">
	</td>
	</tr>
	<tr>
	<td align="right">
	Name:<span style="color:red;">*</span>
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="name" value="<?php echo "$name" ?>">
	</td>
	</tr>
	<tr>
	<td align="right">
	National Insurance<br /> Number:<span style="color:red;">*</span>
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="insurance" value="<?php echo "$insurance" ?>">
	</td>
	</tr>
	<tr>
	<td align="right">
	Address:<span style="color:red;">*</span>
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="address" value="<?php echo "$address" ?>">
	</td>
	</tr>	
	<tr>
	<td align="right">
	Tleephone Number:<span style="color:red;">*</span>
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="phone" value="<?php echo "$phone" ?>">
	</td>
	</tr>
	<tr>
	<td align="right">
	Email:<span style="color:red;">*</span>
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="email" value="<?php echo "$email" ?>">
	</td>
	</tr>
	<tr>
	<td align="right">
	CSCS Registration Number:
	</td>
	<td>
	   <input  style="border:1px solid #4088b8;" type="text" size="29" name="registration" value="<?php echo "$registration" ?>">
	</td>
	</tr>
	<tr>
	<td align="right">
	Special Accommodations:
	</td>
	<td>
	   <textarea  style="border:1px solid #4088b8;" type="textarea" cols="30" rows="5" name="comments">
	   <?php echo "$comments" ?>
	   </textarea>
	</td>
	</tr>
	<tr><td> </td></tr>
	<tr><td> </td>
	<td><input type="submit" name="sub1" value="Payment" />
	<input type="submit" name="sub2" value="More Information"  /></td>
	</tr>
</table>
</form>
</div>

<?php include_once("sidebar.php");?>

<?php include_once("include_footer.php");?>

</div>
</body>
</html>

 

and this is working perfectly on my localhost with PHP 5.3.0

Sadly, a lot of development systems using the xAMP all in one packages are NOT setup properly as development systems where the code you get working on them will work on the majority of actual servers.

 

Your development system has output_buffering turned on in the master php.ini. I recommend that you turn it off (it is off on your live server) so that code you develop on your localhost has a chance of working on your live server.

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.