PHP - File Handle For Php Checkbox
May you help me with how to get a file handle for a checkbox. I mean something that will output a 1 or 0...
thank you Similar TutorialsHow can i handle what the user clicked in the Save File Dialog Box? if(user clicked "save") { i will send them an email; } else if (user clicked "cancel") { i will not send them an email; } is this possible? Please help me out guys. Thankyou Hi can someone assist me with adding a second upload that grabs all files from within a directory. 1. user select .csv file (coding down for that) 2. user select folder with .docx files in side (this folder will only have docx files) 3. on submit .csv and all .docx files are upload to /temp_docx/ folder 4. the .csv has a matching docx_id that relates to the .docx file name (ex file 1.docx == docx_id = 1 in the csv file) so every time an insert is done a move_file happens and 1.docx would be moved to /docx_files/ 5. and if there is ever an error or no match at the end output all errors. I think the part where i'm stuck and confused the most is handling the second upload where all docx files in the folder are upload and looped through moving and inserting Code: [Select] <?php if(isset($_POST['submit'])) { $filename = file_get_contents($_FILES['uploadedfile']['tmp_name']); $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) { $import="INSERT into kmmb_member1(docx_id,no_ahli,no_pin,nama,no_ic_baru,no_ic_lama) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]')"; mysql_query($import) or die(mysql_error()); } fclose($handle); print "Import done"; } else { print "<form action='import.php' method='post'>"; print "Type file name to import:<br />"; print "Select csv file: <input name='uploadedfile' type='file' /><br />"; print "<input type='submit' name='submit' value='submit' /></form>"; } ?> Hey all need some help with the subject title. Have a user text file with all information(Name, address, passwords, etc..) Need to be able to select the user based on Checkbox selection then hit delete button and all users checked will be removed from the txt file and thus removed from HTML page. Im using PHP to show contents of the txt file into my HTML page. So far i have: <?php $file = fopen("user.txt","r"); echo '<table border="0" width="100%"> <tr> <th>Select</th> <th>Username</th> <th>Password</th> <th>FirstName</th> <th>LastName</th> <th>Email</th> <th>Address</th> </tr> '; while(!feof($file)) { $user = explode(":", fgets($file)); echo '<tr> <td><input type="checkbox" name="chkDelete" id = "chkDelete" value="select" /></td> <td>' . $user[0] . '</td> <td>' . $user[1] . '</td> <td>' . $user[2] . '</td> <td>' . $user[3] . '</td> <td>' . $user[4] . '</td> <td>' . $user[5] . '</td> </tr>'; echo '</table>'; fclose($file); ?> Am unsure as to how i would go about doing this, help would be greatly appreciated! Thanks in advanced, Daniel. So i got a table that looks somthing like this: File Name | Download | Suggested Catagory | Select Catagory | Approve -------------------------------------------------------------------------------------- test | Download | blah blah blah | Option menu | yes or no option menu test | Download | blah blah blah | Option menu | yes or no option menu test | Download | blah blah blah | Option menu | yes or no option menu what I want to do is in the file that processes this it only looks at the ones that have had the "approve column" submitted as a yes. Next it will to a mysql entry into verrified notes. Problem is with X amount of entries in that form I dont know how to look at only the ones that have said yes. Do I create a new form for each entry or put them all as one entry and after this what do I do next? Okay, so now I need help evolving my Log-In system... Up until now, the only place a user could log-in was on a given Article page if they wanted to add a comment to the Article. To accommodate that feature, I was setting the "Return To Page" only in my "article.php" script like this... Code: [Select] $_SESSION['returnToPage'] = $_SERVER['SCRIPT_NAME'] . '?title=' . $articleTitle; However, now I want to expand things. I'm growing increasingly confused about how to manage where to route people when they long-in?! 1.) Sometimes a user will Log-In and want to return where they were at (e.g. index.php, article1234.php) 2.) Sometimes a user might want to continue down a path (e.g. Checking Out, Registering for a Workshop, Sending a Message) Is there some kind of strategy to handle this? (nothing over complex, but there must be some Best Practices that work?! Debbie So I'm sitting at my desk scratching my head on how to do a task where I pull information form a database (that i know how to do) but then i need to see if two variables equal a string and if they do count out how many times that two variables equal there two string checks and out put the counted number ? this is what I have thought of but dose not to work because I cant figure out a way to code it? $dbPull = mysql_fetch_array($result) if( $dbPull['Foo'] == 'string1' && $bdPull['Bar'] == 'string2') this is were I get lost I'm looking for (how many times in the DB dose String2 show up in the array were the above, IF statement is true ) any ideas would be most appreciated I have just completed a modest way for Users to post Comments on Articles my website. However, the thought occurred to me today, that I haven't given Users the ability to Preview or Edit their comments after submittal. What is the best way to store info on a Comments Form so you can re-display it for Preview/Editing?? (I'm not really sure how the workflow would work for this?!) Do I capture the Comments Form Data and store it in a Session? Or in my Database? Or do something else? Security is always a concern of mine too!! Thanks, Debbie Hi All. New at this, form is working perfect, then added recapthca, now it only handles recaptcha and not the form. not sure where the error is
How do I make my constructor work when I don't pass in an argument. That is, it should efault to null. Code: [Select] class Something{ private $type=null; public function __construct($t){ $this->type = $t; } public function setSomething($t){ $this->type = $t; } public function getSomething(){ if (is_null($this->type)) { return "None for you!"; } else { return "Something is " . $this->type . "."; } } } TomTees Is there a "PREFERRED METHOD" to handling telephone numbers gathered by a form? I'm torn between ideas. I need to collect the numbers, and want to be able to view them as (123)555-1212. Should I collect them as a 10 digit ONLY string, and strip them into area code, parenthesis, and hyphenated LATER? Or gather them as 3 seperated input boxes posted to the DB accordingly? Obviously, entries will have REQUIREMENTS and error messages, so I am focused on the methodology here. Thanks. I have 2 PHP scripts : opendb.php and closedb.php In opendb.php I have this code :
<?php
In closedb.php I have this code :
<?php When I run opendb.php I get the expexted message "DB Open." But when running the closedb.php , I get an error 500. I was hoping to be able to pass the Handle, needed to operate in my database, between PHP scripts, by pushing it into $_SESSION['dbhandler'] , and retreiving it in other scripts. Is this possible ? Regards,
Martin Hi, New to coding so pls bear with me.... I am running into a continual issue that wonder if there is a better way to handle it. When writing code that handles GET variables that have not been set I use the isset function with if statements to handle it, but my code looks like it is getting sloppy and I am having to repeat it a lot - for example: Every time I simply want to call a class / function that I want to pass avGET i have to do the following: Code: [Select] if (isset($_GET["filter"])){$theFilter = $pageination->filter($_GET["filter"]);} else {$theFilter = $pageination->filter();} Here is a copy of the class I have created (note sure if it works yet as not fully tested it) Code: [Select] class pageination { private $recordLimit=100; public function filter ($filter="") { if ($filter!=""){ $theFilter=" AND ".$filter; return $theFilter; } else { return $theFilter=""; } } private function pageCnt ($pageCntRst) { $pageCnt=intval($results[$pageCntRst]); return $pageCnt; } public function pageNmLnk () { echo 'Page: <a href="?pageStartListings=0&filter='. $_GET['filter'].'">1</a>'; } //This loops through every 100 pages public function pageNmLoop ($pageCnt) { for ($n=1; $n<=$pageCnt; $n++){ if ($n > $recordLimit) { break; } if ($n*$recordLimit==intval($_GET["pageStartListings"])){ $stylePg = 'style="border: 1px solid #aaaaaa; background-color: #CCCCCC; padding:3px; "> ' . $n+1 . '</a>'; } else{ $stylePg = ''; } echo '| <a href="?pageStartListings=' . $n*$recordLimit . '&filter=' . rawurlencode($_GET["filter"]) . ' " ' . $stylePg; } } } $pageination = new pageination (); ?> I use the GET a few times in the code and I have to write a lot of code around the isset and if statements to handle it all the time - thinking there must be a better way to do this or a function that can be built to test it? Any help is grateful in advance. Hi all. I'm new to PHP language and I'd like to know which is the best way to handle the user login. With cookies or with sessions? Do you know some example on the web that I could inspire on? I just know how to do it in both way, I just wanna know which is the best way and like to read some code written by a pro. Dusting off my PHP skills after some time! How would I do this... Code: [Select] IF form was submitted THEN do some PHP stuff and do not show the form again ELSE display the form for the first time Is it as simple as wrapping my HTML inside an If-Then-Else? Debbie I have an application where things are requested/computed/shown using either Metric or English systems.
I am thinking that the best way to handle this is to store units in one system, i.e English (as I am in United States), and to only convert them to Metric for the View, when it is being requested.
And if Metric parameters are being inputted through a form, then convert them to English on input.
So in a word
* store, compute, anything back-end, do it in English system.
When anything Metric shows up, then
* convert-on-output to Metric
* convert-on-input from Metric
Does that sound like a good plan?
Are there any other equally or better-than plans to deal with systems?
Hi guys On the edit profile page on my website, im trying to get is so that when the user first opens the page, if the database field reads "1" the checkbox is checked. However if the user unchecks it and makes a mistake on the form which returns an error, the checkbox remains unchecked. Also if the user unchecks the text box, the 1 in the database is changed to a 0. And vise versa. The only way i have got it to work succesfully is by using the following: <?php $test = $_POST['test']; $submit = $_POST['submit']; if (!isset($test)) { $test="0"; } else { $test="1"; } if ($submit) { mysql_query("UPDATE profiles SET test='$test' WHERE username='user'"); echo "ok"; } ?> <html> <form action="test.php" method="POST"> <input type="checkbox" name="test" <?php if ($submit) { if ($test=="1") { echo "checked='checked'";}} else { if ($row['test'] == "1") {echo "checked='checked'";}} ?> /> <input type="submit" name="submit" /> </form> </html> My problem is, i have about 60 check boxes on the page, and i dont really want to write the code below for all of them: if (!isset($test)) { $test="0"; } else { $test="1"; } Does anybody know a better way to do this so i dont end up with 420 lines of extra code? Many thanks. I was wondering if there's any common method for user management. I'm not talking about basic stuff like DB management stuff I'm talking about registering new users with captcha, validating email addresses, password resets, etc. I can work all this stuff out by hand but it seems rather large and very repetitious so I was wondering if there's guides out there to develop this or a common script? I need to come up with a better way to do this. Currently I have a script which is a form and the user enters their email address, and their password in the database is sent to the email address. Problem is the password is MD5 hashed, so it's hashed when sent to their email. I am sure there is a better way to do this. Also, I am capturing a Security Question and Answer in the initial profile form that the user fills out, so I need to incorporate this as an extra layer of security. Please let me know of the methods for doing this. Thanks in advance! I have a script that takes a 2 or 3 page pdf, uploads it and hashes the file name to something that isn't guessable. We now want to add an image of each of the PDF for users who don't have Adobe Reader. Some pdf's will be 2 and some 3 pages. Should I: A) Let convert name the different pages "*-0.jpg, *-1.jpg..." and then use a recursion function (it's already written for another reason) to crawl the folder, B) Use a PHP/PDF library to determine the number of pages, then add the value to the database's corresponding row. C) Use a hybrid of both D) Any better ideas??? Thanks
I'm currently trying to building a websocket widget, using node package manager(NPM),WAMPserver and electronjs. |