PHP - Header Error... Has Something To Do With Setcookie Cant Figure It Out
I hate header errors... I can never figure them out, im getting this error;
Warning: Cannot modify header information - headers already sent by (output started at /home/damnpeti/public_html/restrict2.php:6) in /home/damnpeti/public_html/restrict2.php on line 62 Code: <?php $testDB = mysql_connect('localhost', $db_user, $db_pwd); mysql_select_db ($db_name); if (!$testDB) { die('Could not connect: ' . mysql_error()); } $surfer_ip = $_SERVER["REMOTE_ADDR"]; $str_sql = "select * from ".$db_table." where ipaddress='".$surfer_ip."'"; $result = mysql_query($str_sql); if ($row = mysql_fetch_assoc($result)) { $blocked_time = strtotime($row['blocked_time']); if($blocked_time != 0) { $current_time = time(); if($current_time - $blocked_time > 3600*24) //24 hours past { $str_sql = "delete from ".$db_table." where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } else { die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } else { if($row['surf_index'] < 2) { $str_sql = "update ".$db_table." set surf_index=surf_index+1 where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); } else { $str_sql = "update ".$db_table." set blocked_time='".date ("Y-m-d H:i:s")."' where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } } else { $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } if(!isset($_COOKIE['surf_no'])) setCookie('surf_no', '1'); else setCookie('surf_no', $_COOKIE['surf_no']+1); if ($_COOKIE['surf_no'] > 2) die("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); include 'http://damnitpetitions.com/cut/index3.php'; ?> Line 62 is if ($_COOKIE['surf_no'] > 2) I know it has something to do with the cookie... but Idk? I need the include there. If there include isnt where its at, the script is worthless. Similar Tutorialshello i use the fallowing code for my login page but it gives me the fallowing error i was wondering what is the problem? (line 179 is the setcookie) by the way it doesn't set the cookie any help would be appreciated error: Quote Warning: Cannot modify header information - headers already sent by (output started at /home2/sportsh9/public_html/test/login_acc.php:6) in /home2/sportsh9/public_html/test/login_acc.php on line 179 my code: <? include_once('functions.php'); function cleanQuery($string) { if(get_magic_quotes_gpc()) // prevents duplicate backslashes { $string = stripslashes($string); } $badWords = "(delete)|(update)|(union)|(insert)|(drop)|(http)|(--)"; $string = eregi_replace($badWords, "", $string); if (phpversion() >= '4.3.0') { $string = mysql_real_escape_string($string); } else { $string = mysql_escape_string($string); } return $string; } if (isset($_COOKIE['scmuser'])) { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">"; }else{ if ($_POST['username']) { //did they supply a password and username $username=cleanQuery($_POST['username']); $password=cleanQuery($_POST['password']); if ($password==NULL || $username==NULL) { ?> <p align="center"> <font color="#FF0000">Username or password wasn't supplied!</font><form action="login_acc.php" method="POST"> <table style="border:1px solid #FFFFFF;" width="90%" align="center"> <tr> <td align="center">Username: </td> <td align="center"> <input type="text" size="20" maxlength="25" name="username" /></td> </tr> <tr> <td align="center">Password: </td> <td align="center"> <input type="password" size="20" maxlength="25" name="password" /></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Login"/> </td> </tr> <tr> <td align="center" colspan="2"> <a href="register.php">Register</a> - <a href="forgetpass.php">Forgot Your Password?</a> </td> </tr> </table> </form> <? }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($query); if($data['password'] != $password) { ?> <p align="center"> <font color="#FF0000">The supplied login was incorrect</font><form action="login_acc.php" method="POST"> <table style="border:1px solid #FFFFFF;" width="90%" align="center"> <tr> <td align="center">Username: </td> <td align="center"> <input type="text" size="20" maxlength="25" name="username" /></td> </tr> <tr> <td align="center">Password: </td> <td align="center"> <input type="password" size="20" maxlength="25" name="password" /></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Login"/> </td> </tr> <tr> <td align="center" colspan="2"> <a href="register.php">Register</a> - <a href="forgetpass.php">Forgot Your Password?</a> </td> </tr> </table> </form> <? }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $row = mysql_fetch_array($query); setcookie("scmuser", "$username", time()+3600); echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">"; } } } } ?> thank you Hi im still learning php and have been running through the tutorials on making a user authentication system but im getting an error on one line but ive got the same code else where and its fine... Code: [Select] // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } Im getting the error on the if statment but no matter what i try it still tells me theres an error... Heres the full function code: Code: [Select] function account_namevalid() { // parameter for use with strspan $span_str = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } // Must contain all legal characters if (strspn($_POST['user_name'],$span_str) != srnlen($name)) { return false; } // Min and Max length if ($strlen($_POST['user_name']) < 5) { return false; } if strlen($_POST['user_name']) > 25 { return false; } // Illegal names if (eregi("^((root)|(bin)|(deamon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)|(uucp)|(operator)|(games)|(mysql)| (httpd)|(nobody)|(dummy)|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download)))$", $_POST['user_name'])) { return false; } if (eregi("^(anoncvs_)", $_POST['user_name'])) { return false; } return true; } Any help or info would be greatfull... Cheers Chris Fatal error: Cannot redeclare class MySQLDB in /home/xservers/public_html/skylar/VIP/include/database.php on line 14 Can someone please give me some guidance on how to deal with the following warning Quote
Warning: move_uploaded_file(../usernet/img/60ff59c9f0a830.45733158.jpg): Failed to open stream: Permission denied in /opt/lampp/htdocs/site/admin/add_post.php on line 23 All directories and files in the path have full owner permissions and I've made myself the owner of them all (I'm on a linux system). I've also done the same with the /tmp folder. I can't even think of anything else to change and haven't found anything online that solves the issue. in case it's needed, the php is as follows: <?php require("assets/initializations.php"); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; $file_ext = explode('.', $filename); $file_act_ext = strtolower(end($file_ext)); $allowed = array('jpeg', 'jpg', 'png', 'gif'); if(!in_array($file_act_ext, $allowed)) { header("Location: add_post.php?message=file_type_not_allowed"); } else { if($filesize > 10000000) { header("Location: add_post.php?message=file_too_large"); } else { $file_new_name = uniqid('', true) . "." . $file_act_ext; $dir = "../usernet/img/"; $target_file = $dir . basename($file_new_name); move_uploaded_file($file_tmp_name, $target_file); echo "<script>alert('Image uploaded successfully');</script>"; } } } I do get the javascript alert that's it's been successfully uploaded, but the image doesn't make it into the specified directory and I get the warnings at the top. I'm also, probably obviously from the path, using XAMPP server for development. TIA I am getting Fatal error: Uncaught Error: Call to a member function real_query() on null with this code: public final function Retrieve($TABLE, $CRIT){ $_query = "SELECT * FROM `{$TABLE}` WHERE "; foreach($CRIT as $_field => $info){ $_query .= " `{$_field}` = `{$info}` &&"; } if($this->LINK->real_query(rtrim($_query, ' &'))){ return $this->LINK->store_result(); } else{ return json_encode(array("Error"=>$this->LINK->errno(), "Description"=>$this->LINK->error())); } } (LINK is my mysql_connect() result.) I have tried everything i can think of, ->query, going to mysqli_query, breaking it sown and using a $result variable, but nothing seems to work... Edited March 29, 2019 by KaraethonThis is the code: <?php $Fname = $_POST["Fname"]; if (!isset($_POST['SUBMIT'])) { // if page is not submitted to itself echo the form ?> <html> <body> <head> <title>Personal INFO</title> </head> <body bgcolor="#008080"> <h1><blink><font color="#FF0000"><strong>Naruto Biography Creation</strong></font></blink></h1> <h3><font size="1" color="#0000FF">Please note, info with a (*) must be filled in!</h> </font> <form method="post" action="<?php echo $PHP_SELF;?>"> <p><font size="2"><b>*First Name:</b></font><input type="text" size="30" maxlength="12" name="Fname"><br /> <br /> <font size="2"><b>*Last Name:</b></font><input type="text" size="30" maxlength="36" name="Lname"><br /> <br /> <b><font size="2">*Gender:</font></b><br /> <input type="radio" value="Male" name="Gender" style="font-weight: 700"><b><font size="2">Male</font> </b><input type="radio" value="Female" name="Gender" style="font-weight: 700"><b><font size="2">Female</font></b></p> <p><b><font size="2">Background Info:</font></p> <textarea rows="3" cols="33" name="Background INFO" wrap="hard">Enter your Character's History</textarea><p><font size="2">Appearance:</font></p> <p> <textarea rows="3" cols="33" name="*Appearance" wrap="hard">State how your character look</textarea></p> <p><font size="2">Personality:</font><br/><span> <textarea rows="3" cols="33" name="*Personality" wrap="hard">Explain your Character's qualities, attitude, etc.</textarea></span></p> <p><span><br /></span> <font size="2">*Affiliation:</font><br /> <select name="Affiliation" size="3" width="8"> <option value="None" selected>Select one</option> <option value="Leaf">Leaf</option> <option value="Sand">Sand</option> <option value="Cloud">Cloud</option> <option value="Rogue">Rogue</option> </select><br /> <font size="2">*Rank:</font><br /> <select name="Rank" size="3" width="8"> <option value="none" selected>Select one</option> <option value="Gennin">Genin</option> <option value="Chuunin">Chuunin</option> <option value="Jounin">Jounin</option> <option value="S class">S class</option> </select> </p> <p> <input type="submit" value="submit" name="submit"></p> </form> </body> </html> <? } esle { echo "Hello,".$Fname." ".Lname.".<br />"; } ?> I get this all the time Quote Parse error: syntax error, unexpected $end in F:\wamp\www\index.php on line 78 I work on Wamp, and I am a beginner so I am totally lost could anyone help please Here is the code: Code: [Select] <?php if (!defined('INCLUDE_GUARD')) { header("Location: /errors/forbidden"); return; } include_once("incs/cls/DatabaseManager.class.php"); include_once("incs/cls/VariantTemplate.class.php"); class Core { private $_logger; private $_self_test_results; private $_config; private $_dbmgr; private $_vtemp; public __construct() // this is line 19 { $this->setupLogger(); $this->_self_test_results = array(); $this->_self_test_results['missing'] = array(); $this->_self_test_results['failed'] = array(); $this->_config = array(); $this->_dbmgr = null; $this->_vtemp = null; $this->selfTest(); } Here is the error I've been receiving. Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /home/ditecha1/public_html/slick/incs/cls/SlickCMSCore.class.php on line 19 I am finding this error extremely weird, my host uses PHP 5.2.14. I was setting the private variables directly (without the assistance of the constructor), but I removed this and had the constructor set basic values to start with to see if this was the issue, but it wasn't. I've tried commenting out the include_once lines, since they are also in development I thought maybe an error was being carried over in to this file as the includes were happening, but still no change in the error message at all. Any help would be greatly appreciated! Hi, I'm a newbie, and needed help fixing a part of a code Whenever someone is clicking add to cart, it triggers an error. The output is: Duplicate entry Warning: Cannot modify header information - headers already sent by (output started at C:\ampp\htdocs\ptc1\pages\insertTotempsql.php:9) in C:\ampp\htdocs\ptc1\pages\insertTotempsql.php on line 56 Is there some weakness in the code causing it? line 56 is the last line. The code is <?php if( !isset( $_SESSION )){ session_start(); } $ses_id = session_id(); require_once('../Connections/connect.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php if(isset($_POST['id'])){ $id=$_POST['id']; $uom=$_POST['uom']; $quantity=$_POST['QUANTITY']; $date=$_POST['dateToday']; $PRICE=$_POST['PRICE']; if(isset($_POST['MeatOrigin'])){ $prod=$_POST['prodname'] . " ( " . $_POST['MeatOrigin'] . " ) "; } else { $prod=$_POST['prodname']; } mysql_select_db($database_connect, $connect); //check database if item is existing $query_duplicate = sprintf("SELECT * FROM tbl_cart WHERE pd_id='$id' and ct_session_id='$ses_id' and ct_date='$date'"); $duplicate = mysql_query($query_duplicate, $connect) or die(mysql_error()); $row_duplicate = mysql_fetch_assoc($duplicate); $totalRows_duplicate = mysql_num_rows($duplicate); if($totalRows_duplicate > 0){ echo "Duplicate entry"; } else { $insertSQL = "INSERT INTO tbl_cart ( pd_id, pd_name, ct_qty, ct_session_id, ct_date, PRICE, uom) VALUES ('$id', '$prod', '$quantity', '$ses_id', '$date', '$PRICE', '$uom')"; $Result1 = mysql_query($insertSQL, $connect) or die(mysql_error()); } mysql_close($connect); header("Location:".$_SERVER['HTTP_REFERER']); } ?> Thanks I've been staring at this for ages and I can't for the life of me see what the problem is, even after reading the 'HEADER ERRORS - READ HERE BEFORE POSTING THEM' post I still haven't been able to get it! It's probably something really stupid, I'm fairly sure its to do with the header because all the info gets passed to the MySQL datase. The form: admin-news.php Code: [Select] <?php session_start(); require_once('auth.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin Index</title> <link href="layout.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> </head> <body> <h1>Update News Feed</h1> <a href="admin-profile.php">My Profile</a> | <a href="admin-news.php">News</a> | <a href="adlogout.php">Logout</a> <p>Enter news below or click <a href="member-news.php">here</a> to view news feed.</p> <form id="news" name="news" method="post" action="newsfeed.php"> <table border="0" class="tablecontents"> <tr> <td align="left">Message:</td> <td><textarea name="newsfeed" style="resize: none;" rows="4" cols="40" onKeyDown="limitText(news.newsfeed,news.countdown,140);" onKeyUp="limitText(news.newsfeed,news.countdown,140);"></textarea> </td> </tr> <tr> <td> </td> <td><?php if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) { echo '<ul class="err">'; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo '<li>',$msg,'</li>'; } echo '</ul>'; unset($_SESSION['ERRMSG_ARR']); } ?> </td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Post News"></td> </tr> <tr> <td></td> <td><p>(Maximum characters: 140)<br /> You have <input readonly type="text" name="countdown" size="3" value="140" /> characters left.</p></td> </tr> </table> </form> </body> </html> The php script: newsfeed.php Code: [Select] <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $newsfeed = clean($_POST['newsfeed']); //Input Validations if($newsfeed == '') { $errmsg_arr[] = 'Please enter some news'; $errflag = true; } //If there are input validations, redirect back to the registration form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: admin-news.php"); exit(); } //Create INSERT query $qry = "INSERT INTO newsfeed(newsfeed) VALUES('$newsfeed')"; $result = @mysql_query($qry); if($result) { header("location: news-success.php"); exit(); } else { die("Query failed"); } ?> The script carries out the insert but just leaves me at a blank newsfeed.php page! Any ideas? Thanks in advance Hello I am getting this error in my script. Can anyone help? Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb25b/b904/ipg.votpservicescom/listing15.8.php:12) in /hermes/bosweb25b/b904/ipg.votpservicescom/listing15.8.php on line 39 if ((!$_POST[username]) || (!$_POST[password])) { header("Location: listing15.7.php"); exit; } //connect to server and select database $link = mysql_connect('servicescom.ipagemysql.com', 'ssap', 'pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db(formlogin); //create and issue the query $sql = "select f_name, l_name from auth_users where username = '$_POST[username]' AND password = password('$_POST[password]')"; $result = mysql_query($sql, $link) or die(mysql_error()); //get the number of rows in the result set; should be 1 if a match if (mysql_num_rows($result) == 1) { //if authorized, get the values of f_name l_name $f_name = mysql_result($result, 0, 'f_name'); $l_name = mysql_result($result, 0, 'l_name'); //set authorization cookie setcookie("auth", "1", 0, "/", "votpservices.com", 0); //prepare message for printing, and user menu $msg = "<P>$f_name $l_name is authorized!</p>"; $msg .= "<P>Authorized Users' Menu:"; $msg .= "<ul><li><a href=\"listing15.8.php\">secret page</a></ul>"; } else { //redirect back to login form if not authorized header("Location: listing15.7.php"); exit; } ?> <html> <head> <title>Listing 15.8 User Login</title> </head> <body> <?php print "$msg"; ?> </body> </html> 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.''); } } ?> For some reason I can not get this to work. Any thoughts? if( $row['password'] == $pass && $row['name'] == $user ) { $username = $row['name']; $uid = $row['id']; setcookie("id", $uid, 1400); //creates the first session var setcookie("username", $username, 1400); // second session var setcookie("loggedin", "1", 1400); echo "<script type=\"text/javascript\">alert(\"".$row['name']."Logged in as ".$_COOKIE['username'].".\"); window.location=\"index.php?OMG=loggedin\"</script>"; } I get a message box saying: "[username] Logged in as ." I've searched php.ini for corrupt cookie settings, nothing unusual. i have never been able to get this to work but i am at it agian in this code the php is not making the cookie can any one tell me why <?php function getRandomString($length = 5) { $validCharacters = "abcdefghijklmnopqrstuxyvwzABCDEFGHIJKLMNOPQRSTUXYVWZ+-*#&@!?1234567890"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result; } setcookie("code", "getRandomString()", 3600000); echo getRandomString(); ?> Hey Guys, I am trying to set a cookie so that when I registered user returns it Auto Logins them in. I am able to accomplish this on my Local server but as Soon as I upload to a web server to test it, it doesn't work. Is anyone able to shed some light on this for me. $usass = $mem['userid']; if (isset($_POST['rem'])) { $year = 3600*24*365; setcookie ("id" , "$usass", time()+$year); } if the code for setting the cookie, and the code for checking the cookie is Below if(isset($_COOKIE['id'])) { $_SESSION['userid'] = $_COOKIE['id']; print "<script>"; print " self.location='loggedin.php';"; // Comment this line if you don't want to redirect print "</script>"; } Hi, I'm working on a mac with MAMP, phpMyadmin. on localhost, also the mysql server is on my localhost. I've tested in either Safari and Firefox. I'm trying to set my cookie, and it doesn't work, and pulling my hair out. I'm trying out following script which should work, but it doesn't and it's driving me mad. I wanna check the cookie for when a person is or isn't logged in, so that i can show additional data on the .php page <html> <body> <?php $value = "my cookie value"; // send a cookie that expires in 24 hours setcookie("TestCookie",$value, time()+3600*24); // Print individual cookies echo $_COOKIE["TestCookie"]; // Print all cookies print_r($_COOKIE); ?> </body> </html> i'm having trouble working with my search bar, when i used wamp it worked but now online i keep getting this message Quote Cannot modify header information - headers already sent by (output started at...) I placed that code for the search bar above the html tags but i keep getting the error here is my coding Code: [Select] <?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); if (isset($_POST['submit'])) { $search = mysql_real_escape_string($_POST['search']); $type = mysql_real_escape_string($_POST['type']); if ($type == true) { header("Location:http://www.link.com/searchresults.php?subdirectory=$search&type=$type"); } } ?> Hi... I'm a little bit new to php and it seems I am getting a small issue that I am not able to resolve... Basicly I just have a page in wich you see the account file of a customer and you can add notes into it. Here's the account file script Code: [Select] <?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); if( ($_GET['cmd']=="view") && (is_numeric($_GET['id'])) ) { $id=$_GET['id']; $data = mysql_query("select * from client_table WHERE id_client='$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo " <table border=\"0\" celppadding=\"0\" cellspacing=\"0\" style=\"font-weight: bold; width: 820px;\"> <tr> <td colspan=\"2\" style=\"height: 50px;\"><a href=\"../dashboard.php\">Panneau de controle</a> > <a href=\"clients.php\">clients</a> > <a href=\"view_client.php?cmd=view&id=".$info['id_client']."\">Fiche client</a> > Notes > ".$info['entreprise']."</td> </tr> <tr> <td style=\"padding-left: 10px\"> NEQ : ".$info['neq']."<br /> <h2>Nom de l'entreprise : ".$info['entreprise']."<br /></h2> <h2>Telephone : ".$info['client_phone']."<br /></h2> </td> </tr> </table> "; } } ?> <form enctype="multipart/form-data" action="process/insert_note.php" method="POST" target="main"> <input type="hidden" name="id_client" value="<?php echo $id; ?>"> <input type="hidden" name="note_date" value="<?php echo date("Y-m-d"); ?>"> <input type="hidden" name="note_time" value="<?php echo date("G:i:s"); ?>"> <table border="0" celppadding="0" cellspacing="0" style="font-weight: bold; width: 780px;"> <tr> <td colspan="0" style="padding-left: 10px">Ajouter une note : <br /><textarea name="note" style="height: 80px;" cols="90"></textarea><br /> <input type="submit" value="Ajouter une note"> </td> </tr> </table> </form> So when I add the note....the form data is passed to a php script to insert the note into the MySQL DB and I just want to be redirected back to the acount file page with the note on it.... Here's the insert script : Code: [Select] <?php header('location:../view_notes.php?cmd=view&id=$id_client'); require_once('../../auth.php'); $id_client = $_POST['id_client']; $con = mysql_connect("localhost","user","pass"); $note_date = $_POST['note_date']; $note_time = mysql_real_escape_string($_POST['note_time']); $note = mysql_real_escape_string($_POST['note']); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db", $con); $sql="INSERT INTO notes_table ( id_client, note_date, note_time, note) VALUES ('$id_client','$note_date','$note_time','$note')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } ?> The problem I have is that the HEADER part is working but the value : header('location:../view_notes.php?cmd=view&id=$id_client'); is not passed so I am redirected to a blank page..... I tried to find the info on google but can't seems to find what wrong... Any help will be appreciated! Thanks This is the error message: Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/main.php:12) in /home/public_html/main.php on line 61 I've tried reading into this but find no solutions if anyone can help I would be very grateful. I'm just trying to get the code to take the user to register page if they not a member heres the code im using <table border="0" width="220" align="center"> <tr> <? if(!session_is_registered("username")){ // if session variable "username" does not exist. echo "<td width='71'>Username:</td> <td width='139'><input type='text' name='username' size='16' style='font-family: Times New Roman, Times, serif; font-size: 11pt;' /></td> </tr> <tr> <td width='71'>Password:</td> <td width='139'><input type='password' name='password' size='16' style='font-family: Times New Roman, Times, serif; font-size: 11pt;' /></td> </tr> <tr> <td colspan='2' align='center'><input name='login' type='submit' value='Log In' style='background-color: #900002; border-color: #555555; color: #FFFFFF; font-weight: bold; width: 60px;' /></td>"; }else{ echo "<td><b>Welcome $username</b><br /><a href='logout.php'><b>Logout</b></a></td>"; } ?> </tr> </table> </form></div> <div id="menutext"><span class="class1"><a href="http://www.fightwatcher.com">Home</a> <a href="http://www.fightwatcher.com">News</a> <a href="http://www.fightwatcher.com">Profile</a> <a href="http://www.fightwatcher.com">Friends & Fighters</a> <a href="http://www.fightwatcher.com">Videos</a> <a href="http://www.fightwatcher.com">Groups</a> <a href="http://www.fightwatcher.com">Forum</a></span></div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <? if(!session_is_registered("username")){ header("Location: http://www.fightwatcher.com/register.html"); }else{ include("connect.php"); $result = mysql_query("SELECT * FROM signup ORDER by date AND time LIMIT 10"); echo "<table cellpadding=0 cellspacing=0 width=163> <tr bgcolor=#990000><td colspan=2 align=center height=24><font color=#FFFFFF><b>Newest Users:</b></font></td></tr>"; while($row = mysql_fetch_array($result)) { $username = $row['username']; $gender1 = $row['gender']; if ($gender1=="male") { $gender2="<font color=#0066FF><b>M</b></font>"; } if ($gender1=="female") { $gender2="<font color=#FF33CC><b>F</b></font>"; } echo "<tr><td align=center width=100>$username</td><td align=center width=57>$gender2</td></tr>"; } echo "</table>"; } ?> </body> Thanks I know PHP setcookie can set for all subdomains - by setting parameter 5 to something like ".domain.com". However, I have quite a lot of code that just leaves param 5 blank (so sets for the current subdomain of that server). Hopefully there'd be an easy way how to do this (a server setting?). I know you can use ini_set('session.cookie_domain','http://domain.com'); but that only seems to set the session cookie value, not ones set in PHP. I only really want it to ensure if someone accesses the site through both www.domain.com and domain.com that they use the same cookies. I am aiming to use setcookie to refresh the expiry of a cookie on EVERY page request. Is this slow? I'm sure I can design things so i don't need to reset it on every page request, but if it isn't a big deal then I'll do it. Is setcookie slow? |