Jump to content

The Bat

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by The Bat

  1. Using your code, the 'Loading..' text appears and disappears very quickly between showing 'not found', but doesn't show anything while loading the image. Why is this?
  2. Hello, I am just recently getting into Ajax, and I am wondering how to add a loading status to my script. I tried adding: if (xmlhttp.readystate == 3) { document.getElementById('ok').innerHTML = 'Loading...'; } to my ajax.html page in the script below, but it did not show up when ajax.html was loading a big image. Here is my Ajax script and PHP script: ajax.html <script type="text/javascript"> function ajax() { var xmlhttp; if (window.ActiveXObject) { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } else { xmlhttp = new XMLHttpRequest(); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 3) { document.getElementById('ok').innerHTML = 'Loading...'; } if (xmlhttp.readyState == 4) { document.getElementById('ok').innerHTML = xmlhttp.responseText; } } xmlhttp.open('GET', 'ajax.php?q='+document.myForm.name.value, true); xmlhttp.send(null); } </script> <form name="myForm"> Name: <input type="text" name="name" onkeyup="ajax()" /> </form><p> <div id="ok"></div> ajax.php <?php $userQuery = mysql_query("SELECT username FROM users WHERE username='".$_GET['q']."'"); if ($_GET['q']) { if (mysql_num_rows($userQuery) > 0) { // Trying to show 'Loading...' when loading a big image. echo '<img src="bigimageURL">'; } else { echo '<font color="red">not found.</font>'; } } ?> Thank you for your help!
  3. To give you a rough outline of what you can do, first you can create a field in the specified table called 'allow_free_mp3' (or whatever you want) and on myaudio.php, have a form with 'yes' or 'no' options and have that inserted into the field: myaudio.php <form action="myaudio.php" method="post"> Allow free MP3s to be downloaded? <select name="allowfree"> <option value="yes">Yes</option> <option value="no">No</option> </select> <input name="update" type="submit" value="Update" /> </form> <?php if ($_POST['update']) { // Connect to your database. mysql_query('INSERT INTO table_name (allow_free_mp3) VALUES ('.$_POST['allowfree'].')') or die (mysql_error()); } ?> listen.php <?php $allowquery = mysql_query('SELECT allow_free_mp3 FROM table_name /* Specify WHERE options */'); $row = mysql_fetch_array($allowquery); if ($row['allow_free_mp3'] == 'yes') { // Your code when free MP3 downloading is allowed. } else { // Your code when free MP3 downloading is NOT allowed. } ?> It isn't that great, but it's a start. If you want to know about using MySQL with PHP, just searh Google.
  4. Say what? You can, using the 'time()-[specified seconds]' parameter in the setcookie() function.
  5. You could also possibly use $_GET. Link: <a href="yourpage.php?changevar=true">Change the variable!</a> Code on yourpage.php: $i = 1; if ($_GET['changevar'] == true) { $i = 2; // Other actions... }
  6. Is this what you want? - if (eregi("^www\.[a-z0-9_\-]+\.[a-z0-9_\-\.]+$", $url)) { // Code when accepted... } else { // Code when denied... }
×
×
  • 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.