Jump to content

lukerodham

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by lukerodham

  1. Awesome thank you, its worked but the date is incorrect, its showing a time and date from yesturday. but that ok i'll try and work out how to get the proper date. THANK YOU
  2. Sorry i thought i added that, what im looking for is 1 ip and its latest date. is this possible?
  3. hi, im trying to use the DISTINCT mysql command to select unique ip's that have visited my site, but im also trying to get the rest of the rows data aswell so i can output the date and time that they visited. i ran into the problem that i can output the ip but no date and time. but if i add the the 'date' in the query line i dont get a unique output as i believe the it looks for a DISTINCT ip and date then. i have the code below to help you understand a bit more. but could some please help me as i can get the right output. thanks. $unique_query = mysql_query("SELECT DISTINCT ip, date FROM ip ORDER BY date DESC LIMIT 10"); while($uniquerow = mysql_fetch_array($unique_query)){ echo "<table width='100%' border='0' align='center'> <tr> <td width='50%' align='center' valign='middle' class='aboutme'>".$uniquerow['ip']."</td> <td width='50%' align='center' valign='middle' class='aboutme'>".$uniquerow['date']."</td> </tr> </table>"; } this is the output atm.
  4. Hey guys for some reason the code below, will insert into the data the information required even if there is the same email address already registered, have i done something wrong? $query = mysql_query("SELECT * FROM users WHERE email=$email"); $count = mysql_num_rows($query); if($count==0){ mysql_query("INSERT INTO users VALUES(NULL,'$firstname','$lastname','$email','$password','$day','$month','$year','$sex')") or die(mysql_error()); echo "Well done. Passwords match"; } else { echo "Please use another email as this one is already registered."; }
  5. ive just looked at the file where the value is held and there is not whitespace in front of the value and no behind. i do have the comma there that is trimmed but thats it. could there be a problem with the file_get_contents action that i have written?
  6. hey guys thanks for the quick response. i thought that this would be the case im getting this error: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'localhost ' (11004) but i dont understand why.
  7. Hi, this is more of a question than asking for help so if its in the wrong section could someone please move. my question is could you connect to a database by using an array that has been generated from getting contents from a file, for example... $file_c = file_get_contents("example.txt"); $colms = explode(",",trim($file_c)); mysql_connect("$colms[0]","$colms[1]","$colms[2]") or die(mysql_error()); mysql_select_db("$colms[3]") or die(mysql_error()); if not how else would someone go about doing this.
  8. ok well what i was aiming for was to create a unique ip database, for a stats page and with the WHERE clause would i then just use the mysql_num_row function to check if there is already an entry for the $guestip. if you understand what i mean.
  9. Hey guys for some reason this code is not working i can't see a problem myself could someone please have a look and point the issue out to me. what i mean by it not working is it won't insert into the database or show a mysql_error. thanks in advance $guestip = $_SERVER['REMOTE_ADDR']; $time = date('G:i'); $date = date("y-m-d"); $query = mysql_query("SELECT * FROM IP_Address") or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ if($guestip != $row['ip']){ //insert into db. mysql_query("INSERT INTO IP_Address(id, ip, date, time) VALUES(NULL,'$questip','$date','$time')") or die(mysql_error()); echo "inserted in to database"; echo mysql_error(); }else{ // add hit count and update time and date. echo "already in db"; } }
  10. Hey guys just wondering if this piece of code is correct because i get a mysql error saying Duplicate entry '*********' for key 2 this is the code i have and table structure. $sql = " INSERT INTO `IP_Address` VALUES(NULL,'".$ip."','".$date."','".$time."') ON DUPLICATE KEY UPDATE `date` = `".$date."`, `time` = `".$time."` ";
  11. ok thank you very much been a great help with only a few words
  12. ok thanks for the quick reply, i dont mean to sounds dumb but how else would i go about achieving what im looking for?
  13. hey guys how you all doing? ok im really looking for some help i've been playing with this code for quite some time now and still not got the hang of it. i'm currently trying to code a dynamic website as a portfolio for my designs and im trying to get to view the news.php file with an 'id' to view in the index file using an include() but for some reason its not happening very well. i keep getting the error message: Warning: include(inc/news.php?id=) [function.include]: failed to open stream: No error in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 Warning: include() [function.include]: Failed opening 'inc/news.php?id=' for inclusion (include_path='.;C:\xampplite\php\PEAR') in C:\xampplite\htdocs\lukerodham\old\index.php on line 218 just wondering if anyone could shed any light on what i may have done wrong thanks guys ive left part of the code below if this will help. <?php $page = $_GET['page']; $news = $_GET['id']; if(!$page){ getnews(); } else { if($page = news){ include("inc/news.php?id=".$news); } else include("inc/".$page.".php"); } ?>
  14. hi guys me again. kinda stuck, im trying to turn my admin login script in to a user login with the admin side of things, so to keep things separate. for some reason the include function is not working after its checked, if the user is a admin or not. any ideas on why this would not work? have i done something completely wrong or just missing something. ive left the code below, if it helps aswell the login.php is a included file aswell to index.php. thanks in advance. login.php <?php $userback = $_SESSION['user']; $username = $_POST['username']; $password = md5($_POST['password']); $login = $_post['submit']; mysql_connect("db2700.oneandone.co.uk","dbo363845380","notgonnalie12"); mysql_select_db("db363845380") or die(mysql_error()); session_start(); if($_SERVER['QUERY_STRING'] == "logout") { unset($_SESSION['user']); header("Location: " . $_SERVER['PHP_SELF']); exit; } if(!isset($_SESSION['user'])){ if(!$submit){ echo"<div align='center'><b>Please login</b></div><br>"; echo " <html> <body> <div align='center'> <form method='post' action='".$_SERVER['REQUEST_URI']."'> <label>username: <input type='text' name='username' id='username'> <label>password: <input type='password' name='password' id='password'> </label> <label> <input type='submit' name='submit' id='submit' value='submit'> </label> </form> </div> </body> </html> "; } else { $rows = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($username)."' AND password='".mysql_real_escape_string($password)."'")); if($rows>0){ while ($row = mysql_fetch_assoc($rows)){ $_SESSION['user']="$username"; $adminpass = $row['admin']; if($adminpass>=1){ include ("admin/index.php"); } else { echo "welcome $user1 you'll be directed in a few seconds.<br> if this doesn't happen please click here."; } } } else { if($rows<1){ echo "Sorry no user information found. Please make sure details are correct."; } } } } ?>
  15. hmmm strange i echo'd it out and it saying post.php so i guess its working fine, this is the code for the post.php page which im trying to see, could you please tell me if have doing something wrong on there. thanks. <?php session_start(); if(isset($_SESSION['user'])){ echo " <h1>Post news</h1> <hr /> <form action='post.php' method='post'> Title:<br /><input type='text' name='title'> <p> Body:<br /><textarea rows='6' cols='35' name='body'></textarea><p> <input type='submit' name='post' value='post this'> </form> "; if ($_POST['post']){ $title = $_POST['title']; $body = $_POST['body']; if ($title&&$body){ mysql_connect("","",""); mysql_select_db("") or die(mysql_error()); $date = date("y-m-d"); $insert = mysql_query("INSERT INTO news VALUES ('','$title','$body','$date')") or die(mysql_error()); die("Your news has been posted."); } else echo "Please fill out title and body<p>"; } } else { die("Sorry you dont have access."); } ?>
  16. hey guys stuck on this one cant see why it wont work, hope someone can help. im trying to just change the content not the whole page while still only a admin can see it. if you get my jist. but everytime i click the link nothing shows up for some reason. thanks in advance. <?php session_start(); include("login.php"); ?> <html> <body> <?php if(isset($_SESSION['user'])){ ?> <table width='90%' height='100%' border='1' align='center'> <tr valign='top'> <td><table width='60%' border='0' align='center'> <tr> <td colspan='3' align='center'>You've succesfully logged in.<p></td> </tr> <tr> <td><a href='index.php?page=post.php'>post news</a></td> <td><a href='index.php?page=mail.php'>mailing list</a></td> <td><a href='index.php?page=stats.php'>site stats</a></td> <td><a href='login.php?logout'>logout</a></p></td> </tr> <tr> <td colspan='3'> <?php $page = $_GET['page']; if($page){ include("inc/".$page.".php"); } ?> </td> </tr> </table></td> </tr> </table> ?> <?php } else { die(); } ?> </body> </html>
  17. sorry to be a pain guys ive just edited the script with what you said , just one thing tho you can still see the admin stuff on index.php without login in is there a quick way around this?
  18. cheers guys i'll see what happens thank you much love...
  19. hi guys how you doing? i new here so take it easy on me . basically just need some quick help and i thought this would be the best place to ask. ive been working on a admin login script but cant seem to get it right, i mean i can login in with random passwords :/ and also everytime i go to the index.php it shows the information i dont want it without being logged in. ive got the script running live just incase anyone wants to see what i mean its at http://www.lukerodham.co.uk/admin heres the code. Thanks in advance. index.php <?php require_once("login.php"); $adminuser = $_SESSION['user']; ?> <html> <head> <title>hoonigans.co.uk</title> </head> <body> <h3 align="center">Welcome to the admin page.</h3> <span class="maintext"><br /> <p align="center">If you would like to post some news please <a href="news/post.php">click here</a>.<br /> To logout please <a href="logout.php">click here</a></p> </body> </html> login.php <?php function loginpage($error){ echo " <html> <body> <div align='center'> <form method='post' action='".$_SERVER['REQUEST_URI']."'> <label>username: <input type='text' name='username' id='username'><br> <label>password: <input type='password' name='password' id='password'><br> </label> <label> <input type='submit' name='submit' id='submit' value='submit'> </label> </form> </div> </body> </html> "; } $username = $_POST['username']; $password = $_POST['password']; $login = $_post['login']; $host = *********; $dbuser = *********; $dbname = *********; $dbpass = *********; mysql_connect("$host","$dbuser","$dbpass"); mysql_select_db("$dbname"); session_start(); if($_SESSION['user'] != $username){ if(!$submit){ loginpage(false); } elseif($submit){ $get = mysql_query("SELECT * FROM users WHERE username='$username'"); while ($row = mysql_fetch_assoc($get)){ $admin = $row['admin']; $passwordmatch = $row['password']; if ($passwordmatch==$password&&$admin==1){ $_SESSION['user']="$username"; echo "this worked"; } else{ die("Sorry wrong information."); } } } } ?>
×
×
  • 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.