-
Posts
1,469 -
Joined
-
Last visited
-
Days Won
12
Everything posted by CroNiX
-
Glad you got it working
-
There is also a typo in the longone function... fwrtie($fp, $four); //needs to be fwrite()
-
Problem is you are taking those methods from a class, and you don't have a "controller" to execute them. Try changing: curl_post_async("http://127.0.0.1/longone.php", $params); //add .php and making a longone.php file in your web root that contains ONLY the code from the longone() function definition: $one = $_POST["one"]; $two = $_POST["two"]; $three = $_POST["three"]; $four = $_POST["four"]; echo uniqid("You won't see this because your PHP script isn't waiting to read any response"); sleep(5); $fp = fopen("data.txt", "w"); fwrite($fp, $one); fwrite($fp, $two); fwrite($fp, $three); fwrite($fp, $four); fclose($fp);
-
Well if you're going for shorter code function format_bytes($bytes, $precision = 2) { $labels = array('B','KB','MB','GB','TB'); for($x = 0; $bytes >= 1024 && $x < (count($labels) - 1); $bytes /= 1024, $x++); return(round($bytes, $precision).' '.$labels[$x]); }
-
It looks like you just need to add: $x_number_format = number_format($x, $decimals); //add $decimals
-
It's simply making a custom POST request to the given url, and using the array() (2nd parameter) as the POST data. In essence, making a 2nd request to a different URL and not waiting for a response back before returning control back to your app. Then the url to the script that you called in curl_post_async() gets processed on it's own behind the scenes, as a totally separate web request (because that's what it is) All of the "we then create a string $out full of what seems to me to be random info required for some reason" you refer to is not random at all. It's a header request. All requests to your server, and the response back, contain them behind the scenes. Like if you click on a link, or request a url. It sends a header to the server, and the server sends back a response. There's a nice plugin for firefox, called "HTTP Live Headers", which allows you to easily examine all of that raw header/response data flying back and forth between your browser and a server behind the scenes. Other browsers might have a similar plugin but that's what I mainly use. It's quite helpful to learn this stuff and how it works.
-
Because it's a full fledged working example, with a proof of concept to show you it's working. All you really need is the curl_post_async() function from that code. Then in your code, you'd just: curl_post_async('http://yoursite.com/path/to/pdf/processing/script.php', array(parameters needed by script.php)); the "parameters needed by script.php" would probably just be your $_POST array.
-
Not sure why you'd need to do that. if (isset($_POST["submit"])) { //use the asynchronous code I linked to to send data to the script that will create the PDF //this will immediately show since using the async method doesn't wait for the PDF generating script to be completed echo 'Your PDF is being generated and will be emailed to you when completed. Please check your email in about 5 minutes. Note: some PDF's will take longer to generate depending on the requested information.'; } Then the user can continue on with their business, go to a different page, etc.
-
It sounds like your login system needs to have user roles, like "admin", "user", "nurse", "doctor", etc. One login system for them all (username/password). Once logged in check their user "role" and redirect them to their "home" page depending on what role they are. You'd also check the roles when doing actions, so a "user" can't access an admin page, or perform admin functions, etc.
-
Sure, take a look at the docs for the round() function. Specifically the 2nd parameter.
-
I just tested it and this worked fine. You'd just need to define the $source_dir at the top. <?php $source_dir = '/home/users/images/'; ?> <form action="test.php" method="post"> <select name="myDirs"> <option value="" selected="selected">Select a genre</option> <?php foreach(glob($source_dir . "*", GLOB_ONLYDIR) as $val){ echo '<option value="'.$val.'">'.$val."</option>\n"; } ?> </select> <input type="submit" name="submit2"> </form> <?php if (isset($_POST['submit2'])) { //get the dir from POST $selected_dir = $_POST['myDirs']; //now get the files from within the selected dir and echo them to the screen foreach(glob($selected_dir . DIRECTORY_SEPARATOR . '*') as $filename) { echo "$filename<br>"; } } ?>
-
Haven't needed to use forks, so not sure. But a quick glance at the documentation states it shouldn't be used in a web platform (apache), only the CLI. http://php.net/manual/en/intro.pcntl.php
-
I think what you want is an "asynchronous" server request, so you can send the data to the task and it executes independently...and you don't have to wait for a response before continuing on so the user doesn't have to wait. I've used something like this.
-
Moved to PHP Coding Help...
-
I think first, you really need to document all of your business rules and come up with a plan to implement them. A diagram of all database tables needed, and of how they relate to each other. Each "page" type and what it needs to do, like "monthly calendar view, daily calendar view, sign up for time slot, doctors calendar view, nurses calendar view, admins calendar view",etc. If you just keep adding part by part without looking at the larger picture, you are probably doing yourself a disservice and will have to constantly be rewriting old parts to make new ones fit. And you might spend a lot of time getting things to work a certain way, but then have to totally redo it because you didn't consider "the next piece". You'll waste a lot of time just rewriting older stuff instead of only new stuff. We don't know your big picture. Only you do. When you ask a specific question, we can give you advice how to solve that specific question with the info given...but it may or may not be totally correct taking into everything you need to do (which we don't know). It might only be good for the generic situation in which it was posed.
-
AFAIK, if each subdomain sets a cookie for the specific subdomain, like "subdomain.domain.com", instead of ".domain.com", and domain.com only sets cookies for "domain.com" and not ".domain.com", then the cookies would be secure and only accessible by the domain/subdomain that set them. The cookie should also be a "secure" (https) cookie and be set to HttpOnly. https://www.owasp.org/index.php/Testing_for_cookies_attributes_%28OTG-SESS-002%29 As far as if the url starts with '/admin', you could use mod_rewrite in apache and detect that, and if it starts with that pass the request to "admin.php" or something. Something like: RewriteRule ^admin/?(.*)$ admin.php/$1
-
//basically the same way you got the dir names...with glob() $selected_dir = $_POST['myDirs']; //you called it 'myDirs' in the form. $images = glob($selected_dir . '*');
-
Build a Form with 2 dropdown options that load a specific PDF
CroNiX replied to Mindjakk's topic in PHP Coding Help
Sure thing, glad it's working -
Build a Form with 2 dropdown options that load a specific PDF
CroNiX replied to Mindjakk's topic in PHP Coding Help
Change header('Content-Disposition: attachment; filename="' . $filename . '"'); to header('Content-Disposition: inline; filename="' . $filename . '"'); -
Build a Form with 2 dropdown options that load a specific PDF
CroNiX replied to Mindjakk's topic in PHP Coding Help
Get rid of the echo statements. You can't have those before the header()'s. That's what I meant about "no output before the headers". The way you are coding this also makes it so that the pdf files must be in the same directory as this form_action.php script since you didn't provide a path to the pdf's. -
Build a Form with 2 dropdown options that load a specific PDF
CroNiX replied to Mindjakk's topic in PHP Coding Help
Post the code you're using. The html on the website doesn't show us anything. We need to see the PHP you're using. But if you have a "headers already sent" error, it's most likely because you are sending output to the browser before it tries to send the pdf file...perhaps it's the echo'ing you're doing. No output can be sent before the headers. -
Why are you creating a new thread for this? I answered this question in your last thread. Please continue the discussion in your original thread if you don't understand something instead of creating a new one.
-
Oh I missed that. Don't see the use of creating a function if it's only going to be used once. Might as well just write the code where it's used.
-
Do you really need so many levels of subdomains? That's confusing and ugly and provides no real benefit that I can see. Why not just www.yoursite.com //main site joeq.yoursite.com //Joe Q's main site joeq.yoursite.com/admin (Joes admin panel) Then the cheaper *.yoursite.com can be used
-
There's also no php function called "died()", it's "die()".