PHP - A Header Refreshing Problem
Hello!
My server hosting company has updated PHP from 4 to 5 version, and now the header function doesn't work very well anymore. It does load the new page everytime, like it should, but the data is not always refreshed. Not until I click "reload current page" from the browser. I'm using Firefox 3.6.3. Here's the code which worked just fine few days ago: Code: [Select] $url="thepage.php"; header("Location: ".$url); die(); I tried something like this, but that doesn't work either: Code: [Select] $url="thepage.php"; header("Refresh: 0; url=".$url); die(); This is really nasty problem... How can I fix it? Similar TutorialsI've got this sign in code: Code: [Select] [php] <?php include("conf.inc.php"); // Includes the db and form info. if ($_SESSION['logged'] == 1) { // User is already logged in. $_SESSION['email'] = $email; header("Location: main.php"); // Goes to main page. exit(); // Stops the rest of the script. } else { if (!isset($_POST['submit'])) { // If the form HAS NOT been submitted. echo "<td width=\"320\" height=\"50\" align=\"left\" valign=\"middle\"> </td>"; echo "<td width=\"360\" height=\"50\" align=\"left\" valign=\"middle\">"; echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">"; echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a> "; echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onMouseOver=\"window.name = 'main'\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>"; echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\"> "; echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> "; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">"; echo "</form>"; } else { // If the form HAS been submitted $email = form($_POST['email']); $pword = md5($_POST['pword']); // Encrypts the password. $q = mysql_query("SELECT * FROM `signin` WHERE email = '$email' AND pword = '$pword'") or die (mysql_error()); // mySQL query $r = mysql_num_rows($q); // Checks to see if anything is in the db. if (!$r) { // There is nothing in the db. The username/password do not match up. echo "<td width=\"108\" height=\"50\" align=\"left\" valign=\"middle\"> </td>"; echo "<td width=\"572\" height=\"50\" align=\"left\" valign=\"middle\">"; echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">"; echo " <a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a> "; echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>"; echo "<font color=\"#FF0000\"><strong>Incorrect Email or Password.</strong></font> "; echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\"> "; echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> "; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">"; echo "</form>"; } else { // If the username/password is invalid $_SESSION['logged'] = 1; // Sets the session. $_SESSION['email'] = $email; header("Location: main.php"); // THIS IS LINE 111 exit(); // Stops the rest of the script. } } } ?> [/php] And when I sign in with my user name and password, I get this warning message: Warning: Cannot modify header information - headers already sent by (output started at /home/content/29/6879529/html/calhoun/index.php:9) in /home/content/29/6879529/html/calhoun/head1.inc.php on line 111 Can anyone help me out and tell me what I need to do to correct this? Thanks in advance for your help! Hi guys, I've got a header problem. I've read the header sticky post but i'm still not getting anywhere. I am currently working on a registration form which loops though checking the data entered meets certain criteria by calling various functions (min length, max length, preg match, etc...), if anything returns 'false' then the form is reproduced with the error message of why it failed and what needs to be changed. If everything returned is 'true' then all day matches what is expected and the code then runs an 'insert' command. If the insert is successful then the code should forward the user to a new page displaying 'registration complete'. However, the way I have written my code I am finding it near impossible to get the forward to be before anything is output to the browser therefore causing the header error. I have tried moving things around but i'm having no luck. The error I am getting is: Warning: Cannot modify header information - headers already sent by (output started at /websites/blahblahblah/register.php:6) in /websites/blahblahblah/register.php on line 77 The code there is relevant though as it is the code that make the connection to my DB. Code: [Select] <!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=utf-8" /> <?php // *** Connection - START *** // connect to database $connect = @mysql_connect("test", "test", "test") or die(mysql_error()); if (!$connect) { do_error("Could not connect to the server"); } @mysql_select_db("test_db",$connect)or do_error("Could not connect to the database"); // *** Connection - END *** // This file includes all of the check functions for the code to run through include("check.php"); if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) { $data= new check($_POST); $data->name('forename'); $data->name('surname'); if ( $data->pass == true ) { // Now we have the required data in the correct format do the code required to complete registration $forename=$data->input['forename']; $surname=$data->input['surname']; $query="INSERT INTO users ( forename, surname ) VALUES ('$forename' , '$surname' )"; if (mysql_query($query,$connect)) { //echo "success"; // once data is inserted, go to complete page header ("location: complete.php"); exit; } else { echo "Error: Please try again."; } } } else { $data= new check(); } ?> What am I actually doing wrong and how can i possibly get the insert script higher up the code?? Thanks the page below worked until i added the php include part to the top of the page and now i get the header error message for some of my web pages but i have fixed them all but this one. How do i fix this because i can't move them to the top of the page just under the php include like i needed to do with the other pages because if i move them up it will put the forms at the top aswell. <?php include("protect page file location"); ?> <!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=utf-8" /> <title>Dvds</title> <link href="../../style.css" rel="stylesheet" type="text/css" /> </head> <link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="uploadify/swfobject.js"></script> <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#file_upload').uploadify({ 'uploader' : 'uploadify/uploadify.swf', 'script' : 'uploadify/uploadify.php', 'cancelImg' : 'uploadify/cancel.png', 'folder' : '../../dvds/dvd_files', 'displayData' : 'percentage', 'auto' : true, 'multi' : true }); }); </script> <body> <div class="container"> <div class="header"><br /><br /><br /> </div> <div class="sidebar1"> <ul class="nav"><b> <li><a href="../../">Home</a></li> <li><a href="../">Testimonials upload</a></li> <li><a href="../audio/">Audio Testimonials upload</a></li> <li><a href="../dvds/">Dvd's upload</a></li> <li><a href="../newsletter/">Newsletter upload</a></li> <li><a href="../news/">News box update</a></li> <li><a href="http://www.weblink.co.cc/admin/?logout=1">Logout</a></li> </b></ul></div> <div class="content"><div class="text"> <center><h3>Admin</h3> <br /> <p><input id="file_upload" name="file_upload" type="file" /></p></center> <center><p><form method="get" action="index.php"> <select name="id" class="inputstandard"> <option value="default">Select Dvd</option><?php include("dbinfo1.inc.php"); mysql_connect($localhost,$username,$password); mysql_select_db($database) or die( "Unable to select database"); $result = mysql_query('SELECT * FROM Dvd ORDER BY id ASC') or die (mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<option value="' . $row['id'] . '" name="' . $row['id']. '">Dvd ' . $row['id']. '</option>'; } ?> </select> <input type="submit" value="Submit"> </form></p> <p><?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="POST" action="insert_dvd.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Update"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?><br /><?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="GET" action="delete.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'.wmv" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Delete"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?> </p></center></div> </div> <div class="sidebar2"> <center><h4>Help</h4></center> <p>text here</p> </div> <div class="footer"> <center><p>&#169; Copyright 2010</p></center> </div> </div> </body> </html> the below are the php parts causing the problems. <?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="POST" action="insert_dvd.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Update"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?> <br /> <?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="GET" action="delete.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'.wmv" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Delete"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?> What im trying to do is have the webpage forward the user to another page after they fill out something for a certain element in the database. But the once I put the variable into a header for forwarding, the variable is thought to be a string instead of outputting its value it holds. Heres my code.... $variable = "nextPage"; header('Location:webpage.php?id=$variable'); But whats its doing is sending the user to the url "webpage.php?id=$variable" instead of "webpage.php?id=nextPage" What can I do to get the header to read the variable value and not the variable name? All help is greatly appreciated!!! My session start is in my session object and I include it at the top of my page prior my html code, yet I still get this warning: Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/Sites/writepaps/index.php:2) in /Users/Sites/writepaps/includes/functions/sessions.php on line 11 I include the object in index line 2. and line 11 is where my session start is in my construct function <?php require_once("database.php"); require_once("user.php"); class Sessions { public $logged_in = false; protected $username; protected $password; function __construct(){ session_start(); $this->check_login(); } .... Why is this happening? Hi! I'm not a very experienced PHPer. I keep getting this error... Warning: Cannot modify header information - headers already sent by (output started at /home/content/j/2/6/j26183102/html/referral.php:11) in /home/content/j/2/6/j26183102/html/referral.php on line 295 Any suggestions? It works on one server but not my customers godaddy hosting site. Problem with this header. $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "From: $to\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion(); $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $body = "<html><body>".$table."</body></html>"; Can anyone tell me why? Hi all, I am trying to send an image through header so I have two php files: test0.php Code: [Select] <html> <head> </head> <body> <?php $imagename='test.php'; ?> <img src="<?php echo $imagename; ?>"/> </body> </html> and test.php: Code: [Select] <html> <html> <head> </hesd> <body> <?php $image = imagecreatefromjpeg('images/1.jpg'); header('Content-Type: image/jpeg'); imagejpeg($image, '', 100); ?> </body> </html> but the image doesn't show . What is the correct way? Thank you in advance. hi i want a page to display 4 different pages within it but each of them have a auto refresh ability i dont know if this can be done in php as they woudl only refresh preferably when the users accept or decline the job but can set it to every 10 s if needed 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. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350027.0 Hello. I'm using a PHP/CGI Upload Script -tesUpload. U can see the uploader at http://www.mintload.com/upload/upload-single.php As you can see, the percentage doesnt reload (its an iframe). On Firefox, if u right click on frame (0%) and select "open frame in new tab" or show only frame, u see it movin' and refreshing. Basically the iframe /fileprog.php calculates the percentage uploaded and refreshes itself to get new percentage every second. The code for upload-single.php is : <?php require_once("upload_helper.php"); $sid = md5(uniqid(rand())); ?> <html> <head> <script language="javascript" type="text/javascript" src="upload.js"></script> <link rel="stylesheet" href="upload.css" type="text/css" media="screen" title="Upload" charset="utf-8" /> <script language="javascript"> function beginUpload(sid) { document.postform.submit(); var pb = document.getElementById("progress"); pb.parentNode.parentNode.style.display='block'; new ProgressTracker(sid,{ progressBar: pb, onFailu function(msg) { Element.hide(pb.parentNode); alert(msg); } }); } </script> </head> <body> <form target="_top" enctype="multipart/form-data" name="postform" action="/cgi-bin/upload.cgi?sid=<?php echo $sid; ?>&target=<?php echo normal_target('receive.php') ?>" method="post"> <div class="inputhead">File 1</div> <input type="file" size="50" name="file_1" /><br/> </form> <div id="progressbox" style="display: none;"><img src="http://www.remit2home.com/remittance/images/mmm_loading.gif" alt="uploading..."> Uploading now... <div class="progresscontainer"><div class="progressbar" id="progress"></div></div> </div> <iframe src="http://mintload.com/upload/fileprog.php?sid=<?php echo $sid; ?>" width=50 height=50 frameborder=0 border=0 allowtransparency="true" ></iframe> uploaded <!--img src="http://www.remit2home.com/remittance/images/mmm_loading.gif" alt="uploading..."--> <!--iframe for percentage--> <p align="right"><input type="image" src="http://mintload.com/images/btn_upload.png" onclick="beginUpload('<?php echo $sid ?>');" alt="Upload" ></p> </body> </html> fileprog.php is alright. I need the percentage in iframe to refresh even when embedded onto upload-single.php Please help Thank you. Hi all, I have a list of information that needs to be individually deleted from mysql after 3 months of being on the website. How would I go about this - can one make a php script run 24 hours a day or maybe just refresh at a certain time everyday to check each row (about 300 rows total) in a mysql db and delete as appropriate? Many thanks I have made a website that deals with the sales of different products. It handles the total sales of a specific product. One of the aspects of the website is that it can change the current sales data of the products. At the moment I can change the sales figures fine however I have to click the submit button once and then physically refresh the page for it to change the data in the table. Is there a way that I can automatically refresh the page once the submit button is pressed? I have tried using headers for example: Code: [Select] if (!empty($_POST['NSales'])) { header('location: currentpage.php'); } however this just constantly refreshes the page. Any help would be greatly appreciated Hello. I'm using a php script to upload file. I've used an iframe inserted on the upload page that refreshes every second/3sec. to display percentage uploaded. forget percentage, lets take a simple example. Presently, my iframe displays last two digits of PHP time() function that change constantly. If you see the live example at: http://mintload.com/upload/upload-single.php The last two digits of time() function are shown and iframe is refreshed every 1 sec. But, the moment one clicks "Upload" button, the file starts uploading, but iframe no more refreshes & freezes. In IE7 it works fine. Why not in Firefox Latest Ver: 3.6 ? code for iframe: Code: (php) [Select] header("refresh:1; $_SERVER[PHP_SELF]"); echo substr(time(),-2,2); My point is, just as in IE, my iframe shouldnt freeze refreshing even if a file is being uploaded. Any code/functions? The problem is taking place in Firefox. Please help. Thank you. Trying to create a simple login page (and my code is embarassingly disgraceful at this point). In simple terms, I have start_session on three pages. The first page asks for name, the second for password, the third welcomes user. The second page contains $name=$POST['name']; $_SESSION['name']= $name; When I access the page 2, the name is echoed with a greeting and request for password. But after a password submission (whether correct or incorrect) the $name disappears. I am at a loss for why it is not being refreshed or maintained in the session. Any ideas for me? Hi, In the following code I'm using a combo box to select a relay and activate it. The code works but if I refresh the page, the last selected relay is activated again. How can I reset the page to default to value '0' which has no relay control? TIA
<!DOCTYPE html> <html> <head> <title>Relay control</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h2><center>Status y control de relés</center></h2> <?php $arrleds = array(); if ($_SERVER["REQUEST_METHOD"] == "POST") { $selected_val = $_POST['sel']; if ($selected_val == '1'){ $cmd = exec("sudo ./trigger.py b 0"); } elseif ($selected_val == '2'){ $cmd = exec("sudo ./trigger.py b 1"); } elseif ($selected_val == '3'){ $cmd = exec("sudo ./trigger.py b 2"); } .... else {} } ?> <table class="center"> <tr> <td></td> <td><h1>Activación de relé</h1> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post"> <select name='sel' onchange='submit();'> <option value='0'>Sin activar</option> <!-- no action --> <option value='1'>Secadora 1</option> <option value='2'>Secadora 2</option> <option value='3'>Lavadora S</option> .... </select> </form> </td> <td></td> </tr> <tr> <td></td> <td><a href="index.php">Home</a> <td></td> </tr> </table> </body> </html>
Hi I made a simple chat script with pagination in MySQL (yes I know I should change to MySQLi) but just bare with me please My script is working fine when I post messages, but I have a problem.. Each time I refresh my page my previous message gets reposted again. Is there maybe a way I can fix this problem?
<html> <?php define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); // database connection info $conn = mysql_connect('****','******','*****') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('*****'',$conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // INSERT INTO DATABASE $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_USERID_R"]; $msg = $_POST['message']; $time = date("U"); $mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"]; if(!isset($mxitid, $name )) { $mxitid = "DEFAULT"; $name = "SYSOP"; } $sqli = "INSERT INTO StringyChat (StringyChat_ip, StringyChat_name, StringyChat_message, StringyChat_time, mxit_id) VALUES ('$ip', '$name', '$msg', '$time', '$mxitid')"; $result = mysql_query($sqli, $conn) or trigger_error("SQL", E_USER_ERROR); // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />'; } // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> // FORM <body> <form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <br> <input type="hidden" name="name" class="StringyChatFrm" value="<?php $name ?>" size="20" > <br> <i>Type your Message here...</i>:<br> <textarea name="message" class="StringyChatFrm" cols="20" rows="4"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </body> </html> Hi all. I've seen on facebook and on some other sites where content refreshes without complete page reloads. for example, right after posting a comment to a database, without any discernible page change, the comment appears somewhere on the page. Is it using php vars and some auto refresh function, (how does it, without reloading appear then?) I know that I am not very clear, but I need to know how to achieve this. If you like to help me, please look at the attachments. They depict the process which I dearly want to know of. Thank you for reading, and thanks in advance for trying to help. Thauwa. Sorry if this is in the incorrect section, but I suspect php activity here. |