Jump to content

jackpf

Members
  • Posts

    1,410
  • Joined

  • Last visited

    Never

Everything posted by jackpf

  1. No problem JUST REALISED! $browser = strtolower($_SERVER['HTTP_USER_AGENT']); if(ereg('msie', $browser)) { echo 'You are using ie'; } else if(ereg('firefox', $browser)) { echo 'You are using ff'; } That will work. I forgot to set the string to check for the ereg in firefox Duhh
  2. Yeah, it's quite a good way of going about it really. So simple I never though of it
  3. I have no idea, but I'll try the mysql method tbh
  4. jackpf

    Login

    hey, try this. I just swapped a few things round and removed some unescesary stuff Also, if data.php sends anything to the page, it could prevent your headers from being set. <?php include_once('data.php'); ob_start(); session_start(); if(isset($_POST['submit'])) { // username and password sent from form $username=$_POST['username']; $password=$_POST['password']; $password = md5($_POST['password']); $sql=mysql_query("SELECT * FROM `pilots` WHERE `username`='$username' AND `password`='$enc' AND `admin`='yes'"); $omg = mysql_num_rows($sql); if($omg != 0) { $_SESSION['username'] = $username; $_SESSION['password'] = $password; header ('Location: successadm.php'); mysql_close($connection); } else { echo "Wrong Username/Password"; }} else { echo '<center> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <div> <br /> <label for="txtusername">Username:</label> <input type="text" name="username" value="" title="Text input: Username" id="txtusername" maxlength="20" /> </div> <div> <label for="txtpassword"> Password:</label> <input type="password" name="password" title="Text input: Password" id="txtpassword" maxlength="20" /> </div> <br /> <div> <input type="submit" name="submit" value="Login" /> <input type="submit" name="ResetButton" title="Reset button: Login" id="btnReset" value="Clear" class="button" /> <br /> </div> </fieldset> </form> <font color="red">'; } ?> I assume that your mysql connection is being made in data.php?
  5. Thanks for the response. Yeah...sessions...I did a quick google on how to get session data, so I could see if the sessions still exist, but couldn't really find a straight answer. Is this even possible? I think the second approach sounds like a good idea. I could make a function which checks if they're online, something like this- mysql_connect....etc $status = $fetch['status']; //status being the unix stamp of the last time they visited a page if($status + 1200 <= time()) { $online = 'false'; } else { online = 'true'; } I think I'll go with that, unles anyone has any more suggestion?
  6. You'd have to use cookies whichever way you do it. If it were me, I'd require users to log in each time they purchase something. Then, when they add something to their cart, store the ID of the item in an encrypted cookie, and when they go to the checkout, you can grab the ID(s) from the cookie, and get the corresponding item(s) from the database.
  7. Hi all, To determine who is online on my site, I have a "status" column in my users table, which is updated when users log on/off. However, if people simply close the window/browser, then my site thinks they're still online. I was just wondering if there's a better way to go about this. Thanks, Jack.
  8. Yeah, ajax is basically just a way of communicating with the server without reloading the page, by http requests. You definitely need knowledge of javascript and some server side programming like php or asp(crap).
  9. You can use rewrite rules with apache in your htaccess file to make something look like this forum/reading/how-to-read be processed by this forum.php?sub=reading&id=2355
  10. Just to let you know- the title of the "Advanced Tutorials" nav link is "Advaned Tutorials" You might want to fix that
  11. This code will get you the browser- $browser = strtolower($_SERVER['HTTP_USER_AGENT']); if(ereg('msie', $browser)) { echo 'You are using ie'; } else if(ereg('firefox')) { echo 'You are using ff'; } Enjoy.
  12. Hi all, Just wondering, is there a way to use preg_replace() to replace tags which aren't closed in the right order? For example- If someone were to have [colour=red]red[colour=blue]blue[/colour][/colour] I've noticed that preg_replace() can't handle it, and cuts out one of the tags... Thanks for any help, Jack.
  13. <?php function str_trim($str) { echo substr($str, 0, 5); } ?> Tbh, a google search would have given you what you need.
  14. PHP is parsed before it is sent to the page, so unless you use AJAX, you can't parse it without refreshing the page. It'd probably be quite easy with AJAX tbh, something like each nav link sends a variable to the server via httpRequest, eg. page=music, and your index file can return the respective page. Hope this helps...
  15. Thats supposed to have a colour=blue tage where it goes blue btw
  16. Hi all, Just wondering, is there a way to use preg_replace() to replace tags which aren't closed in the right order? For example- If someone were to have [colour=red]redblue[/colour][/colour] I've noticed that preg_replace() can't handle it, and cuts out one of the tags... Thanks for any help, Jack.
  17. He's not actually inserting anything into a database, as was pointed out to me before. Why have you got them spaces in $_POST[" blah"]? You could try taking them out, they're not supposed to be there.
  18. Ahh. I didn't actually read the code properly, I thought he was inserting something into a database. My bad, I should pay more attention
  19. addslashes may be turned off when posting/getting in your PHP config? Try putting addslashes() round each of your posts and see what that does...
  20. No, the index file is put there to be displayed by default. The only time you get directory listings is when there is no index, and it's turned on in apache/iis.
  21. No problem.
  22. What do you mean you can't change the width? Do you want to post a link to your site so I could have a look?
  23. I think I know why this is- you need to define all variables for a function when calling it. eg- function foo() { connect('localhost', 'user', 'pass'); #...rest of function... } Functions don't reference global variables. Well, I don't think they do. Hope this helps. Jack.
  24. AJAX could do it
  25. Couldn't you just use javascript? I have someting similiar to this on my site. onmouseover="this.className='new_css_element';" onmouseout="this.className=""
×
×
  • 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.