PHP - Detect If A Record Is Open By Other User?
Similar TutorialsIn the site I am making, the client wants one account for everyone (don't ask me why, it's a long, silly reason) And I'm wondering how I would configure mySQL to deal with that (I asked this in the mySQL area) and in PHP (For you guys ) what would I need to put in order for this to work. I'm very new with PHP and mySQL, so please forgive the nooby question. *EDIT* the admins have their own username and psw for adding, deleting, and editing articles. and that works. But all users that register will have this set user and psw displayed to them. I want to make it so they have to log in to see an article. hi i am trying to dectect the user agent and depending on which agent the user is using embed the video a differnt way working fine on my wamp test sever but when i upload to my sever i get this error Warning: get_browser() [function.get-browser]: browscap ini directive not set in Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) { echo 'Internet explorer';?> <object width="420" height="360" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> <param name="src" value="test.avi" /> <param name="controller" value="true" /> <param name="autoplay" value="false" /> <!-- Code For Older Browsers --> <embed src="test.avi" width="420" height="360" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> </embed> </object> <?php } if(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE) { echo 'Mozilla Firefox';?> <object type="video/quicktime" data="your file name.avi" width="150" height="250"><param name="Filename" value="test.avi"><param name="AutoStart" value="0"><param name="ShowControls" value="True"><param name="ShowStatusBar" value="False"><param name="ShowDisplay" value="False"><param name="AutoRewind" value="True"> <param name="src" value="./Videos/Security/XPWUA.avi"> <embed src="test.avi" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" filename="test.avi" autostart="0" showcontrols="True" showstatusbar="False" showdisplay="False" autorewind="True" height="600" width="800"></embed> </object> <?php } if(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE){ echo 'Google Chrome';?> <object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="mediaplayer1" height="600" width="800"><param name="Filename" value="./Videos/Security/XPWUA.avi"><param name="AutoStart" value="0"><param name="ShowControls" value="True"><param name="ShowStatusBar" value="False"><param name="ShowDisplay" value="False"><param name="AutoRewind" value="True"> <param name="src" value="./Videos/Security/XPWUA.avi"> <embed src="test.avi" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" filename="test.avi" autostart="0" showcontrols="True" showstatusbar="False" showdisplay="False" autorewind="True" height="600" width="800"></embed> </object> <?php }else{ echo 'Something else'; } ?> Hello there, I'm trying to make when you click on a record, it opens another page with full details about this record the code for it is Code: [Select] <td><a href=\"user.php?id=".$row['id']."\">".$row['id']."</a></td> and it's working right, but when it opens the other page, no records is shown about the user with that ID So I figure the problem that I need to pass $row['id'] to my second page and make it search for it in the database how can I do that? here is the code from the second page (details of the record) Code: [Select] $dbObj = new DB(); $result = mysql_query("select * from users where id = '$userID'"); return $result; $row = @mysql_fetch_array($result); echo "<table width=98%>"; echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\" class=\"searchtitle\"> ".$row['fname']. ' ' .$row['mname']. ' ' .$row['lname']." </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['mobile']." </td> </tr> <tr> <td> <a href=\"user.php?id=".$row['recruiterid']."\" class=\"link\">".$row['recruiterid']."</a> </td> </tr> </table>"; echo "</td>"; echo "</tr>"; echo "</table>"; 1 Total number of likes work, but I'm guessing it can be done differently, any input would be appreciated. /controllers/indexController.php $posts = Post::find('all', [ 'limit' => 4, 'include' => ['likes'] ]); foreach ($posts as $post) { $post->assign_attribute('likeCount', count($post->likes)); } } /models/Post.php class Post extends ActiveRecord\Model { static $has_many = [ ['comments', 'class_name' => 'PostComments'], ['likes', 'class_name' => 'UserLikePosts'] ]; } /models/UserLikePosts.php class UserLikePosts extends ActiveRecord\Model { static $belongs_to = [ ['user'], ['post'] ]; }2 The big question is, how can I get a true/false for "if current user has liked post"? I was thinking something like this, but using vars won't work here, and I would have to use a ternary or a function call to do it like this as the session var might not be set (guest). class Post extends ActiveRecord\Model { static $has_many = [ ['comments'], ['likes', 'class_name' => 'UserLikePosts'], ['user_likes', 'class_name' => 'UserLikePosts', 'conditions' => ['user_id = ?', [$_SESSION['user']['id']]] ]; } Edited by JimL, 21 June 2014 - 03:36 PM. Hi everyone... I would like to implement a questionnaire/survey system that has only two Answers (Yes /No). Basically, this questionnaire system will be widely used on Mobile Phones. It will be looking something like this below: http://awardwinningfjords.com/2009/06/16/iphone-style-checkboxes.html Lets say a user selects a response as No (Using the above slider button for a question). That response should be recorded in the database with User Details + Time Stamp. Also, I would like to generate a report for each question (Responses of Multiple Users) and a report at a User Level for the entire questionnaire/survey (s). Can some one guide me the fastest & easiest way to achieve this? I'm a new learner of PHP. Regards Sandeep Hey guys, I can't wrap my head around how to make this work right... I have three tables: Code: [Select] CREATE TABLE `games` ( `g_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(150) DEFAULT NULL, PRIMARY KEY (`g_id`)); CREATE TABLE IF NOT EXISTS `game_player` ( `r_id` int(11) NOT NULL AUTO_INCREMENT, `p_id` int(11) DEFAULT NULL, `g_id` int(11) DEFAULT NULL, `bool` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`r_id`)); CREATE TABLE IF NOT EXISTS `players` ( `p_id` int(11) NOT NULL AUTO_INCREMENT, `playerid` varchar(150) NOT NULL, PRIMARY KEY (`p_id`), UNIQUE KEY `playerid` (`playerid`)); The players table is my list of users, and they're tied to the list of games via the game_player table. So here's my issue... I'm trying to show the full list of games, and then check mark each record where the player does play it. This is what I have so far - it shows all the games, but it's not checking the boxes. Code: [Select] $result = mysql_query("SELECT * FROM games") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $newquery = "SELECT * FROM game_player, players WHERE game_player.p_id = players.p_id AND game_player.g_id = ".$row['g_id']. " AND players.playerid = {$userid}"; $query = mysql_query($newquery) or die(mysql_error()); if($query['bool'] == 1) { $set_checked = " CHECKED"; } else{ $set_checked = ""; } echo "<input type=\"checkbox\" name=\"box1\" value=\"".$query['g_id']."\"" . $set_checked . "/>".$row['name']."<br />\n"; } I have hardware setup to preform an action on camera when i enter a url into the address bar. Pretty much you will be able to feed tarantulas. I'd like to setup a button that my user can click that will active the url without being moved off of the current page. I can't figure out how to stop the browser from following the link to a blank page. It messes the whole thing up because the feeder only runs for a second and if you get sent to the blank page and have to navigate back the the live video feed page you could miss the feeding. Thanks for the help Hi guys Do you guys know if possible to open an external URL without actually displaying this to the user? We have a service where we wish to open an external URL which triggers sending out an SMS to the user. However..we cannot display the url opened to the user as it shows our username etc with the sms provider. basically the url looks like this: https://www.smsprovider.com/username=OurUsername&password=******&smsMsg_to_send=blablablablabla Is it possible to "trigger" this URL without letting our users see it? Thanks in advance for any help you may provide I'm working on a light use/kiosk system. I have apache2 and php5 installed on Ubuntu 10.04 and I have the browser open the localhost web page by default. I would like to include a link on this page to open oowriter (open office writer) for the end user on the machine. I've tried Code: [Select] exec('oowriter'); with no luck. I've also tried setting the DISPLAY value before the command like Code: [Select] exec('DISPLAY=:0 oowriter'); with no success. I don't mind have the www-data user in the sudoers file if I have to sudo the command or something, but is this possible to do?? I'm not having any luck at all! i want a code in php to check if user open this page I'm trying to open a URL using fopen() and I keep getting this error: Code: [Select] Failed to open stream: Permission deniedI can not work out what is wrong, it's not a firewall as far as I can tell. Not to say that this occurs in every php software out there, but I far too occasionally notice that the application is written with scattered php open and close tags, for instance
<?php if(true) ?> <?php { ?> Blah blah blah, because it's true <?php } else { ?> because it's not true <?php } ?>To me, it is extremely irritating. Regardless, I see a lot of open source software written this way and I can't help but think that there must be some underlying reason for it. Magento, for example, is written exactly in this manner. The templates are infested with these opened and closed php snippets. Obscurity is not security so I'm ruling security reasons out. Maybe it is more efficient? -- But I couldn't understand why, if so. It seems like that would put more of a drag on the system itself causing php to start and stop parsing continually and excessively, then again, I'm no expert in the field of memory consumption and other operating system complexities. Honestly, in my opinion, it is stupid. i would never write a program that way.. HEREDOCs are much more useful and eye pleasing than that awful <?php { ?> I had the misfortune a few months ago when I purchased an invoicing/customer maintenance system that I didn't know was written for PHP 5.2 or something lower, one that allowed short tags; and thus short tags were used in the same manner as I've described. Is this just plain disorganization or is there some deep-seated inner lining advantage that I'm not aware of? hi, i have made a website where people resgister their details of them and products. they have to enter the following details in form Name of company name of the product company address email id password mobile number contact and brief details about their company
user can then login with email id and pwd. now after login ..user will get a page where he can upload the photos of products images and their price, so now my question is that when he finishes uploading (|by clicking on upload button) the product images and price text box ..then on final uploaded webspage it should show all other things which he registerd before (company name , mobile number etc) along with images and price...hence the main question that user does not need to enter mobile and address while uploading images and filling proce ..but on the final page it should show mobile and address along with price and images..as user is not going to enter mobile and address again and again as he will have multiple products to upload.
I would appreciate your assistance, there are tons of login scripts and they work just fine. However I need my operators to login and then list their activities for the other operators who are logged in to see and if desired send their clients on the desired activity. I have the login working like a charm and the activities are listed just beautifully. How do I combine the two tables in the MySQL with PHP so the operator Logged in can only make changes to his listing but see the others. FIRST THE ONE script the member logges in here to the one table in MSQL: <?php session_start(); require_once('config.php'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $login = clean($_POST['login']); $password = clean($_POST['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); if($result) { if(mysql_num_rows($result) == 1) { session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: member-index.php"); exit(); }else { header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> ................................................. ................................ Now I need the person who logged in to the table above to be able to make multiple entries to the table below <? $ID=$_POST['ID']; $title=$_POST['title']; $cost=$_POST['cost']; $activity=$_POST['activity']; $ayear=$_POST['aday']; $aday=$_POST['ayear']; $seats=$_POST['special']; $special=$_POST['seats']; mysql_connect("xxxxxx", "xxx350234427", "========") or die(mysql_error()); mysql_select_db("xxxx") or die(mysql_error()); mysql_query("INSERT INTO `activity` VALUES ('ID','$title', '$cost','$activity', '$aday', '$ayear', '$special', '$seats')"); Print "Your information has been successfully added to the database!" ?> Click <a href="member-profile.php">HERE</a> to return to the main menu <?php ?> Hi, so far I have managed to set up a somewhat basic login website with a mysql database backend. Once they have logged on they go to a "main menu" page. What I need to define is that user A sees button A but only that button, etc. (Then of course that same rule would have to apply if they tried to directly go to the page, but I am guessing I can do that in the same way that I currently do to force a login). If anyone has any tutorials or sample code I would much appreciate it. Thanks, Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after Hi, I am getting frustrated beyond belief at the moment with trying to get a very simple script to run, I am using PHP 5.3.3 and MySQL 5.1 on a Win2k8 server with IIS7.5. Basically my script is connecting to a local database, running a single select query, returning those rows and building up a string from them. The problem is that I am receiving complete BS responses from PHP that the access is denied for the user being specified. This is complete rubbish since the user can connect via mysql, sqlyog, ASP.NET MVC without issue but for some bizarre reason it is not working via PHP. The code for the script is here : Code: [Select] <?php $mysql = mysql_connect('127.0.0.1:3306', 'myuser', 'mypass', 'mydatabase'); if (!$mysql) { die(mysql_error()); $content = "<nobr></nobr>"; } else { $result = mysql_query('SELECT * FROM tblEventGroup'); $content = "<nobr>"; if ($result) { while($row = mysql_fetch_assoc($result)) { $content .= "<span>"; $content .= $row['GroupName']; $content .= "</span>"; $content .= "<a href=\"../Event/EventSearch?groupid="; $content .= $row['GroupId']; $content .= "\" target=\"_blank\">Book here</a> "; } } mysql_close($mysql); $content .= "</nobr>"; } ?> I cannot for the life of me understand what the problem is, the return error is Access denied for user 'myuser'@'localhost' (using password: YES) Hi guys, I am trying to put together a little system that allows users to log onto my website and access there own personal page. I am creating each page myself and uploading content specific to them which cannot be viewed by anyone else. I have got the system to work up as far as: 1/ The user logs in 2/ Once logged in they are re-directed to their own page using 'theirusername.php' Thats all good and working how I need it too. The problem I have is this. If I log onto the website using USER A details - I get taken to USER A's page like I should but - If I then go to my browser and type in USERBdetails.php I can then access USER B's page. This cannot happen!! I need for USER A not to be able to access USER B profile - there is obviously no point in the login otherwise! If you are not logged in you obviously cannot access any secure page. That much is working! Please find below the code I am using: LOGIN <?php session_start(); function dbconnect() { $link = mysql_connect("localhost", "username", "password") or die ("Error: ".mysql_error()); } ?> <?php if(isset($_SESSION['loggedin'])) { header("Location:" . strtolower($username) . ".php"); if(isset($_POST['submit'])) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $mysql = mysql_query("SELECT * FROM clients WHERE username = '{$username}' AND password = '{$password}'"); if(mysql_num_rows($mysql) < 1) { die("Password or Username incorrect! Please <a href='login.php'>click here</a> to try again"); } $_SESSION['loggedin'] = "YES"; $_SESSION['username'] = $username; $_SESSION['name'] header("Location:" . strtolower($username) . ".php"); } ?> HEADER ON EACH PHP PAGE <?php session_start(); if(!isset($_SESSION['loggedin'])) { die(Access to this page is restricted without a valid username and password); ?> --------------------------------------------------- Am I right in thinking it is something to do with the "loggedin" part? The system I have here is adapted from a normal login system I have been using for years. The original just checks the details and then does a 'session start'. This one obviously has to re-direct to a user specific page. To do this I used the <<header("Location:" . strtolower($username) . ".php");>> line to redirect to a page such as "usera.php" or "userb.php" Any help would be greatly appreciated! Ta Hello. Would php be the right thing to use in regards to monitoring changes in html on certain pages, Basicly, I'd need it to be something like: "Page last changed: 2 Days, 4 Hours, 34 Minutes and 13 Seconds ago." What would I use for this? Thanks Ok, so I have a code that looks like so: Code: [Select] <script type="text/javascript"> var ng_config = { assests_dir: 'ng/assets/' // the path to the assets directory } </script> <script type="text/javascript" src="ng/ng_all.js"></script> <script type="text/javascript" src="ng/components/calendar.js"></script> <script type="text/javascript"> var my_cal; ng.ready(function(){ // creating the calendar var my_cal = new ng.Calendar({ input: 'enddate', start_date: 'year - 1', // the start date (default is today) display_date: ng.get('startdate').value, // the display date (default is start_date) server_date_format: 'm/d/Y' // changing the server date format for a specific calendar. }); }); var my_cal1; ng.ready(function(){ // creating the calendar my_cal1 = new ng.Calendar({ input: 'startdate', start_date: 'year - 1', // the start date (default is today) display_date: new Date(), // the display date (default is start_date) server_date_format: 'm/d/Y' // changing the server date format for a specific calendar. }); }); how do I detect the months that pass between the two dates that are selected using a popup calendar using php so that my register page know which month to display the event under. Does this make sense? |