learnAjax Posted November 20, 2007 Share Posted November 20, 2007 Hello Everybody, I'm new to Ajax/Web development. Just got a new project and descided to learn php and ajax. Here is the problem i'm having. I'm having problems with data refresh. I use form to get input from the user and then insert it using PHP into database and then return via ajax to my main view where user can search database. But when i try to look up information i just inserted it comes out empty. But if I clear my IE cach and then do lookup, information is getting displayed. Can somebody please tell me how to correctly insert data into database and then withough refresh (ajax) pull that information back to the page. Here is my code: <html> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var hostname = document.getElementById('hostname').value; var alias = document.getElementById('alias').value; var date = document.getElementById('date').value; var app = document.getElementById('app').value; var queryString = "?hostname=" + hostname + "&alias=" + alias + "&date=" + date +"&app=" + app; ajaxRequest.open("GET", "sa_report.php" + queryString, true); ajaxRequest.send(null); } function ajaxFunction2(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var radio = document.getElementsByName('mychoice'); for (i=0;i<radio.length;i++){ if(radio.checked){ var user_input = radio.value; } } //var get_detail = 1; //var queryString = "?crashid=" + get_detail; var queryString = "?crashid=" + user_input; ajaxRequest.open("GET", "sa_get_detail.php" + queryString, true); ajaxRequest.send(null); } function ajaxFunction3(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var radio = document.getElementsByName('mychoice'); for (i=0;i<radio.length;i++){ if(radio.checked){ var user_input = radio.value; } } var queryString = "?crashid=" + user_input; ajaxRequest.open("GET", "sa_modify_report.php" + queryString, true); ajaxRequest.send(null); } function ajaxFunction_save(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var crashID = document.getElementById('crashID').value; var APP = document.getElementById('APP').value; var CLASS = document.getElementById('CLASS').value; var sun_ticket = document.getElementById('sun_ticket').value; var mtech_ticket = document.getElementById('mtech_ticket').value; var hp_ticket = document.getElementById('hp_ticket').value; var mss_ticket = document.getElementById('mss_ticket').value; var verit_ticket = document.getElementById('verit_ticket').value; var dts_ticket = document.getElementById('dts_ticket').value; var nixeng_ticket = document.getElementById('nixeng_ticket').value; var sun_resolution = document.getElementById('sun_resolution').value; var mtech_resolution = document.getElementById('mtech_resolution').value; var hp_resolution = document.getElementById('hp_resolution').value; var mss_resolution = document.getElementById('mss_resolution').value; var verit_resolution = document.getElementById('verit_resolution').value; var dts_resolution = document.getElementById('dts_resolution').value; var nixeng_resolution = document.getElementById('nixeng_resolution').value; var queryString = "?APP=" + APP + "&CLASS=" + CLASS + "&sun_ticket=" + sun_ticket + "&mtech_ticket=" + mtech_ticket + "&hp_ticket=" + hp_ticket + "&mss_ticket=" + mss_ticket + "&verit_ticket=" + verit_ticket + "&dts_ticket=" + dts_ticket + "&nixeng_ticket=" + nixeng_ticket + "&sun_resolution=" + sun_resolution + "&mtech_resolution" + mtech_resolution + "&hp_resolution" + hp_resolution + "&mss_resolution=" + mss_resolution + "&verit_resolution=" + verit_resolution + "&dts_resolution=" + dts_resolution + "&nixeng_resolution=" + nixeng_resolution + "&crashID=" + crashID; ajaxRequest.open("GET", "sa_save_report.php" + queryString, true); ajaxRequest.send(null); } //--> </script> <center><h1> Crash Check Report </h1></center> <hr> <form name='crashForm'> <table> <tr> <td>HostName:</td> <td><input type='text' id='hostname' /> </td> </tr> <tr> <td>Alias:</td> <td><input type='text' id='alias' /> </td> </tr> <tr> <td>Date:</td> <td><input type='text' id='date' /> </td> </tr> <tr> <td>Application:</td> <td><select id='app'> <option></option> <option value='AMM'>AMM</option> <option value='QSA'>QSA</option> <option value='RAM'>RAM</option> <option value='STA'>STA</option> <option value='UNITY'>UNITY</option> </select> </td> <td></td> <td></td> </tr> <tr> <td></td><td></td><td><td><input type='button' onclick='ajaxFunction()' value='Display' /></td> <td></td<td></td><td></td><td><small><i>*Blank Fields will display all info from Crash Database</i></small></td> </tr> </table> </form> <hr> <div id='ajaxDiv'><b>Your result will be displayed below:</b></div> </form> </body> </html> -------------------------------------------------------------------------------------------------------------- sa_modify_report.php <?php $dbhost = "localhost"; $dbuser = "crash"; $dbpass = "crashmerrill"; $dbname = "equity_crash"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $crashid = $_GET['crashid']; // Escape User Input to help prevent SQL Injection $crashid = mysql_real_escape_string($crashid); #echo "Hello"; $query = "select * from crash_detail,server_crash_data where crash_detail.crashID = server_crash_data.crashID and server_crash_data.crashID='$crashid' and crash_detail.crashID = '$crashid'"; //Execute query $qry_result = mysql_query($query) or die(mysql_error()); $check = mysql_fetch_array($qry_result); if ($check[crashID]){ $qry_result = mysql_query($query) or die(mysql_error()); } else { $query = "select * from server_crash_data where crashID = '$crashid'"; $qry_result = mysql_query($query) or die(mysql_error()); } //Build Result String $display_string = "<table width='100%' align='center'>"; $display_string .= "<tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Ticket ID:</b> $row[ticketID]</td>"; $display_string .= "<td align='left'><b>Crash Date:</b> $row[Date]</td>"; $display_string .= "<td align='left'><b>Application:</b> <input type='input' value='$row[APP]' id='APP' size=10 /></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Crash ID:</b> <input type='input' value='$row[crashID]' id='crashID' size=3 /></td>"; $display_string .= "<td align='left'><b>Crash Time:</b> $row[Time]</td>"; $display_string .= "<td align='left'><b>Host Class:</b> <input type='input' value='$row[CLASS]' id='CLASS' size=10 /></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><br></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Pysical_Name:</b> $row[Physical_Name]</td>"; $display_string .= "<td align='left'><b>Service Groups:</b> $row[service_groups]</td>"; $display_string .= "<td align='left'><b>Alias:</b> $row[Alias]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Sun Ticket:</b><br><input type='input' value='$row[sun_ticket]' id='sun_ticket' size=10 /></td>"; $display_string .= "<td align='left'><b>MainTech Ticket:</b><br><input type='input' value='$row[mtech_ticket]' id='mtech_ticket' size=10 /></td>"; $display_string .= "<td align='left'><b>HP Ticket:</b><br><input type='input' value='$row[hp_ticket]' id='hp_ticket' size=10 /></td>"; $display_string .= "<td align='left'><b>MSS Ticket:</b><br><input type='input' value='$row[mss_ticket]' id='mss_ticket' size=10 /></td>"; $display_string .= "<td align='left'><b>Veritas Ticket:</b><br><input type='input' value='$row[verit_ticket]' id='verit_ticket' size=10 /></td>"; $display_string .= "<td align='left'><b>DTS Ticket:</b><br><input type='input' value='$row[dts_ticket]' id='dts_ticket' size=10 /></td>"; $display_string .= "<td align='left'><b>NIXeng Ticket:</b><br><input type='input' value='$row[nixeng_ticket]' id='nixeng_ticket' size=10 /></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><br></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "</table>"; $display_string .= "<table width='100%' align='center'>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Sun Resolution:</b><br><textarea cols='60' rows='5' id='run_resolution' name='sun_resolution'>$row[sun_resolution]</textarea></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>MainTech Resolution:</b><br><textarea cols='60' rows='5' id='mtech_resolution' name='mtech_resolution'>$row[mtech_resolution]</textarea></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>HP Resolution:</b><br><textarea cols='60' rows='5' id='hp_resolution' name='hp_resolution'>$row[hp_resolution]</textarea></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>MSS Resolution:</b><br><textarea cols='60' rows='5' id='mss_resolution' name='mss_resolution'>$row[mss_resolution]</textarea></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Veritas Resolution:</b><br><textarea cols='60' rows='5' id='verit_resolution' name='verit_resolution'>$row[verit_resolution]</textarea></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>DTS Resolution:</b><br><textarea cols='60' rows='5' id='dts_resolution' name='dts_resolution'>$row[dts_resolution]</textarea></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>NIXENG Resolution:</b><br><textarea cols='60' rows='5' id='nixeng_resolution' name='nixeng_resolution'>$row[nixeng_resolution]</textarea></td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; $display_string .= "<br><br>"; $display_string .= "<table width='100%' align='center'>"; $display_string .= "<tr>"; $display_string .= "<td align='center'><input type='button' onclick='ajaxFunction_save()' value='Save'/>"; $display_string .= " <input type='button' onclick='ajaxFunction()' value='Back'/>"; $display_string .= "</tr>"; $display_string .= "</table>"; #Uncomment below for Debuging Select Statement #echo "Query: " . $query . "<br />"; echo $display_string; ?> ------------------------------------------------------------------------------------------------------------------- sa_save_report.php <?php $dbhost = "localhost"; $dbuser = "crash"; $dbpass = "crashmerrill"; $dbname = "equity_crash"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $crashID = $_GET['crashID']; $app = $_GET['APP']; $class = $_GET['CLASS']; $mtech_ticket = $_GET['mtech_ticket']; $hp_ticket = $_GET['hp_ticket']; $mss_ticket = $_GET['mss_ticket']; $verit_ticket = $_GET['verit_ticket']; $dts_ticket = $_GET['dts_ticket']; $nixeng_ticket = $_GET['nixeng_ticket']; $sun_resolution = $_GET['sun_resolution']; $mtech_resolution = $_GET['mtech_resolution']; $hp_resolution = $_GET['hp_resolution']; $mss_resolution = $_GET['mss_resolution']; $verit_resolution = $_GET['verit_resolution']; $dts_resolution = $_GET['dts_resolution']; $nixeng_resolution = $_GET['nixeng_resolution']; // Escape User Input to help prevent SQL Injection $hostname = mysql_real_escape_string($hostname); $alias = mysql_real_escape_string($alias); $date = mysql_real_escape_string($date); $application = mysql_real_escape_string($application); #echo "Hello"; $query = "INSERT INTO crash_detail (crashID,mtech_ticket,hp_ticket,mss_ticket,verit_ticket,dts_ticket,nixeng_ticket,sun_resolution,mtech_resolution,hp_resolution,mss_resolution,verit_resolution,dts_resolution,nixeng_resolution) VALUES ('$crashID','$mtech_ticket','$hp_ticket','$mss_ticket','$verit_ticket','$dts_ticket','$nixeng_ticket',('$sun_resolution'),('$mtech_resolution'),('$hp_resolution'),('$mss_resolution'),('$verit_resolution'),('$dts_resolution'),('$nixeng_resolution'))"; echo $query; mysql_query($query) or die(mysql_error()); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die('Error, insert query failed'); echo "<h1> Database Updated! </h1>" ?> --------------------------------------------------------------------------- sa_get_detail.php <?php $dbhost = "localhost"; $dbuser = "crash"; $dbpass = "crashmerrill"; $dbname = "equity_crash"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $crashid = $_GET['crashid']; // Escape User Input to help prevent SQL Injection $crashid = mysql_real_escape_string($crashid); #echo "Hello"; $query = "select * from crash_detail,server_crash_data where crash_detail.crashID = server_crash_data.crashID and server_crash_data.crashID='$crashid' and crash_detail.crashID = '$crashid'"; //Execute query $qry_result = mysql_query($query) or die(mysql_error()); //Build Result String $display_string = "<table width='100%' align='center'>"; $display_string .= "<tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Ticket ID:</b> $row[crashID]</td>"; $display_string .= "<td align='left'><b>Crash Date:</b> $row[Date]</td>"; $display_string .= "<td align='left'><b>Application:</b> $row[APP]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Crash ID:</b> $row[crashID]</td>"; $display_string .= "<td align='left'><b>Crash Time:</b> $row[Time]</td>"; $display_string .= "<td align='left'><b>Host Class:</b> $row[CLASS]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><br></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Pysical_Name:</b> $row[Physical_Name]</td>"; $display_string .= "<td align='left'><b>Service Groups:</b> $row[service_groups]</td>"; $display_string .= "<td align='left'><b>Alias:</b> $row[Alias]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Sun Ticket:</b><br>$row[sun_ticket]</td>"; $display_string .= "<td align='left'><b>MainTech Ticket:</b><br>$row[mtech_ticket]</td>"; $display_string .= "<td align='left'><b>HP Ticket:</b><br>$row[hp_ticket]</td>"; $display_string .= "<td align='left'><b>MSS Ticket:</b><br>$row[mss_ticket]</td>"; $display_string .= "<td align='left'><b>Veritas Ticket:</b><br>$row[verit_ticket]</td>"; $display_string .= "<td align='left'><b>DTS Ticket:</b><br>$row[dts_ticket]</td>"; $display_string .= "<td align='left'><b>NIXeng Ticket:</b><br>$row[nixeng_ticket]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><br></td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Sun Resolution:</b> $row[sun_resolution]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>MainTech Resolution:</b> $row[mtech_resolution]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>HP Resolution:</b> $row[hp_resolution]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>MSS Resolution:</b> $row[mss_resolution]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>Veritas Resolution:</b> $row[verit_resolution]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>DTS Resolution:</b> $row[dts_resolution]</td>"; $display_string .= "</tr>"; $display_string .= "<tr>"; $display_string .= "<td align='left'><b>NIXENG Resolution:</b> $row[nixeng_resolution]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; $display_string .= "<br><br>"; $display_string .= "<table width='100%' align='center'>"; $display_string .= "<tr>"; $display_string .= "<td align='center'><input type='button' onclick='ajaxFunction()' value='Back'/>"; $display_string .= "</tr>"; $display_string .= "</table>"; #Uncomment below for Debuging Select Statement #echo "Query: " . $query . "<br />"; echo $display_string; ?> ------------------------------------------------------------------------------ sa_report.php <?php $dbhost = "localhost"; $dbuser = "crash"; $dbpass = "crashmerrill"; $dbname = "equity_crash"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $hostname = $_GET['hostname']; $alias = $_GET['alias']; $date = $_GET['date']; $application = $_GET['app']; // Escape User Input to help prevent SQL Injection $hostname = mysql_real_escape_string($hostname); $alias = mysql_real_escape_string($alias); $date = mysql_real_escape_string($date); $application = mysql_real_escape_string($application); #echo "Hello"; $query = "SELECT * FROM server_crash_data"; if( $hostname ){ $query .= " WHERE Physical_Name='$hostname'"; } //$query = "SELECT * FROM server_crash_data WHERE Physical_Name='$hostname'"; if($alias != ""){ if ( ereg('WHERE', $query) ){ $query .= " AND Alias='$alias'"; } else{ $query .= " WHERE Alias='$alias'"; } } if($date != ""){ if ( ereg('WHERE', $query) ){ $query .= " AND Date='$date'"; } else{ $query .= " WHERE Date='$date'"; } } if($application != ""){ if ( ereg('WHERE', $query) ){ $query .= " AND APP='$application'"; } else{ $query .= " WHERE APP='$application'"; } } //Execute query $qry_result = mysql_query($query) or die(mysql_error()); //Build Result String $display_string = "<form name='return'>"; $display_string .= "<table width='100%' align='center'>"; $display_string .= "<tr>"; $display_string .= "<th align='center'></th>"; $display_string .= "<th align='center'><u>crashID</u></th>"; $display_string .= "<th align='center'><u>Hostname</u></th>"; $display_string .= "<th align='center'><u>Service Groups</u></th>"; $display_string .= "<th align='center'><u>Alias</u></th>"; $display_string .= "<th align='center'><u>Date</u></th>"; $display_string .= "<th align='center'><u>Time</u></th>"; $display_string .= "<th align='center'><u>Application</u></th>"; $display_string .= "<th align='center'><u>Class</u></th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td align='center'><input type='radio' name='mychoice' value='$row[crashID]'></td>"; $display_string .= "<td align='center'>$row[crashID]</td>"; $display_string .= "<td align='center'>$row[Physical_Name]</td>"; $display_string .= "<td align='center'>$row[service_groups]</td>"; $display_string .= "<td align='center'>$row[Alias]</td>"; $display_string .= "<td align='center'>$row[Date]</td>"; $display_string .= "<td align='center'>$row[Time]</td>"; $display_string .= "<td align='center'>$row[APP]</td>"; $display_string .= "<td align='center'>$row[CLASS]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; $display_string .= "<br><br>"; $display_string .= "<table width='100%' align='center'>"; $display_string .= "<tr>"; $display_string .= "<td align='center'><input id=radio_view type='button' onclick='ajaxFunction2()' value='View Report'/>"; $display_string .= " <input id=radio_view type='button' onclick='ajaxFunction3()' value='Modify Report'/></td>"; $display_string .= "</tr>"; $display_string .= "</table>"; $display_string .= "</forum>"; #Uncomment below for Debuging Select Statement #echo "Query: " . $query . "<br />"; echo $display_string; ?> Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted November 20, 2007 Share Posted November 20, 2007 I'm not going to bother reading all that code as: 1) It's not in [ code ] tags and 2) There's way too much of it. But here are a couple of suggestions. Are you 100% positive it is the browser's cache that is causing the problem? If you are, you can probably use a call to header() to tell the browser to never cache that URL. Also, when you use AJAX to query the database, is your PHP script returning [X]HTML or JSON? If you are returning [X]HTML I would advise that you look into JSON. JSON stands for Javascript Object Notation. It is much, much more convenient for returning data in AJAX requests. Quote Link to comment Share on other sites More sharing options...
learnAjax Posted November 20, 2007 Author Share Posted November 20, 2007 Thanx for a quick reply and sorry about all that code. I'm pretty sure it's cashe issue and would like to try setting header() to disable cacheing. If that doesn't work i'll look into JSON. BTW how and where do i set up header()? Thanx again. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted November 20, 2007 Share Posted November 20, 2007 header() is a PHP function that allows you to set the headers sent to the browser. I don't know which header, but there is one that controls the browsers ability to cache a page. You might look through the PHP help forums for header questions, or google or wikipedia. As an example, if I wanted to redirect the user's browser to a new URL from PHP I could do this: <?php header('Location: http://www.yahoo.com'); exit(); ?> That code in any PHP script will send the user to yahoo's home page. I know this is irrelevant to what you want to accomplish, I was just giving an example of how the function is used. Instead of Location:, you need to supply the parameter that controls the browser cache. Instead of the URL you need to provide a different value that says, "Don't cache this page." Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.