Jump to content

Malevolence

Members
  • Posts

    102
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Malevolence's Achievements

Member

Member (2/5)

0

Reputation

  1. I had to fix a couple of things, but the main things were PHP upload limits in the php.ini file(s) as well as the mysql config to allow such a big request. I know that normal file storage is reccomended but this way is better for what I am doing, and the site is very exclusive and protected so not just anyone will upload several server-speed-crunching files. Solved! - I guess...
  2. I never thought of those optional fields however for the current CMS I won't need all that data, but perhaps in my other CMS I will use it. Thanks for the info. gnet, seeing as you seem so confused- and I'm not sure where you are at with coding php, can I have the database layout for the current table you have (as well as the table name) and all of your login script minus the db password and username? that way we can give you a code to work with straight off the bat rather than us giving you snippets all over the show.
  3. darn you ignace! foiled again! Absolutely fair enough gnet, Ignace has clearly been learning php longer than me, kudos to him. If you have a webpage you can add a mysql table on, create one - it could have failed because the table `users` has been taken. -Try creating `activeUsers`, there will be 2 fields (as phpmyadmin and similar control panels require this number with the table name). -Then you need to make field 1 "users_last_click_at" and make the field type 'DATETIME' under Date and Time in the list. -Then name the other field "users_id" and make this field a VARCHAR or SMALLINT (small integer). If varchar, make it about 6 chars wide. Shove this at the top of every PHP page: (you may find it worth converting ALL your pages to .php by renaming the filetype as it could get sloppy) <?php include(sesschk.php); include(dbconnect.php); $q = "UPDATE users SET users_last_click_at = now() WHERE users_id = $id"; $q2 = "SELECT * FROM users WHERE users_last_click_at BETWEEN now() - 300 AND now()"; mysql_query($q) or die("MySQL Error: ".$mysql_error()); $r2 = mysql_query($q2); $u = mysql_num_rows($r2); ?> the includes at the top will include your 'logged-in' checker, so you may want to replace this line with your code or the file you use. The same goes for the database connection file, you may want to put your db connection script in a similarly named file or replace the line with your code. - It is a lot easier to put them in files to include to be honest. To show how many users are logged in: Users online: <?php echo $u; ?>
  4. Curse you ignace! curse you! He's right, my post is a waste of time. Lol, Do I get banned for "self-flaming"?
  5. When I say fails, it doesn't seem to recognise a file has been uploaded, however I echoed $_FILES['supload']['tmp_name'] and found that nothing was there. I then uploaded a small jpg file, which successfully uploaded and the if statement did work. The problem therein lies that either mp3 files aren't allowed by my home webserver (unlikely) or that the filesize cannot be handled by my webserver. I will look at httpd.conf and see what I can fix, if anyone can point me to the main things I should be looking for, that would be helpful. Also, would 6-10mb be an allowed upload size on a conventional web host? seeing as you can't change this factor if you're paying for a host rather than a home-hosted server.
  6. Sorry I seemed to have answered the wrong question... Ignace's table seems a bit much just to see how many people are online, but would work with the correct PHP code (something he didn't include). What you could do is create a file somewhere in your root directory, something like userLog.dat or userLog.txt and then have some php code open the file, add an entry in a new line with an IP address (or a username from a session variable) and a timestamp on it. Then you'd parse the file finding every entry that is recent (your choice of time) and only allow one ip per entry in that timespan. Then you'd have the amount of users online recently. I would have to write this code up if you aren't sure how, or I could point you to a tutorial. The other downside is that you'd have to delete the contents of this file after a while or it would become huge.
  7. On the basis that you've used sessions for the login: sessChk.inc.php: <?php if (!isset($_SESSION['sessName']) { header("Location: login.php"); exit; } $user['name'] = $_SESSION['sessName']; This is how you would create that session in the login parser page: session_start(); $_SESSION['sessName'] = $username; Simples! By the way, replace $username with the username found in the login form i.e. $_POST['usr'], replace sessName in the sessions with whatever you like. Hope that helps!
  8. 1. Is $id set? 2. Are there more than 2 rows with that id? 3. Good practise to use backticks (`) the button above the tab button around SQL Tables e.g. SELECT genre_id FROM `genrelinked` WHERE etc.... although this wont fix your problem. That's all I can help you with as I don't understand the foreach statement :\ lol. http://www.brainbell.com/tutors/php/php_mysql/Using_foreach_Loops_with_Arrays.html - this looks helpful and I'm starting to understand it already =D oh and I thought of ignace's answer but then I thought the associative bit is useless however he may be correct....
  9. I have a form that lets one upload a file. If there is no file present, then the if statement only uploads the strings from the other fields. If however, the file is present, then the script will upload the text and parse the file into binary which is then uploaded to the database alongside the simple string data. The HTML for the Form: <form enctype="multipart/form-data" name="addSong" action="addSong.php" method="POST"> <div style="float: right; font-size: 0.9em;" align="right"> <strong>Tip</strong> | Use the tag buttons found at the bottom left of the toolbar to structure your song. </div> Song Title: <input type="text" class="regField" name="stitle" value="" tabindex="1" /> <br /><br /> <textarea cols="95" rows="20" name="slyrics" value="" tabindex="2"></textarea> <br /> <div align="right" style="float: right;"> <input type="checkbox" name="sdraft" value="true"> Save as draft? <input name="submit" type="submit" value="Save" /> </div> Upload: <input type="hidden" name="MAX_FILE_SIZE" value="20000000" /><input name="supload" type="file" /> </form> The PHP IF Statement that fails: (the rest is irrelevant) if(!empty($_FILES['supload']) && $_FILES['supload']['size'] > 0) // If the upload field is not empty, set up the file upload. { // ^^^ THE ABOVE BIT DOESNT WORK ^^^ ... ... } else // Otherwise just upload the lyrics { ... ... } If anyone can help, thanks in advance.
  10. just ensure you use the code I put in my last post to retrieve their ip address, as that will ensure that you're logging their true ip whether they're behind a proxy or not.
  11. I'm surprised mine didn't work, so long as you define the session with: session_start(); $_SESSION['bob'] = "storeanythingyoulike"; you can call it any time on that website echo $_SESSION['bob'] and 1 the session returns true and 2 it stores "storeanythingyouilke" which is useful if you wanna call a username or match a user id against a database in order to refer to that user in something they post.
  12. Thanks, I'll have a look at those, the file upload bit was just from a tutorial example so I didn't go over those. I will have a look at the error returned, I would have thought it would have echoed the error anyway... thanks for the quick reply.
  13. You can try doing this instead too: session_start(); // PHP will tell you if its already been set in an error. if so, delete this line $_SESSION['passed'] = true; You would only put it in login.php as that's the page that will destroy the session (obviously, you could in essence put it in every page, but in pages locked to members only, the session would be destroyed and they would be greeted with a blank page. By only having it in login.php it simply shows them the login screen after they've logged out.
  14. @MrAdam - You can't work with sessions until you initialise the session function. @craigtolputt: Use an if statement to detect if ?act=logout was sent to the page and then delete the session. <?php //include the global settings require_once('../settings.php'); //hold the target url $_refURL = $_SERVER['QUERY_STRING']; //if the query string is empty, use chooseTable if(empty($_refURL)){$_refURL = 'chooseTable.php';} $_GET['act'] = strip_tags($_GET['act']); // Filter out any html found in the get variable. if(isset($_GET['act']) && $_GET['act'] == "logout") // If there is an action set and it is equal to logout... { session_start(); unset $_SESSION['passed']; // Unset the session. // we won't destroy the session as any other sessions linked to this site will be lost too. } if(isset($_POST['submit'])){ //reset the target url if(isset($_POST['ref'])){$_refURL = $_POST['ref'];} //init the errors $err = "the following errors occurred:\n"; if(!empty($_POST['user'])){ $_un = $_POST['user']; }else{ $err .= "Username was not set.\n"; } if(!empty($_POST['pwd'])){ $_pw = $_POST['pwd']; }else{ $err .= "Password was not set.\n"; } //check for match if(array_key_exists($_un, $users_login)){ if($users_login[$_un] == $_pw){ session_register('passed'); header("Location: $_refURL"); }else{ $error= 'The password was not correct. Please try again.'; } }else{ $error= 'The username and/or password was not correct. Please try again.'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?=$pageTitle?></title> <style type="text/css" media="all">@import "../blogStyles.css";</style> <style type="text/css" media="all">@import "http://www.tktest.co.uk/clinigen/news_articles/cms/css/screen.css";</style> <style type="text/css" media="all">@import "http://www.tktest.co.uk/clinigen/stylesheet.css";</style> <script type="text/javascript" src="js/inits.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <!--******* Wrapper *******--> <div id="wrap"> <!--******* Header *******--> <div id="logo"> <a href="../../biopharmaceutical_partnering.php" target="_self">CLINIGEN</a></div> <div id="bullets"> <p>Management and supply of unlicensed and specialist medicines<br /> Structured implementation of named patient programmes<br /> Partnership approach to Global Market Access Planning<br /> Patient Access and Product Life Cycle support </p> </div> <div id="slogan"> <h1>UNLICENSED WITHOUT UNCERTAINTY</h1> </div> <!--******* END - Header - END *******--> <!--******* Top Image *******--> <div id="topimg"> <h1>Unlicensed and Specialist Medicine Management and Supply</h1> </div> <!--******* END - Top Image - END *******--> <!--******* Navigation *******--> <div id="nav"> <ul id="navbut"> <li><a href="../../biopharmaceutical_partnering.php">Home Page</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../about_clinigen.php">About Clinigen</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../global_named_patient_distribution.php">Global Named Patient Distribution</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../patient_access_and_product_life_cycle_support.php">Patient Access & Product Life Cycle Support</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../market_access_planning.php">Market Access Planning</a></li><br /> <li><a href="../../our_people.php">Our People</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../case_studies.php">Case Studies</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../management_and_supply.php">Management & Supply</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../partnerships.php">Partnerships</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../stakeholders.php">Stakeholders</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../regulatory.php">Regulatory</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../news_articles/">News/Articles</a></li> <li><img src="../images/dot.png" alt="" /></li> <li><a href="../../contact_us.php">Contact Us</a></li> </ul> </div> <!--******* END - Navigation - END *******--> <!--******* Content *******--> <div id="content"> <div id="contact"> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST" > <h1>LOGIN</h1> <input type="hidden" name="ref" value="<?=$_refURL ?>" /> <br /> <label for=phone accesskey=P>USERNAME:</label> <input type="text" name="user" /> <br /> <label for=phone accesskey=P>PASSWORD:</label> <input type="password" name="pwd" /> <br /> <input type="submit" name="submit" value="Submit" id="contactus" class="submit" /><br /> <?=$error ?> </form> </div> </div> <!--******* END - Content - END *******--> <!--******* Footer *******--> <div id="footer"> <hr /> <p class="copyright">© 2009 Clinigen Online</p> <a href="http://www.tolputtkeeton.co.uk" target="_blank" class="tolputt">Designed by Tolputt Keeton</a> <div id="nav"> <ul id="navbutbot"> <li><a href="../../biopharmaceutical_partnering.php">Home Page</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../about_clinigen.php">About Clinigen</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../global_named_patient_distribution.php">Global Named Patient Distribution</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../patient_access_and_product_life_cycle_support.php">Patient Access & Product Life Cycle Support</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../market_access_planning.php">Market Access Planning</a></li><br /> <li><a href="../../our_people.php">Our People</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../case_studies.php">Case Studies</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../management_and_supply.php">Management & Supply</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../partnerships.php">Partnerships</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../stakeholders.php">Stakeholders</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../regulatory.php">Regulatory</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../news_articles/">News/Articles</a></li> <li><img src="../images/greydot.png" alt="" /></li> <li><a href="../../contact_us.php">Contact Us</a></li> </ul> </div> </div> <!--******* END - Footer - END *******--> </div> <!--******* END - Wrapper - END *******--> </body> </html> Shove this anywhere in your site (obviously in the logged in areas) <a href="login.php?act=logout" alt="Log out">Log Out</a> Hope this helps.
  15. I'm not sure if printing within a function works. If it does, you get an instant result, whereas you have far more to play with if its returned. ... } else { $errMsg = "<p style='font: verdana;font-size:10px;font-weight:bold;color:red;'>Error: ". $error[$error_id] ."</p>"; return $errMsg; } } ... $err = WriteError(2); print $err; but you could also pass the error on in a GET variable or session.
×
×
  • 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.