Page 1 of 1
Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 12:38 pm
by sazzadraju
guys i m new in this forum..i m a beginner in php programming...i hv got a problem..
Any one can tell me what the reason of this warning and how to fix it up...
Warning: Cannot modify header information - headers already sent by (output started at /home/ataulhab/public_html/tracking/update.php:3) in /home/ataulhab/public_html/tracking/update.php on line 31
here is the code
<?php include("dbconnection.php");?>
<?php
$update=mysql_query("UPDATE tracking SET origin='$_POST[origin]', pickup_date='$_POST[pickup_date]', shipper='$_POST[shipper]', consignee='$_POST[consignee]', quantity='$_POST[quantity]', commodity='$_POST[commodity]', weight='$_POST[weight]', flight_details='$_POST[flight_details]', present_status='$_POST[present_status]', received_by='$_POST[received_by]', received_on='$_POST[received_on]', received_at='$_POST[received_at]', remarks='$_POST[remarks]' WHERE hawb_no='$_POST[hawb_no]'");
if($update)
{
header ('Location:order_list.php');
}
?>
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 12:40 pm
by flying_circus
sazzadraju wrote:guys i m new in this forum..i m a beginner in php programming...i hv got a problem..
Any one can tell me what the reason of this warning and how to fix it up...
Warning: Cannot modify header information - headers already sent by (output started at /home/ataulhab/public_html/tracking/update.php:3) in /home/ataulhab/public_html/tracking/update.php on line 31
You'll have to post the code, but I'd be willing to bet that whatever is on line 31 is trying to send a header, but you've already started output at line 3.
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 12:50 pm
by sazzadraju
flying_circus wrote:sazzadraju wrote:guys i m new in this forum..i m a beginner in php programming...i hv got a problem..
Any one can tell me what the reason of this warning and how to fix it up...
Warning: Cannot modify header information - headers already sent by (output started at /home/ataulhab/public_html/tracking/update.php:3) in /home/ataulhab/public_html/tracking/update.php on line 31
You'll have to post the code, but I'd be willing to bet that whatever is on line 31 is trying to send a header, but you've already started output at line 3.
here is the code
<?php include("dbconnection.php");?>
<?php
$update=mysql_query("UPDATE tracking SET origin='$_POST[origin]', pickup_date='$_POST[pickup_date]', shipper='$_POST[shipper]', consignee='$_POST[consignee]', quantity='$_POST[quantity]', commodity='$_POST[commodity]', weight='$_POST[weight]', flight_details='$_POST[flight_details]', present_status='$_POST[present_status]', received_by='$_POST[received_by]', received_on='$_POST[received_on]', received_at='$_POST[received_at]', remarks='$_POST[remarks]' WHERE hawb_no='$_POST[hawb_no]'");
if($update)
{
header ('Location:order_list.php');
}
?>
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 1:02 pm
by flying_circus
I see all kinds of whitespace (output) in your script.
sazzadraju wrote:Code: Select all
<?php include("dbconnection.php");?>
<?php
$update=mysql_query("UPDATE tracking SET origin='$_POST[origin]', pickup_date='$_POST[pickup_date]', shipper='$_POST[shipper]', consignee='$_POST[consignee]', quantity='$_POST[quantity]', commodity='$_POST[commodity]', weight='$_POST[weight]', flight_details='$_POST[flight_details]', present_status='$_POST[present_status]', received_by='$_POST[received_by]', received_on='$_POST[received_on]', received_at='$_POST[received_at]', remarks='$_POST[remarks]' WHERE hawb_no='$_POST[hawb_no]'");
if($update)
{
header ('Location:order_list.php');
}
?>
Try something like:
Code: Select all
<?php
# Includes
include_once("dbconnection.php");
# Query
$update = mysql_query("UPDATE tracking SET origin='$_POST[origin]', pickup_date='$_POST[pickup_date]', shipper='$_POST[shipper]', consignee='$_POST[consignee]', quantity='$_POST[quantity]', commodity='$_POST[commodity]', weight='$_POST[weight]', flight_details='$_POST[flight_details]', present_status='$_POST[present_status]', received_by='$_POST[received_by]', received_on='$_POST[received_on]', received_at='$_POST[received_at]', remarks='$_POST[remarks]' WHERE hawb_no='$_POST[hawb_no]'");
# Check Success
if($update) {
header ('Location:order_list.php');
exit();
}
?>
Your script is also vulnerable to SQL Injection.
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 1:36 pm
by sazzadraju
NOt worked yet!!
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 1:39 pm
by Sephern
Whats the code in dbconnection.php?
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 1:42 pm
by flying_circus
sazzadraju wrote:NOt worked yet!!
Yeah? And what does dbconnection.php look like? Any whitespace in there?
Alternatively, you can use output buffering.
Code: Select all
<?php
# Begin Output Buffering
ob_start();
# Includes
include_once("dbconnection.php");
# Query
$update = mysql_query("UPDATE tracking SET origin='$_POST[origin]', pickup_date='$_POST[pickup_date]', shipper='$_POST[shipper]', consignee='$_POST[consignee]', quantity='$_POST[quantity]', commodity='$_POST[commodity]', weight='$_POST[weight]', flight_details='$_POST[flight_details]', present_status='$_POST[present_status]', received_by='$_POST[received_by]', received_on='$_POST[received_on]', received_at='$_POST[received_at]', remarks='$_POST[remarks]' WHERE hawb_no='$_POST[hawb_no]'");
# Check Success
if($update) {
header ('Location:order_list.php');
exit();
}
?>
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 2:35 pm
by sazzadraju
dbconnection.php is allright bcoz i used it other pages and it works...
i used header ('Location:order_list.php'); another pages...all of them is not working..
only this one given below is working...
<?php
include ('dbconnection.php');
?>
<?php
$hawb_no = $_POST['hawb_no'];
$query = mysql_query ("SELECT * FROM tracking WHERE hawb_no = '$hawb_no' ");
if (mysql_num_rows ($query) > 0 )
{
echo "This HAWB NO is already exist";
}
else
{
$query2 = "INSERT INTO tracking (hawb_no, origin, pickup_date, shipper, consignee, quantity, commodity, weight, flight_details, present_status, received_by, received_on, received_at, remarks) VALUES ('$hawb_no', '$_POST[origin]', '$_POST[pickup_date]', '$_POST[shipper]', '$_POST[consignee]', '$_POST[quantity]', '$_POST[commodity]', '$_POST[weight]', '$_POST[flight_details]', '$_POST[present_status]', '$_POST[received_by]', '$_POST[received_on]', '$_POST[received_at]' ,'$_POST[remarks]' )";
$do =mysql_query($query2);
header ('Location:order_list.php');
}
?>
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 2:53 pm
by sazzadraju
ohk i've found the solution using java script...thanks for information and your help
print "<script>";
print " self.location='mynewpage.html';";
print "</script>";
Re: Prblem Help Please (PHP)
Posted: Mon Mar 15, 2010 2:56 pm
by flying_circus
What if the user has disabled javascript?
Re: Prblem Help Please (PHP)
Posted: Tue Mar 16, 2010 8:51 am
by sazzadraju