PHP - Header Already Declared
Gooday Coders. Im using php 5.4 with xampp 1.8. Each time I run this script "add+stock.php", the script jumps to line 240 saying header is already defined. Thus referring to the session headers. What can I do to get rid of these header errors?
add_stock.php
<?php include_once("init.php"); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>NIC - Add Stock Category</title> <!-- Stylesheets --> <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet'> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="js/date_pic/date_input.css"> <link rel="stylesheet" href="lib/auto/css/jquery.autocomplete.css"> <!-- Optimize for mobile devices --> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <!-- jQuery & JS files --> <?php include_once("tpl/common_js.php"); ?> <script src="js/script.js"></script> <script src="js/date_pic/jquery.date_input.js"></script> <script src="lib/auto/js/jquery.autocomplete.js "></script> <script> /*$.validator.setDefaults({ submitHandler: function() { alert("submitted!"); } });*/ $(document).ready(function() { $("#supplier").autocomplete("supplier1.php", { width: 160, autoFill: true, selectFirst: true }); $("#category").autocomplete("category.php", { width: 160, autoFill: true, selectFirst: true }); // validate signup form on keyup and submit $("#form1").validate({ rules: { name: { required: true, minlength: 3, maxlength: 200 }, stockid: { required: true, minlength: 3, maxlength: 200 }, cost: { required: true, }, sell: { required: true, } }, messages: { name: { required: "Please Enter Stock Name", minlength: "Category Name must consist of at least 3 characters" }, stockid: { required: "Please Enter Stock ID", minlength: "Category Name must consist of at least 3 characters" }, sell: { required: "Please Enter Selling Price", minlength: "Category Name must consist of at least 3 characters" }, cost: { required: "Please Enter Cost Price", minlength: "Category Name must consist of at least 3 characters" } } }); }); function numbersonly(e){ var unicode=e.charCode? e.charCode : e.keyCode if (unicode!=8 && unicode!=46 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=9){ //if the key isn't the backspace key (which we should allow) if (unicode<48||unicode>57) return false } } </script> </script> </head> <body> <!-- TOP BAR --> <?php include_once("tpl/top_bar.php"); ?> <!-- end top-bar --> <!-- HEADER --> <div id="header-with-tabs"> <div class="page-full-width cf"> <ul id="tabs" class="fl"> <li><a href="dashboard.php" class="dashboard-tab">Dashboard</a></li> <li><a href="view_sales.php" class="sales-tab">Sales</a></li> <li><a href="view_customers.php" class=" customers-tab">Customers</a></li> <li><a href="view_purchase.php" class="purchase-tab">Purchase</a></li> <li><a href="view_supplier.php" class=" supplier-tab">Supplier</a></li> <li><a href="view_product.php" class="active-tab stock-tab">Stocks / Products</a></li> <li><a href="view_payments.php" class="payment-tab">Payments / Outstandings</a></li> <li><a href="view_report.php" class="report-tab">Reports</a></li> </ul> <!-- end tabs --> <!-- Change this image to your own company's logo --> <!-- The logo will automatically be resized to 30px height. --> <a href="#" id="company-branding-small" class="fr"><img src="<?php if(isset($_SESSION['logo'])) { echo "upload/".$_SESSION['logo'];}else{ echo "upload/NIC.png"; } ?>" alt="Point of Sale" /></a> </div> <!-- end full-width --> </div> <!-- end header --> <!-- MAIN CONTENT --> <div id="content"> <div class="page-full-width cf"> <div class="side-menu fl"> <h3>Stock Management</h3> <ul> <li><a href="add_stock.php">Add Stock/Product</a></li> <li><a href="view_product.php">View Stock/Product</a></li> <li><a href="add_category.php">Add Stock Category</a></li> <li><a href="view_category.php">view Stock Category</a></li> <li><a href="view_stock_availability.php">view Stock Available</a></li> </ul> </div> <!-- end side-menu --> <div class="side-content fr"> <div class="content-module"> <div class="content-module-heading cf"> <h3 class="fl">Add Stock </h3> <span class="fr expand-collapse-text">Click to collapse</span> <div style="margin-top: 15px;margin-left: 150px"></div> <span class="fr expand-collapse-text initial-expand">Click to expand</span> </div> <!-- end content-module-heading --> <div class="content-module-main cf"> <?php //Gump is libarary for Validatoin if(isset($_POST['name'])){ $_POST = $gump->sanitize($_POST); $gump->validation_rules(array( 'name' => 'required|max_len,100|min_len,3', 'stockid' => 'required|max_len,200', 'sell' => 'required|max_len,200', 'cost' => 'required|max_len,200', 'supplier' => 'max_len,200', 'category' => 'max_len,200' )); $gump->filter_rules(array( 'name' => 'trim|sanitize_string|mysql_escape', 'stockid' => 'trim|sanitize_string|mysql_escape', 'sell' => 'trim|sanitize_string|mysql_escape', 'cost' => 'trim|sanitize_string|mysql_escape', 'category' => 'trim|sanitize_string|mysql_escape', 'supplier' => 'trim|sanitize_string|mysql_escape' )); $validated_data = $gump->run($_POST); $name = ""; $stockid = ""; $sell = ""; $cost = ""; $supplier = ""; $category = ""; if($validated_data === false) { echo $gump->get_readable_errors(true); } else { $name=mysql_real_escape_string($_POST['name']); $stockid=mysql_real_escape_string($_POST['stockid']); $sell=mysql_real_escape_string($_POST['sell']); $cost=mysql_real_escape_string($_POST['cost']); $supplier=mysql_real_escape_string($_POST['supplier']); $category=mysql_real_escape_string($_POST['category']); $count = $db->countOf("stock_details", "stock_name ='$name'"); if($count>1) { $data='Dublicat Entry. Please Verify'; $msg='<p style=color:red;font-family:gfont-family:Georgia, Times New Roman, Times, serif>'.$data.'</p>';// ?> <script src="dist/js/jquery.ui.draggable.js"></script> <script src="dist/js/jquery.alerts.js"></script> <script src="dist/js/jquery.js"></script> <link rel="stylesheet" href="dist/js/jquery.alerts.css" > <script type="text/javascript"> jAlert('<?php echo $msg; ?>', 'NIC'); </script> <?php } else { if($db->query("insert into stock_details(stock_id,stock_name,stock_quatity,supplier_id,company_price,selling_price,category) values('$stockid','$name',0,'$supplier',$cost,$sell,'$category')")) { $db->query("insert into stock_avail(name,quantity) values('$name',0)"); $msg=" $name Stock Details Added" ; header("Location: add_stock.php?msg=$msg"); }else echo "<br><font color=red size=+1 >Problem in Adding !</font>" ; } } } if(isset($_GET['msg'])){ $data=$_GET['msg']; $msg='<p style=color:#153450;font-family:gfont-family:Georgia, Times New Roman, Times, serif>'.$data.'</p>';// ?> <script src="dist/js/jquery.ui.draggable.js"></script> <script src="dist/js/jquery.alerts.js"></script> <script src="dist/js/jquery.js"></script> <link rel="stylesheet" href="dist/js/jquery.alerts.css" > <script type="text/javascript"> jAlert('<?php echo $msg; ?>', 'NIC'); </script> <?php } ?> <form name="form1" method="post" id="form1" action=""> <table class="form" border="0" cellspacing="0" cellpadding="0"> <tr> <?php $max = $db->maxOfAll("id", "stock_details"); $max=$max+1; $autoid="SD".$max.""; ?> <td><span class="man">*</span>Stock ID:</td> <td><input name="stockid" type="text" id="stockid" readonly maxlength="200" class="round default-width-input" value="<?php echo $autoid; ?>" /></td> <td><span class="man">*</span>Name:</td> <td><input name="name"placeholder="ENTER CATEGORY NAME" type="text" id="name" maxlength="200" class="round default-width-input" value="<?php echo $name; ?>" /></td> </tr> <tr> <td><span class="man">*</span>Cost:</td> <td><input name="cost" placeholder="ENTER COST PRICE" type="text" id="cost" maxlength="200" class="round default-width-input" onkeypress="return numbersonly(event)" value="<?php echo $cost; ?>" /></td> <td><span class="man">*</span>Sell:</td> <td><input name="sell" placeholder="ENTER SELLING PRICE" type="text" id="sell" maxlength="200" class="round default-width-input" onkeypress="return numbersonly(event)" value="<?php echo $sell; ?>" /></td> </tr> <tr> <td>Supplier:</td> <td><input name="supplier" placeholder="ENTER SUPPLIER NAME" type="text" id="supplier" maxlength="200" class="round default-width-input" value="<?php echo $supplier; ?>" /></td> <td>Category:</td> <td><input name="category" placeholder="ENTER CATEGORY NAME" type="text" id="category" maxlength="200" class="round default-width-input" value="<?php echo $category; ?>" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <input class="button round blue image-right ic-add text-upper" type="submit" name="Submit" value="Add"> (Control + S) <td align="right"><input class="button round red text-upper" type="reset" name="Reset" value="Reset"> </td> </tr> </table> </form> </div> <!-- end content-module-main --> </div> <!-- end content-module --> </div> <!-- end full-width --> </div> <!-- end content --> <!-- FOOTER --> <div id="footer"> <p>Any Queries email to <a href="mailto:sridhar.NIC@gmail.com?subject=Stock%20Management%20System">sridhar.NIC@gmail.com</a>.</p> </div> <!-- end footer --> </body> </html> Similar TutorialsHi, Basically I am going to give a short description to my problem with pseduo and comments (-->), there is too much to paste all my code he basically include(config.php) --> database connection include(global.php) --> class is instantiated here as $p ($p is GLOBAL) --> I print_r the $p value here, and it shows (debugging) switch() case x: include file.php; break; --> but when I try to access it or print_r it here (here being within the file.php), via the file that has been included above "include file.php", it does not see it. I have to re-declare the $p variable with the class, within the included file. any tips as how to solve this please; I dont see why it wouldnt see it, since all the file is that I am including is an HTML file with a few PHP lines, which checks if a user has permission: if(!$p->check()) redirect("index.php"); I don't understand why "if(isSet($_GET['sid'])) " works before it is declared in the variable name(" $name = $_GET['sid'];"). 1. How does php store the date in this get statement? 2. Is GET an array? Code: [Select] if(isSet($_GET['sid'])) { echo "<h2>Exercise</h2>"; $name = $_GET['sid']; $timein = time(); $quest=1; $nextquest=2; } else { echo "<h2>Enter Student Number:</h2>"; $quest=0; $nextquest=0; } Dear all, I am new to the forums, with a hope that somebody can point me in the right direction. I am coding a new photo website, and am doing it with PHP to maximize my flexibility. In essence I want to have a set of gallery folder on the server, and the site reads off these folders and automatically generates the required galleries. My PHP code is below, along with a detail of the exact problem: <?php $main = "Collections/"; # Location of galleries $big = "Large/"; # Location of big versions (subdir within each gallery) $i = 0; #Gallery Iterator #Searching for galleries & Checking only for directories (save them im $galleries array) $tempgalleries = scandir($main); foreach ($tempgalleries as $gallery_iterate) { if (!is_dir($gallery_iterate)) { $galleries[]=$gallery_iterate; } } #Iterating galleries. Collecting each gallery's images (saving in $GalleryImages.$i). This creates an image array for each $galleries[$i] for($i=0; $i<=sizeof($galleries)-1; $i++) { #Making the title nice (from the the directory names) $GalleryTitles[$i] = str_replace('_',' ', $galleries[$i]);; $temp_gallery = opendir($main.$galleries[$i]); #Checking for Images and storing in array if valid while (false !== ($image = readdir($temp_gallery))) { if ($image != "." && $image != ".." && $image != rtrim($big,"/") && strstr($image,'.jpg')) { ${$GalleryImages_.$i}[] = $image; } } #Sorting the images numerically natsort(${$GalleryImages_.$i}); closedir($temp_gallery); } #Better location for the buttons!! #Printing the galleries and all the html required for naming, separation, etc.. This is also an iteration for($i=0; $i<=sizeof($galleries)-1; $i++) { echo('<div class="galleries_hidden" id="gallery_'.$i.'"><hr><br><div class="Gallery_Title"><b><i><big>'.$GalleryTitles[$i].'</big></i></b></div><br>'); $folder=$galleries[$i]; foreach(${$GalleryImages_.$i} as $thumb_image) { echo '<a href="'.$main . $folder .'/'. $big . 'large_'. $thumb_image . '" rel="lightbox['.$folder.']" title="'.$folder.'"><img src="' . $main . $folder .'/'. $thumb_image. '" alt="'.$folder.'" class="Gallery_Image" /></a>'; } echo('</div>'); } #Making the buttons to cycle the galleries for($i=0; $i<sizeof($galleries); $i++) { echo('<input type="button" id="gallery_'.$i.'" value="Show '.$GalleryTitles[$i].'" onclick="showgallery(');echo("'gallery_".$i."');");echo('" /><br><br>'); } ?> I have managed to make each aspect work, exept one. The last portion, as commented: #Making the buttons to cycle the galleries for($i=0; $i<sizeof($galleries); $i++) { echo('<input type="button" id="gallery_'.$i.'" value="Show '.$GalleryTitles[$i].'" onclick="showgallery(');echo("'gallery_".$i."');");echo('" /><br><br>'); } This piece of code generates buttons which shows one gallery, and hides the rest. This is done by changing the classes of the divs from "galleries_visible" to "galleries_hidden", as applicable. This is done using a javascript declared in the header as follows: Code: [Select] <script type="text/javascript"> function showgallery(id) { var divall = document.getElementsByTagName("div"); var i=0; for (i=0;i<divall.length;i++) { if(divall[i].className == "galleries_visible") { divall[i].className = "galleries_hidden"; } var showdiv = document.getElementById(id); showdiv.className = "galleries_visible"; return false; } </script> When I have the button-generating php code below the gallery-generating php code, then the javascript seems to work, by showing and hiding respective galleries. These galleries and their litebox viewer all work normally. However, when putting the button-creator php above the gallery-generator php, then the buttons appear as normal, and the javascript runs, but it cannot find the div with the id it searches for: Code: [Select] var showdiv = document.getElementById(id); showdiv.className = "galleries_visible"; I am confused. The PHP code makes several arrays which stores all the file and folder information, and these arrays are read by the button-generator irrespective of its position (I know this because the buttons are generated based on the content of non-empty arrays). Why can't the javascript change the gallery-containing divs when they are below the button-containing div? Any help is greatly appreciated, I just cant seem to find whats wrong! Kind regards, Frederik Hi all, I have this structure of two functions: function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } function normaliza($text){ function entre($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } foreach (count_chars($text, 1) as $i => $val) { if(chr($i)=='<'){ $totaltag = $val; } } for($u=0; $u <= $totaltag; $u++){ $parsed = entre($text, "<", ">"); $text = str_replace('<'.$parsed.'>',"",$text); } return $text; } The I passed a text named $data throught both functions and I got the correct return: $status = get_string_between($data, 'Inativo', 'CNPJ'); $status = normaliza($status); echo $status.' '; Just after, I passed the same folowing text throught the same both functions: $cnpj = get_string_between($data, 'CNPJ', 'Grau'); $cnpj = normaliza($status); echo $cnpj.' '; And I got this error: Cannot redeclare entre() (previously declared in C:\Users\entidade.php:47) in C:\Users\entidade.php on line 47 Why? I thougth this kind strange because it didin't gave the same error for the function get_string_between. Thanks danilo jr. I'm receiving a cannot redeclare function error. I have a functions.php pack that I only require_once once. require_once 'functions.php'; require_once 'classes.php'; A little further into the code I conditionally require another php file. require_once 'dataentry.php'; It appears that when the require_once 'dataentry.php' line is hit, I receive this redeclare error. I do not call any include or require in dataentry.php. The first function in my function pack throws this error, and when I comment it out, the next function throws the error. Im appalled as to the reasoning for this error. Any Thoughts? Newb here trying to build a form that works with ints to count how many red shirts die in a classic episode of star trek (exercise to get better with forms and ints). I have an error which reads as '7 Error message: Undefined index: rsTot'. I have tried a few things and read that setting it(casting it?) as a float was the safest way to work with the int, however each thing i've attempted results in some sort of error so after a day of reading and trying i'm very confused and hoping for an answer I can understand here.
I have read through stackOverflow for an answer but not seen one which i can understand and apply that speaks to the problem i'm having of initially entering and process a number as an int which i can later do some math on.
error can be seen he http://zephir.seattlecentral.edu/~jstein11/itc250/z14/w03c0102_OOPform/w03c0102_OOPform.php
<?php //w03c0102_OOPform require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials //END CONFIG AREA ---------------------------------------------------------- $rsTot = (float)$_POST['rsTot'];// float more forgiving int $rsSurvived = (float)$_POST['rsSurvived']; $rsSum = $rsTot - $rsSurvived; $rsRatio = 0; # Read the value of 'action' whether it is passed via $_POST or $_GET with $_REQUEST if(isset($_REQUEST['act'])){$myAction = (trim($_REQUEST['act']));}else{$myAction = "";} switch ($myAction) {//check 'act' for type of process case "display": # 2)Display user's name! showName(); break; default: # 1)Ask user to enter their name showForm(); } function showForm() {# shows form so user can enter their name. Initial scenario get_header(); #defaults to header_inc.php ?> <script type="text/javascript" src="<?=VIRTUAL_PATH;?>include/util.js"></script> <script type="text/javascript"> function checkForm(thisForm) {//check form data for valid info if(empty(thisForm.YourName,"Field Empty, please fill out")){return false;} return true;//if all is passed, submit! } </script> <p align="center"><?=smartTitle();?></p> <h3 align="center">Star Trek Classic</h3> <h2 align="center">Death-Shirt Calculator</h2> <form action="<?=THIS_PAGE;?>" method="post" onsubmit="return checkForm(this);"> <p align="center">Classic Star Trek Episode Name<br /> <input type="text" name="epName" /><br /><br /> Esitmated number of officers with red shirts<br /> <input type="text" name="rsTot" /><br /><br /> Esitmated number of officers with red shirts<br /> to actually survive the episode<br /> <input type="int" name="rsSurvived" /><br /><br /> <input type="submit" value="Go!"> </p> <input type="hidden" name="act" value="display" /> </form> <?php get_footer(); #defaults to footer_inc.php } function showName() {#form submits here we show entered name get_header(); #defaults to footer_inc.php if(!isset($_POST['epName']) || $_POST['epName'] == '') {//data must be sent feedback("No form data submitted"); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } if(!ctype_alnum($_POST['epName'])) {//data must be alphanumeric only feedback("Only letters and numbers are allowed. Please re-enter your name."); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } $epSubmitted = strip_tags($_POST['epName']);# strip data entered echo '<h3 align="center">' . smartTitle() . '</h3>'; echo '<p align="center">Episode Name: <b>' . $epSubmitted . '</b><br />'; echo '<p align="center">Total Red Shirts Appearing: <b>' . $rsTot . '<br />'; echo 'Red Shirts Still Breathing at End of Episode: <b>' . $rsSurvived . '<br />'; echo 'Red Shirt Episode Survival Ratio: <b>' . $rsRatio . '</b>!</p>'; echo '<p align="center"><a href="' . THIS_PAGE . '">RESET</a></p>'; get_footer(); #defaults to footer_inc.php } ?> Edited by Chezshire, 25 May 2014 - 08:10 AM. Hello All,
I have designed a small php module Which has more than 80 .php files. I want to give the access level for all those files through a global access.php file. But i am not getting how it can be developed. I made a table in database which has all the scripts name. When those are checked value 1 it has to be visible for those users who come under a perticular position like MD, CEO, Sales Manager etc. Here is my table structure
script.JPG 20.61KB
0 downloads
and i tried doing like this
if($_SESSION['pos']=='admin') { echo "<h1> SORRY YOU DONT HAVE ACCESS </h1>"; } else { // file contents... } Hi All, My appologies in advance. I am pretty sure that this has probably been answered before by someone...but for the life of me I carn't find the answer in any forums. My basic question is this. Can you create an object at the beginning of a script, and then call its methods from within functions? I have coded the following: <?php ///import classes to use require "booking_form_gui.php"; $booking = new booking_form_gui(); function _booking_form($form_state){ ///$booking = new booking_form_gui(); return $booking -> date_selection(); <----------this line causes the error I guess } The problem is that when I run this code, I get an error message similar to the following: Fatal error: Call to a member function date_selection() on a non-object in /var/www/drupal_6/sites/default/modules/booking_system/booking_form/booking_form.module on line 127 Anyone any ideas how I could get round this? Thanks, Mark. Fatal error: Cannot redeclare limitatexto() (previously declared in funciones.php:4) in funciones.php on line 12 <?php function limitatexto( $texto, $limite ) - Line 4 { if( strlen($texto)>$limite ) { $texto = substr( $texto,0,$limite ); } return $texto; } Line 12 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350027.0 Hello everyone, I'm just starting out with PHP as I need to create an online bookstore for a school project. I'm working by a magazine which should teach you exactly how to do this using PHP, but I've had a bunch of problems with the code they use and I don't really know what's going on. Anyway, this looks really simple and basically what it does is allows you to post a comment on a book, then returns you to the book's page. Problem is, I'm getting the Header may not contain more than a single header, new line detected. error and I can't figure out why. I've tried researching into the matter but all the cases I found had to do with returning to an url, which is not my case. Anyway, here's the snippet of code: The form: Code: [Select] <div style="width:400px; border:1px solid #ffffff; background-color:#F9F1E7; padding:5px"> <b>Adauga opinia ta:</b> <hr size="1"> <form action="adauga_comentariu.php" method="POST"> Nume: <input type="text" name="nume_utilizator"><br><br> Email: <input type="text" name="adresa_email"><br><br> Comentariu: <br> <textarea name="comentariu" cols="45"></textarea><br><br> <input type="hidden" name="id_carte" value="<?=id_carte?>"> <center><input type="submit" value="Adauga"</center> </form> </div> The script adaugare_comentariu.php: Code: [Select] <?php ob_start(); include("conectare.php"); $numeFaraTags=strip_tags($_POST['nume_utilizator']); $emailFaraTags=strip_tags($_POST['adresa_email']); $comentariuFaraTags=strip_tags($_POST['comentariu']); $sql="insert into comentarii (id_carte, nume_utilizator, adresa_email, comentariu) values(".$_POST['id_carte'].", '".$numeFaraTags."','".$emailFaraTags."','".$comentariuFaraTags."')"; mysql_query($sql); $inapoi="carte.php?id_carte=".$_POST['id_carte']; header("location:urldecode($inapoi)"); ob_end_flush(); ?> conectare.php connects to the mysql database. $inapoi is the variable which returns the user to carte.php (the book he posted a comment on), where id_carte is the book's unique id. I'm getting Header may not contain more than a single header, new line detected on line ten, which is the header line. Can anyone help me? I've been stumped on this for a few days now and I've just let it pass and started working on other bits, but it's bugging me too much and I'd like to fix it. How do I get this to put in the pilotID? Code: [Select] header("Location: logbook.php?id=" . $pilotid); Thanks! Hi there, I have a form which displays a "successful" message if the form is completed correctly. However, I want the form to go to another url if it is successful. I have tried this, but I get the "headers already sent..." message // Add New Subscriber Success Message $successMsg = header('Location: http://www.example.com/'); is there another way to forward onto another page? Thanks Hi is there a way that i can set header not go anywhere like the problem with this is that it still goes to the second header is there a way i can set if none do nothing exit? and else do the second header?? Code: [Select] <?php if ($_POST['agents']=="none") { header("location:#"); exit; // header("Location: {$_SERVER['PHP_SELF']}"); } else { header("location:http://www.xxxxxx.co.uk/tv/".$_POST['agents']."/index.php"); } ?> Can some one help please i always get this wrong dont now why keep saying header already been sent any help please and how to fix it Code: [Select] <?php session_start(); $conn = mysql_connect(""); $db = mysql_select_db("", $conn); if(isset($_POST['submit'])){ $user = mysql_escape_string($_POST['user']); $pass = mysql_escape_string($_POST['pass']); } if(empty($user) && empty($pass)){ exit; }else{ } ?> <?php $sql = mysql_query("SELECT * FROM useradmin WHERE dbusername= '".$user."' AND dbuserpass= '".$pass."'")or die(mysql_error()); $row = mysql_fetch_assoc($sql); $count = count($sql); $u = $row['dbusername']; $p = $row['dbuserpass']; if($u == $user && $p == $pass){ $_SESSION['access'] = "$u"; header("location: index.php"); }else { echo "Sorry there as been a problem!"; exit; } ?> Hey guys, I have a problem, i'm using ob_start to send multiples headers and it works but the problem is that my metada is not being sent, when i remove the ob_start it gets sent. Is there a way i can allow more info to be sent with ob_start? or should i use other methods to redirect to pages? i dont want to use javascript or meta http because they are not very reliable is there any other way? Thanks for help. Hi everyone, I have a login area, and i also have set up for me is a view page... the view page is each user's sort of profile, it gets id and displays relevant content. i was wondering if i could get the id or post rather through a re-direct on log in? for example user logs in with username and password, user is re-directed to the view page like this: header( "refresh:5;url=view00=id.php " ); echo '<h1>You will be re-directed in 5 seconds...</h1>'; user is taken to view page where they can edit bit on it. So far though i'm getting page not found error? first of all is this possible? if not whats the correct way/better way? Thanks Does starting a Session send data to the Header? Debbie I currently have a login script in place on my site and to get to certain pages you have to be logged in to get to. So when a user tries to go to one of those pages and is not logged in it sends them to the login page (which is great) But on the login page once they login it uses " header('Location: index.php') " to automatically send them to the index page logged in. How can i dynamically see what page they are coming from that way when they login I can send them back to where they where trying to get to to begin with. (like if they click on "Profile" and they are not logged in it sends them to "login" then they login and it currently sends them to "index" I want it to dynamically know to send them back to "profile" instead) If this doesn't make sense and i will try and explain it better But if you understand and know how to do this please help Thanks ahead of time! I have been trying to fix this for a really long time. It does not show an error on my local server but on my demo server it does.' What am I doing wrong? I have tried changing the location of the default.php file. I even tried require_once and require. Nothing worked. try logging in with random details with this link. You will see the error. http://goo.gl/3IetJ default.php <?php $hostname_default = "localhost"; $database_default = "mypass"; $username_default = "my_user"; $password_default = "my_pass"; $default = mysql_pconnect($hostname_default, $username_default, $password_default) or trigger_error(mysql_error(),E_USER_ERROR); ?> login.php <?php if (!isset($_SESSION)) { session_start(); } if (!empty($_REQUEST['password'])) { include("../Connections/default.php"); $username = $_REQUEST['username']; $password = md5(md5($_REQUEST['password'])+salt); mysql_select_db($database_default, $default); $login_check = "SELECT * FROM users WHERE username = '$username' AND password = '$password'"; $login = mysql_query($login_check, $default) or die(mysql_error()); $row_login = mysql_fetch_assoc($login); $val_login = mysql_num_rows($login); if ($val_login == '1') { $_SESSION['E_User'] = $row_login['username']; header('Location: index.php'); } else { header('Location: login.php?error=1&username='.$username.''); } } ?> |