Jump to content

GetPutDelete

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Posts posted by GetPutDelete

  1. Ok, you're trying to get the contents of a variable (URL variables are listed after the question mark (?) and separated by (&). To echo these variables use

     

    <?php
    
    echo $_GET['page'];
    
    ?>

     

    An example using multiple variables in the URL...

     

    (URL is http://example.com/?my_name=bob&fav_color=blue&age=23)

     

    <?php
    
    echo 'My name is ' . $_GET['my_name'] . ' my favourite color is ' . $_GET['fav_color'] . ' and I am ' . $_GET['age'] . ' years old.';
    
    ?>
    

     

    I hope that helps.

  2. For apostrophes when you insert the data to the database you should use mysql_real_escape_string() http://php.net/manual/en/function.mysql-real-escape-string.php This will add slashes to the quotes ' and " to make them database friendly, strings will then be displayed like (Hello, GetPutDelete\'s awesome!) Then when you output the string use stripslashes() http://php.net/manual/en/function.stripslashes.php to remove the slashes to output (Hello, GetPutDelete's awesome).

  3. Do you mean getting the user to login to their email through your site and then grabbing the contents of their address book?

     

    If so and you want to write it yourself then look no further than some IMAP classes, if you don't then I think I came across one a while back after a google search, but if I remember correctly they charged for their service. Personally I'd just write it myself.

  4. Here you go...

     

    <?php 
    
    if(isset($_POST['user']) && isset($_POST['vanaparool']) && isset($_POST['uusparool'])) {
    
    $username = $_POST['user'];
    $password = $_POST['vanaparool'];
    $password2 = $_POST['uusparool'];
    $con = mysql_connect("localhost","baasiksutaja","parool");
    
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    // vastus
    mysql_select_db(baasinimi);
    $uuendamine = mysql_query("SELECT * FROM testtable WHERE (username='$username' AND password='$password')");
    while($row = mysql_fetch_array($uuendamine)) {
    echo "Your " . $row['username'] . " password is updated!" ;
    }
    // uuendamine
    mysql_select_db(baasinimi);
    mysql_query("UPDATE testtable set password='$password2'");
    
    mysql_close($con);
    
    }
    
    ?>
    
        <form method="post" action="">
            <table width="80%" border="0" align="center" cellpadding="3" cellspacing="3" class="forms">
              <tr> 
                <td width="31%">Username:</td>
                <td width="69%"><input name="user" type="text" id="user"></td>
              </tr>
    	  <tr> 
                <td width="31%">Old password:</td>
                <td width="69%"><input name="vanaparool" type="password" id="vanaparool"></td>
              </tr>
              <tr> 
                <td>New password:</td>
                <td width="69%"><input name="uusparool" type="password" id="uusparool"></td>
              </tr>
            </table>
            <p align="center"> 
              <input name="uuenda" type="submit" id="uuenda" value="Update">
            </p>
    </form>
    

     

    The form now posts to itself. When the page loads again it checks for POST data and if there is some it runs the code to update the users details.

  5. No because all you need to do is have a cleanup script run each time a user loads the page. So the last user leaves and the chat is now empty, now when the next user comes on the script determines that he too hasn't been active for over 10 seconds and so removes him from the db. This all should happen prior to the page being displayed so that once the house keeping is complete the new user gets an accurate view of what's going on in the chat.

     

    Anyway that's enough PHPing for me tonight, good luck with your project.

  6. The problem you have though is getting the script to execute once the user has left the chat in order to delete the data from the db. Really the only way to be able to maintain accurate info on who is in chat and who is not is to use the ajax example I gave you.

     

    The problem with your last idea is that once the user has left no script has been executed in order to bring the db up to date.

  7. It's displaying the last result because the query is overwriting the variables each time, to get around this you could turn the variables into an array, for example $role[1] = bla, $position[1] = bla ect, then for the next row $role[2] = bla... ect.

     

    That way after the loop is finished you will have each row and its data assigned to an array.

×
×
  • 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.