Jump to content

scuff

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Everything posted by scuff

  1. Wow thanks! I simplified it to this to fit my needs <?php if ($_POST['delete']) { $stringData = "delete <br>"; $ourFileName = "directlink.php"; $ourFileHandle = fopen($ourFileName, 'a'); fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); } ?> <html> <head> <script language="javascript" type="text/javascript"> function commencer() { setInterval(ajaxFunction2, 1000); } function ajaxObj() { try { return new XMLHttpRequest(); } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} alert("XMLHttpRequest not supported"); return null; } function ajaxFunction2(){ ajaxRequest2 = new ajaxObj; var params = "delete=1"; ajaxRequest2.open('POST', 'test.php', true); ajaxRequest2.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajaxRequest2.setRequestHeader("Content-length", params.length); ajaxRequest2.setRequestHeader("Connection", "close"); ajaxRequest2.send(params); } </script> </head> <body onLoad="commencer()"> </body> </html> Thanks once again
  2. oh yea I have that on and there are no errors
  3. What does that mean? Are there any errors? If not do you have display_errors turned on? Try: <?php if (isset($_POST['delete'])) { I was talking about how I didn't notice that the javascript wasn't in the <head> I don't think there are any errors because when the page loads it doesn't say anything at the bottom, and I don't know how to check if display_errors is turned on. BTW <?php if (isset($_POST['delete'])) { doesn't work either
  4. If somebody could play around with it until it works then post code that would help D: I know it's lazy but do what you want
  5. <?php if ($_POST['delete']) { $stringData = "delete"; $ourFileName = "directlink.php"; $ourFileHandle = fopen($ourFileName, 'w'); fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); } ?> <head> <script language="javascript" type="text/javascript"> function commencer() { setInterval(ajaxFunction2, 1000); } function ajaxFunction2(){ var ajaxRequest2; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest2 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest2 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest2 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } ajaxRequest2.open('POST', 'testing.php'); var title = document.getElementById('delete').value; ajaxRequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ajaxRequest2.setRequestHeader('Content-length', title.length); ajaxRequest2.send(title); } </script> </head> <body onLoad="commencer()"> <input type="text" name="delete" id="delete" value="delete"> </body> I didn't even notice that but either way it's still not working..
  6. ajaxRequest2.open('POST', 'testing.php'); var title = document.getElementById('delete').value; ajaxRequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ajaxRequest2.setRequestHeader('Content-length', title.length); ajaxRequest2.send(title); I inserted this instead of ajaxRequest2.open('POST', 'testing.php'); ajaxRequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); var title = document.getElementById('delete').value; ajaxRequest2.send(title); and it still didn't work
  7. testing.php <?php if ($_POST['delete']) { $stringData = "delete"; $ourFileName = "directlink.php"; $ourFileHandle = fopen($ourFileName, 'w'); fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); } ?> <body onLoad="commencer()"> <script language="javascript" type="text/javascript"> function commencer() { setInterval(ajaxFunction2, 1000); } function ajaxFunction2(){ var ajaxRequest2; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest2 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest2 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest2 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } ajaxRequest2.open('POST', 'testing.php'); ajaxRequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); var title = document.getElementById('delete').value; ajaxRequest2.send(title); } </script> <input type="text" name="delete" id="delete" value="delete"> </body> I'm trying to make a form send every second without refreshing and basically clear another file. I can't get it to work does anyone see what I'm doing wrong? (probably many things because I'm testing)
  8. It's going to reload like a chatboard so it really does need to refresh alot... but even if I do <br> it bugs the script and doesn't sense if it has changed or not (I'm aware it only detects if the text has changed but it doesn't in this case for some reason) it seems the < and >s are bugged in this. Do you know why and could you tell me how to overcome this? BTW this is not neccessary it just seems that it would make it less laggy if it were to only update when the content changes. Thanks
  9. serverTime.php's code is <img src='logo.gif'> that's it (I think the <>s are messing it up)
  10. I found out that if you put in the serverTime.php this: <img src="anypic.jpg"> it wouldn't work, not sure if it's because innerHTML doesn't accept it or if I need to do something differently. Please help if you can.
  11. I tested with simpler text in the file and it worked, so I need to find out why it stops sometimes. thanks! (sorry)
  12. <html> <body onLoad="commencer()"> <script language="javascript" type="text/javascript"> <!-- function commencer() { setInterval(ajaxFunction, 1000); } //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){ document.getElementById('test').innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("POST", "serverTime.php", true); ajaxRequest.send(null); } //--> </script> <div id="test" name="test"> </div> </body> </html> Btw in serverTime.php the code is: <?php echo date("H:i:s"); ?> I'm just wondering if it's possible to only use document.getElementById('test').innerHTML = ajaxRequest.responseText; if the content of ajaxRequest.responseText has changed? I imagine it would be something like this: (this doesn't work) ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ if (document.getElementById('test').innerHTML == ajaxRequest.responseText) { }else{ document.getElementById('test').innerHTML = ajaxRequest.responseText; } } Please help thanks!
  13. Nvm I think I solved it by changing GET to POST
  14. I found a code to try Ajax out and I edited it to reload every second, it works fine on my computer but when I tried it out on another computer it didn't work... Here is the code. <html> <body onLoad="commencer()"> <script language="javascript" type="text/javascript"> <!-- function commencer() { setInterval(ajaxFunction, 1000); } //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){ document.getElementById('test').innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "serverTime.php", true); ajaxRequest.send(null); } //--> </script> <div id="test" name="test"> </div> </body> </html> I'm not sure why it isn't working seeing as the computer I tested it on was using the same internet as I (in windows xp) and I tested it on Vista and it wasn't working either.. But on Firefox it works on any computer. Btw in serverTime.php the code is: <?php echo date("H:i:s"); ?> Can somebody please tell me why it only works on my computer?
  15. it won't work if the session destroy isn't in the <?php ?> tags, but it might not work even if you put them in because it would just destroy the session even before unload because php loads before javascript, plus I think the session automatically destroys itself once the page is unloaded (not sure)
  16. You could use javascript like <?php echo " <script> onunload=function() { session_destroy(); } </script> <body onUnload='onunload()'>"; ?> something like that, but it doesn't always work
  17. Okay, I'm creating a login and I want to create a whitelist for characters allowed in their account name instead of using a blacklist to block every single alt code etc... So I was looking online and I found this: if(preg_match("/[A-Za-z0-9]/",$string)) { echo "The string '$string' contains only letters and numbers"; } But it only returns false if the string is like "#######" and it returns true if it's "fdsdfs#f" is there a way to return true even if there is only one wrong character? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.