[PHP] Script to add domain users to local groups on remote machines
Hello, Has anyone got any ideas how I might add a user to a local group on a remote networked Windows machine via a PHP script? The idea is to make an automated tool where users can request access to a shared folder via our intranet, and after suitable approval the system add them to a group which has read privileges for the folder in question. If I run apache using an account with suitable privileges, I've been able to do it with COM, but for security reasons I'd like to be able to authenticate through the script instead, and leave apache running on the standard local system account. Perhaps COM is the wrong way to go about the problem - perhaps exec? Any ideas gladly appreciated! Thanks, Jon.
RE: [PHP] Script to add domain users to local groups on remote machines
-Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: 04 June 2010 15:34 To: Mayer, Jonathan; php-general@lists.php.net Subject: Re: [PHP] Script to add domain users to local groups on remote machines At 11:16 AM +0100 6/4/10, Mayer, Jonathan wrote: Hello, Has anyone got any ideas how I might add a user to a local group on a remote networked Windows machine via a PHP script? The idea is to make an automated tool where users can request access to a shared folder via our intranet, and after suitable approval the system add them to a group which has read privileges for the folder in question. If I run apache using an account with suitable privileges, I've been able to do it with COM, but for security reasons I'd like to be able to authenticate through the script instead, and leave apache running on the standard local system account. Perhaps COM is the wrong way to go about the problem - perhaps exec? Any ideas gladly appreciated! Thanks, Jon. Jon: The concept is pretty simple. 1. Have a database set up for users with logons and passwords, such as: http://php1.net/a/edit-db-demo -- just add logon and password fields. 2. Have a method of approving users for access to the documents. Such as providing them with the password via email, phone, mail, or an act such as providing a real email address (i.e., subscribing): http://webbytedd.com/b/sub-email/ 3. Provide an url that checks for authorization before providing the document(s), such as: http://webbytedd.com/b/password-db/index.php or http://webbytedd.com/ccc/protected-download1/ 4. Provide a method for users to find the document(s) for download: http://php1.net/b/zip-files/ You throw all of that together and you have a way to solve your problem. Here's a working example I wrote for a client: http://webbytedd.com/ccc/protected-download1 The password is: 'a' The email address is: 't...@sperling.com' Also, the access of the data is registered (IP/Date) and an email is sent to me that someone accessed the file. So you can get as elaborate as you want. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com --- Thanks for your detailed answer tedd, I agree that that would be a sensible solution if I were to create an online file access tool from scratch. Unfortunately, however, the tool I'm creating has to work in the way I described because I am trying to put together a tool to simplify the maintenance of a system that is already in place. Once the users have access, they will also expect to be able to access these folders via Windows rather than using an online interface. Cheers, Jon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] COM/DCOM
Hello, I'm trying to write a few scripts to help automate some Windows administration tasks. One of these is to add people to groups on different networked machines. I've written something like the following: ?php $computer = TestComputer; $groupName = TestGroup; $server_config = array('Server' = TestComputer' , 'Username' = 'TestUser' , 'Password' = 'TestPass'); // list all current group members $domainObject = new COM(WinNT://.$computer./.$groupName.,group,$server_config) or die(Cannot create COM object); foreach ($domainObject-Members as $var) { echo $var-Name.br; } // add person to group $usertoadd = APerson; $domainUser = new COM(WinNT://DOMAIN/.$usertoadd.,user,$server_config) or die(Cannot create COM object ); $domainObject-Add($domainUser-ADsPath); ? TestUser is a local administrative account on TestComputer. If I run apache using the standard local system account, the code lists the members of the group but refuses to add APerson. If I run apache with a domain administrator account it works fine, but I don't want to do this - I want to be able to pass the username and password of an account on the target machine that has permissions set up for this purpose. I've tried making changes using dcomcnfg on the target machine, but no luck so far. Does anyone have any experience in using COM functions and can spot anything I'm doing wrong or a misunderstanding in how it works? Thanks, Jon - This e-mail does not reflect the views or opinions of Travellers Tales (UK) Ltd or any other related TT Games group company.
RE: [PHP] Problem with date
strtotime would be a neater way of solving the problem... ie (untested): $n = 0; while ($n = 9) { $date = d.$n; $$date = date(Y-m-d, strtotime(+ $n days) $n++; } If you are just enquiring about the maths though, I'm not sure! -Original Message- From: Korgan [mailto:josber...@seznam.cz] Sent: 15 September 2009 16:32 To: php-general@lists.php.net Subject: [PHP] Problem with date Hi, I have a problem with date function. $gen_pos = mktime(0,0,1,10,25,2009); $d1 = date(Y-m-d, $gen_pos);// 2009-10-25 $d2 = date(Y-m-d, $gen_pos + (1*24*60*60)); // 2009-10-25 $d3 = date(Y-m-d, $gen_pos + (2*24*60*60)); // 2009-10-26 $d4 = date(Y-m-d, $gen_pos + (3*24*60*60)); // 2009-10-27 $d5 = date(Y-m-d, $gen_pos + (4*24*60*60)); $d6 = date(Y-m-d, $gen_pos + (5*24*60*60)); $d7 = date(Y-m-d, $gen_pos + (6*24*60*60)); $d8 = date(Y-m-d, $gen_pos + (7*24*60*60)); line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 , 2009-10-26 ? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Timestamps and strftime
Off the top of my head, would strtotime work? ie strftime(%j,strtotime($row['UpdateDate'])) -Original Message- From: John Comerford [mailto:jo...@optionsystems.com.au] Sent: 04 June 2009 07:10 To: php-general@lists.php.net Subject: [PHP] Timestamps and strftime Hi, I am having a problem trying to use a date that I take from a MySQL database. The field is defined as a timestamp in the database. I extract it using PDO and I am trying to use the value with strftime as follows: foreach ($stmt-fetchall(PDO::FETCH_ASSOC) as $row) { echo strftime(%j,$row['UpdateDate']); } but it returns the following error: PHP Notice: A non well formed numeric value encountered... I understand that this is because strftime is expecting a numeric value and that ,$row['UpdateDate'] is a character but I am not sure how to resolve the issue. Any help would be apprecaited. TIA, JC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] More PHP Includes
-Original Message- From: Gary [mailto:gwp...@ptd.net] Sent: 11 March 2009 00:17 To: php-general@lists.php.net Subject: Re: [PHP] More PHP Includes Jochem Thanks for your reply, the project seven and DW was just for a point of information, same as if you have an issue with a computer you generally find it a good idea to list your operating system and other pertinent facts. I had coded the scripts and files by hand. The file was not on the server and it did not point back to my hard drive, it was hand coded and not uploaded to the server, which is why it was curious. The way I sometimes go about making a website is to fully code up the entire first page with a design I would like. Menus/headers/footers/layout and all. Then, when I'm happy with it, I cut it up into componant parts which I then include back in. This way there is no chance of having repeated tags, and everything is neatly organised. By the time you've cut it up, your index.php file will likely have nothing more than a bunch of includes and possibly the text specific to the index page. Don't think that each included file needs to work on its own. It doesn't matter if the included file doesn't open a tag if the page calling it has opened the tag already (such as html). I've had an include that formed part of a table, with the table created by a different included file, and closed by yet another. Jochem Maas joc...@iamjochem.com wrote in message news:49b6fddd.20...@iamjochem.com... Gary schreef: I'm sorry you were not able to understand the questions, but thank you for trying. a few tips: 1. don't assume people know what 'projectseven PMM' 2. it's doubtful anyone worth their salt on this list uses or knows much about a mind-bending, soul-destroyer like DreamWeaver. 3. try your hand at building a page by hand using a simple text editor and copious ammounts of searching/reading about HTML structure ... doing it this way will help you to understand what goes wrong and why, when DW tries to 'help you'. The path to the include is not an absolute path. then it is on the server, somewhere on your php include_path. Jochem Maas joc...@iamjochem.com wrote in message news:49b6b6d8.7050...@iamjochem.com... Gary schreef: Thanks again for all the help. I created a simple page of all includes (header, menu, 3 columns). I mixed the file types up. The menu (projectseven PMM) I saved as a library item, works fine. Had an HTML file in there, but I am guessing that having 2 page declarations along with an extra set of head and body tags was playing havoc with the code, so I removed them. Same thing when I created a php page and saved it as filename.inc.php, so I removed all the declarations and tags, again seems to work fine. Also included a simple .txt file. I did get some strange results in that all of the tags were highlighted after the menu, and I had to remove and insert again to correct. So is this the best way, to create a php page, remove all of the html tags and page declarations and name it filename.inc.php? (I'm using DW CS3) I'm quite sure I don't understand any of that ... so I'd hazard a guess and so no it's not the best way Also, something I do not understand, I included a small txt file in a page of a customer and it shows fine, however this file is not on the server...is this normal? it's probably pointing to a file on your machine, e.g. file://C:/path/to/file.txt, that's something you see quite often with DW/FrontPage/insert WYSIWYG-PITA-editor here. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP includes
-Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: 09 March 2009 19:55 To: Mayer, Jonathan Cc: Gary; php-general@lists.php.net Subject: RE: [PHP] Re: PHP includes On Mon, 2009-03-09 at 15:10 +, Mayer, Jonathan wrote: Thank you to everybody that replied...but it almost seems it is making extra work. I can understand using an include for a menu, since they tend to change often and it is on every page, but the normal content I am not understanding the benefit. If I have a page that has unique content on it, that is to say no other page has this content, why would I want to create a separate file to be included on the page, why would I not simple put the content directly on the page itself? What is the best type of file to be used as an include (.txt, .php). Thanks again for all your help. There are some circumstances where that could be useful. I don't do it often, but one site I made a while ago was based on a standard main page with the content included in. The content pages then had absolutely nothing except the unique text, so that redesigns to the site were made easier in the futurem, because only one page needed to be edited. So the entire site was based around a page.php?ID=x with the ID specifying the include required. Such as an example might be a little out of date now, what with CSS and so forth, but it was useful at the time. If I am including a file with password details, I usually make it something random (.inc, .sec, whatever) and hide it away somewhere inacessible Gary Gary gwp...@ptd.net wrote in message news:8a.64.51087.33bf3...@pb1.pair.com... I'm working on learning php and have been toying with includes, and I am trying to figure the advantages/disadvantages to using them. I know that using them eliminates the need to put the files once altered as with a template, however, is that the only advantage. My particular concerns are with SEO and if the search engines and the bots can read the page if it is made completely on includes? Any and all comments would be appreciated. Gary Just thought I'd point out that it's recommended against giving non-php extensions to PHP code pages. Basically, making all of your include files .inc without the server correctly configured to recognise all .inc files as PHP files, you are opening yourself up to possible hacks where people put the URL of your include directly in their browser and view all your code. Best thing is usually to name files like this: filename.inc.php or some-such, and not filename.inc. Ash www.ashleysheridan.co.uk Thanks Ash - that's an excellent point which I'll remember next time I'm including! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP includes
Thank you to everybody that replied...but it almost seems it is making extra work. I can understand using an include for a menu, since they tend to change often and it is on every page, but the normal content I am not understanding the benefit. If I have a page that has unique content on it, that is to say no other page has this content, why would I want to create a separate file to be included on the page, why would I not simple put the content directly on the page itself? What is the best type of file to be used as an include (.txt, .php). Thanks again for all your help. There are some circumstances where that could be useful. I don't do it often, but one site I made a while ago was based on a standard main page with the content included in. The content pages then had absolutely nothing except the unique text, so that redesigns to the site were made easier in the futurem, because only one page needed to be edited. So the entire site was based around a page.php?ID=x with the ID specifying the include required. Such as an example might be a little out of date now, what with CSS and so forth, but it was useful at the time. If I am including a file with password details, I usually make it something random (.inc, .sec, whatever) and hide it away somewhere inacessible Gary Gary gwp...@ptd.net wrote in message news:8a.64.51087.33bf3...@pb1.pair.com... I'm working on learning php and have been toying with includes, and I am trying to figure the advantages/disadvantages to using them. I know that using them eliminates the need to put the files once altered as with a template, however, is that the only advantage. My particular concerns are with SEO and if the search engines and the bots can read the page if it is made completely on includes? Any and all comments would be appreciated. Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Downloading file from local network machine
Cheers Ash et al... got it working now using fileread(), based on the example on php.net. I have it in a separate download.php file which takes a variety of inputs and spews out a file download. Many thanks all. -Original Message- From: Ashley Sheridan [mailto:[EMAIL PROTECTED] Sent: 05 December 2008 20:23 To: Mayer, Jonathan Cc: Wolf; php-general@lists.php.net Subject: RE: [PHP] Downloading file from local network machine On Fri, 2008-12-05 at 17:32 +, Mayer, Jonathan wrote: Thanks Wolf :) Yup, I had considered that, although there could be up to 8 different servers so that's 8 seperately mapped drives. If that's the simplest/neatest way, I'll do that, although I did wonder whether there was some other clever another way around it. -Original Message- From: Wolf [mailto:[EMAIL PROTECTED] Sent: 05 December 2008 17:29 To: Mayer, Jonathan; php-general@lists.php.net Subject: Re: [PHP] Downloading file from local network machine !-- SNIP -- I would like to present users to our internal intranet with a link to download a file from a folder on a different machine on our local network (such as \\computername\folder\file) !-- SNIP -- Map the drive to the server so that it is accessible as /folder/file on the website. Voila, no more problem. HTH, Wolf I don't have the code to hand right now, but I can try and post it later. You were on the right track with fread() et al. Basically, set the correct headers for a download (application/octet-stream I believe) and print out the results of the fread(). Don't forget the binary flag on fread() if you are opening binary files, and it should create a file that auto-downloads. There are extra headers to set the default filename of the download, but I forget these at the moment. A Google should give you what you need though. This way, the file can even be delivered to someone outside of your network should you wish, without you needing to put the file in a web-accessible directory. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Downloading file from local network machine
Hiya everyone, I would like to present users to our internal intranet with a link to download a file from a folder on a different machine on our local network (such as \\computername\folder\file) The file may be an HTML file, in which case the page should show in the browser, or a file which requires saving to the user's local machine, and which may be very big. In IE, I could do something simple like a href='file://computername/folder/file.html'click here/a But Firefox doesn't like doing this, for security reasons I think. I was wondering whether there was a PHP solution. I have looked into fopen() and fread() but not sure if this will help me. I would like to hide all the working behind a form button so as to also mask the download location, but that should be easy enough to do once I get the basics working. Any ideas? Thanks, Jon.
RE: [PHP] Downloading file from local network machine
Thanks Wolf :) Yup, I had considered that, although there could be up to 8 different servers so that's 8 seperately mapped drives. If that's the simplest/neatest way, I'll do that, although I did wonder whether there was some other clever another way around it. -Original Message- From: Wolf [mailto:[EMAIL PROTECTED] Sent: 05 December 2008 17:29 To: Mayer, Jonathan; php-general@lists.php.net Subject: Re: [PHP] Downloading file from local network machine !-- SNIP -- I would like to present users to our internal intranet with a link to download a file from a folder on a different machine on our local network (such as \\computername\folder\file) !-- SNIP -- Map the drive to the server so that it is accessible as /folder/file on the website. Voila, no more problem. HTH, Wolf
RE: [PHP] Re: BarcodeDB.com - a Barcode Database
Thanks for your suggestion!! Sounds like a good route to go down with the API access. Really struggling with the pending 'list' at the moment. Suppose I have got 2 tables `product` and `description`. `product` contains `EAN`, `name`, `last_modified` and `description` contains `EAN` and `description`. The nearest thing to me right now is a tub of pencils. EAN: 5011772007888 Name: 50 Staedtler HB Pencils Description: A tub of 50 HB Pencils by Staedtler. Suppose someone at BarcodeDB.com, having signed in, wanted to change the description to: A tub of 50 HB Pencils by Staedtler. With strong break resistant leads, they make an ideal pencil for kids or adults alike. Rather than update this description straight into the database. It would be nice for it to wait to be approved, and once approved a 'history' is kept so it is known who submitted the data and who approved it. Any ideas on how to achieve this effectively?? -- How about you add two extra fields in your 'description' table - 'UniqueID' and 'Approved.' Each time a new description is added or updated, it creates a new field in the description table. UniqueID auto-increments. 'Approved' is set to 0 until it has been approved (set to 1) or rejected (-1). This will make it easy to list pending approvals, too. The code can default to show the most recent (based on 'UniqueID') approved description. This has the advantage of having a full history of descriptions, and whether they were approved. You could expand it by having further fields (SubmittedID, ApproverID) to track that. And you could choose to have the 'Product' table hold the UniqueID of the currently chosen description, if you want the flexibility to choose a description that isn't the most recently submitted one. Jon.
RE: [PHP] Keeping POST values when paging
Yup, some good work there Tedd! In the end I decided the simplest way of coding the functionality was to do something similar to what Eric said, and have some extra submit buttons in the form, called Next, Previous and Jump. When clicked, they each submitted the form again with a different flag set. Along with a session variable storing the current page, I was able to code a reasonably neat solution deciding which results to show without having to rewrite any sections of my code. Because these submit buttons are tied to a form at the top of the page, this has limited me to only having the navigational buttons at the top of the results table rather than at the bottom too, but that is perfectly fine in my situation. Thanks all for your assistance, Jon. -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: 08 July 2008 15:08 To: Philip Thompson Cc: PHP-General List Subject: Re: [PHP] Keeping POST values when paging On Tue, Jul 8, 2008 at 9:29 AM, Philip Thompson [EMAIL PROTECTED] wrote: On Jul 7, 2008, at 12:46 PM, tedd wrote: At 2:51 PM +0100 7/7/08, Mayer, Jonathan wrote: Hiya all, I have coded a PHP site on an intranet which forms a MySQL query based on multiple inputs on a large form. The form results are POSTed back to itself, and query is formed, and the results are returned from the database and echoed. I am looking to set up a basic paging system (back/next, jump to page 3, etc) in order to limit results for efficiency. Jon: Here's my version of paging: http://webbytedd.com/bbb/paging/ And here's some different styles: http://webbytedd.com/ccc/pagination/ Here's an example of paging using ajax -- however, it's not as simple as the others: http://www.webbytedd.com/b1/photo-retouch/ tedd.. this is your best work so far! So maybe I'm a bit biased b/c there's beautiful women on it. But hey, what can I say?! ~Phil Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php very nice images -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Keeping POST values when paging
-Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: 08 July 2008 17:01 To: Eric Butera Cc: Mayer, Jonathan; Bastien Koert; Philip Thompson; PHP-General List Subject: Re: [PHP] Keeping POST values when paging On Tue, 2008-07-08 at 11:57 -0400, Eric Butera wrote: On Tue, Jul 8, 2008 at 11:33 AM, Robert Cummings [EMAIL PROTECTED] wrote: Just a comment... the submit button/session technique sucks with respect to passing along links to people. I would suggest scrapping that approach and going with a GET approach (where the navigational information is present in the URL). I know my clients almost always want to be able to paste a URL into an email and have the recipient go directly to whatever they are viewing. Maybe that's not an issue for you though... yet ;) That isn't practical if your form has 50 fields though. I haven't been following the thread very closely... does he have 50 fields? Cheers, Rob. I do have a large form - not quite 50 fields but it would create very long URLs! I take your point, however. In this situation the GET method isn't needed, as there will be a very limited number of users who will generally use the system independantly of each other, but I understand your reasoning. So, I've been lucky this time, but it's something I need to consider more carefully in the design stage of future projects. PHP programming is a small part of my job, with only hobby experience to work with, so it's only now that I'm moving on to slightly larger projects I'm beginning to see the real benefits in the design stage. With this project, I carefully worked out all the database design before coding, but didn't do enough on the use-case side of things, such as considering the need for paging to ensure system speed during a database query with lots of results. So I get to the situation where I have 1,000 lines of reasonably decent code, and I'm trying to hack in a solution for, say, paging, when it could have been easily handled if it was considered more carefully earlier. Live and learn I guess! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Keeping POST values when paging
Hiya all, I have coded a PHP site on an intranet which forms a MySQL query based on multiple inputs on a large form. The form results are POSTed back to itself, and query is formed, and the results are returned from the database and echoed. I am looking to set up a basic paging system (back/next, jump to page 3, etc) in order to limit results for efficiency. The problem I get is that my next link - something like href='resultspage.php?page=2' - naturally reloads the page without all the POST variables it needs to recreate the query. Is there some way of forcing the page to remember and reload the POST variables when clicking next? Or, if that's difficult, can anyone suggest a good way of addressing this problem without too much recoding? I'm sure there must be a neater way of doing it then simply passing 30 or so variables using GET. Many thanks in advance. Jon. Jonathan Mayer Motion Capture Studio Manager TT Games (www.ttgames.com) Email: [EMAIL PROTECTED] Tel: 01565 757357 Mob: 07814 973885 Address: Traveller's Tales, Canute Court, Toft Road, Knutsford, Cheshire, WA16 0NL -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Keeping POST values when paging
Thanks Wolf and Eric, I shall experiment with the two options you have suggested. Cheers, Jon. -Original Message- From: Wolf [mailto:[EMAIL PROTECTED] Sent: 07 July 2008 14:58 To: Mayer, Jonathan Cc: 'php-general@lists.php.net' Subject: Re: [PHP] Keeping POST values when paging Mayer wrote: Hiya all, I have coded a PHP site on an intranet which forms a MySQL query based on multiple inputs on a large form. The form results are POSTed back to itself, and query is formed, and the results are returned from the database and echoed. I am looking to set up a basic paging system (back/next, jump to page 3, etc) in order to limit results for efficiency. The problem I get is that my next link - something like href='resultspage.php?page=2' - naturally reloads the page without all the POST variables it needs to recreate the query. Is there some way of forcing the page to remember and reload the POST variables when clicking next? Or, if that's difficult, can anyone suggest a good way of addressing this problem without too much recoding? I'm sure there must be a neater way of doing it then simply passing 30 or so variables using GET. Many thanks in advance. Jon. Set session variables, have the script check the session variables. That'll keep the pages rolling, shouldn't take much coding, and you can change some things on-the-fly. HTH, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic form changes without refresh
Hiya all, I have a PHP page with a form holding a large number of textarea boxes. These text boxes are individually set as enabled or disabled based on a flag held in a MySQL database. I want to be able to dynamically enable or disable a specific box without the page being recalled (potentially loosing the parameters passed, and having to rebuild a large complex table). Using some basic javascript/AJAX, I have set up a link next to each text box, which calls code that updates the database in the background without refreshing the page. If I manually refresh the page, the textarea box in question updates correctly, proving that the database update has worked. However, I cannot work out how to get the textarea boxes to toggle the disable on/off on the fly. I assume they would need to continually check the database and adjust as required. I realise there may not be too much PHP involved here, but I was wondering whether anyone could assist or point me in the right direction. Thanks, Jon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic form changes without refresh
I suppose that, as well as updating the database when I click the link, I could also update a CSS toggle, but I'd really like it to be deciding whether to toggle only based on the flag in the database. So: // check database if ($toggle == 1) { textarea.../textarea } else { textarea disabled.../textarea } This is called every time the page is refreshed, of course, but if the database is changed afterwards, the form doesn't know. I would like some way of continually checking in the background whether $toggle is 1 or 0, and update the form appropriately. I assumed AJAX was the way to go. Perhaps I'm making this more complicated than it needs to be, but there is a reason why I want to store the state of the toggle in the database (as opposed to simply using a javascript on/off snippet) as I use this information in other places in the code. -Original Message- From: Per Jessen [mailto:[EMAIL PROTECTED] Sent: 05 June 2008 13:26 To: php-general@lists.php.net Subject: Re: [PHP] Dynamic form changes without refresh Mayer, Jonathan wrote: Using some basic javascript/AJAX, I have set up a link next to each text box, which calls code that updates the database in the background without refreshing the page. If I manually refresh the page, the textarea box in question updates correctly, proving that the database update has worked. However, I cannot work out how to get the textarea boxes to toggle the disable on/off on the fly. I assume they would need to continually check the database and adjust as required. This sounds too obvious, so I've probably misunderstood your question - but surely it is just a matter of toggling the CSS 'display' attribute? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php