- Strength to Increase Rep
- +13
- Strength to Decrease Rep
- -3
- Upvotes Received
- 555
- Posts with Upvotes
- 382
- Upvoting Members
- 169
- Downvotes Received
- 9
- Posts with Downvotes
- 9
- Downvoting Members
- 8
I've been doing all sorts of thing within the IT area. Started on Spectrum for fun back in eighties I started to seriously engage in CAD (Microstation, MDL, Autocad, Lisp) in nineties and then shifted to IT security (smartcards, PKI, e-banking...) and…
- Interests
- My spare time is mostly spent for music. I play keyboards in a seven piece band.
- PC Specs
- HP ProDesk i5, Ubuntu 17.10 at home, Windows 10 at work
812 Posted Topics
Re: The image method: http://www.fpdf.org/en/doc/image.htm The tutorial: http://www.fpdf.org/en/tutorial/tuto2.htm | |
Re: Now, there might also be a problem in the password field definition in the table spec: `password varchar(20) NOT NULL`. As far as I remember the good old MD5 produces a hash of lenght that fits into CHAR(32). So password hashes stored in the users table could be truncated due … | |
Re: This is interesting, thanx for sharing. But what were the requirements for this kind of script? Is this a part of a production application? And did you have to implement any security (so the whole world does not start sending thousands of pages to your printer)? | |
Re: If you intend to use quotes arround field and table names in Mysql you must use backticks, not single or double quotes. However they are not required if table and field names are not same as Mysql keywords/reserved words which is your case anyway. See the list of Mysql keywords … | |
Re: In first version you are missing the other condition ($_SESSION['iiio'] != "pending"). In that case the div is shown by default. It looks like you are using Bootstrap so you can use the `show` and `hidden` classes provided by Bootstrap. I am using ternary expression here since it is most … | |
Re: The code is basically OK except for the `return` statements. Why do you use them? Are the PHP scripts being called using the `include/require` statements? And make sure your first script has the `.php` extension (not the `.html`). | |
Re: Not sure what exactly is the expected workflow but few notes anyway: The PHP code in the beginning of the test.php should probably only execute after form submission or when the `$_POST` values are set so maybe perform a check or you might get errors/warnings: if(isset($_POST['submit'])) { $user = $_POST['user']; … | |
Re: Quite many issues here: The following code is not valid: $valueToSearch = $_POST['requirementtype' 'build' ]; You can not have two strings as an array index. They should be separated in i.e two variables like so: $searchRequirementtype = $_POST['requirementtype']; $searchbuild = $_POST['build']; These two values should be escaped before used in … | |
Re: You can get the variables out of sight by using POST method in your form or call instead of GET which you are using in above example. If you use POST the variables won't be part of the URL instead they will be "hidden" in the HTTP header. Mind you … | |
Re: The ID that appear in the URL depends on the field names of the form that sends the data. A field in your form probably has a name attribute that equals to `id` and information entered into that field goes into the `id` variable in the URL. I would recommend … | |
Re: You should do it in a similar fashion. I presume the information about the gender is stored in a database for each user. When they login you read this information and redirect based on it. Something like: if($row['gender']=='Couple MF') { header('location:landingpage2MF.php'); } else if($row['gender']=='Couple MM') { header('location:landingpage2MM.php'); } else if... | |
Re: If you want to use a variable inside a string then the string must be enclosed in double quotes. [CODE]$var = 'foo'; echo "Variable value: $var";[/CODE] will display: [CODE]Variable value: foo [/CODE] while[CODE]$var = 'foo'; echo 'Variable value: $var';[/CODE]will display: [CODE]Variable value: $var[/CODE] See [url]http://www.php.net/manual/en/language.types.string.php[/url] ![]() | |
Re: EDIT: I noticed after posting that the javascript functions are meant to be in a separate JS file. Disregard my 1. remark, sorry. Had a quick look at the code and there are two obvious error: 1. The Javascript functions are outside the `<html></html>` and outside the `<body></body>` pairs which … | |
Re: You can also check how the query gets constructed, using similar technique as described above by cereal. Just add this between line 2 and 3: die($query); This will print out the query on the screen and stop the script. Now you can inspect the query whether it has all the … | |
Re: If you have a fixed number of variables (known in advance and equal to the lenght of the `$row`) you could use the [list](http://php.net/manual/en/function.list.php) function. Something like: list($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m) = $row; But be aware that using an array instead … | |
Re: You can not subtract two strings representing dates on line 4 and expect to get a difference. Besides the variables on line 4 have not been declared anywhere (but I guess you just misstyped them). The best thing to do is to use the [DateTime](http://php.net/manual/en/class.datetime.php) and the [DateInterval](http://php.net/manual/en/dateinterval.format.php) PHP classes. … ![]() | |
Re: Looking at your code the new_entries table is in another database (`newentries`). Is that what you really wanted to do? You are duplicating rows (althoug in another database) so maybe you first review your DB design. If that is OK, make sure connection to the `newentries` database is OK and … ![]() | |
Re: Quite many issues here, some big, some smaller. I'll try to comment on some without any particular order of importance. 1. On line 9 you try to concatenate some unknown constant. It should be either a variable (i.e. `$error`, but defined somewhere) or mysqli's error function `mysqli_connect_error()`. 2. I strongly … | |
Re: I tried your code and the table gets generated OK. I get this: Age Beg Bal Interest Deposits Ending Bal 45.00 2000.00 324.65 1200.00 3524.65 46.00 3524.65 521.09 1200.00 5245.75 47.00 5245.75 742.58 1200.00 7188.33 48.00 7188.33 992.31 1200.00 9380.63 49.00 9380.63 1273.87 1200.00 11854.50 50.00 11854.50 1591.33 1300.00 14745.83 … | |
Re: Use [PHPExcel](https://github.com/PHPOffice/PHPExcel) to create Excel file from the data you read from the database. Dynamic headers are just headers that contain text and formulae in them (the header changes if the information in the respective column changes). You have to build those formulas yourself. | |
Re: If this is a guide how to do something it has serious issues: * POST variables are not being sanitized so arbitrary code can be injected * An old and deprecated mysql extension is used So sanitize (check, validate, cast, replace, blacklist, whitelist...) the post data and switch to the … | |
![]() | Re: > Is it possible to do a nested checkbox It is, but you will have to code. Use Javascript or even better jQuery to listen to the click event and to check related checkboxes upon clicking the main one. It is easier if you put related checkboxes in a container … ![]() |
Re: Displaying images in a grid is probably better since your page will be displayed nicely on mobile devices - provided that your grid is set-up properly. You can use a proven framework for that such as [Bootstrap](http://getbootstrap.com/). If you want to display images in pages use pagination - google for … ![]() | |
Re: If you want to prevent unauthorised users from displaying the iamges you can encrypt them using [mcrypt_encrypt](http://php.net/manual/en/function.mcrypt-encrypt.php). But be aware that you have to deal with key management to be able to decrypt later. By that I mean generating secure keys, securely storing the keys not to expose, corrupt or … | |
Re: I can't test the code since I am on Linux and using Firefox and Chrome. However my recommendation is that you use [jquery](http://jquery.com/) functions in your javascript code since jquery is meant to abstract browser differences. Looking at your code you did include jquery library but are not using it. … | |
Re: PHPExcel site is [here](http://phpexcel.codeplex.com/), documentation is [here](https://github.com/PHPOffice/PHPExcel/wiki/User%20Documentation%20Overview%20and%20Quickstart%20Guide). Great library, I have used it many times. | |
Re: Try : echo $user_data[0]['fullname']; since fetchAll returns a set of all the rows (only one in your case). | |
Re: You could use jquery ajax [post](http://api.jquery.com/jQuery.post/) method. The data for the post would be all the parameters, that are needed for the public function. The page won't refresh but you will still be able to carry out the insertion into the database. But you need a javascript event to triger … | |
Re: Or use more jquery-like approach, where you catch onclick event in jquery: <button type="button" class="btn-login" id="btn-login">Login</button> ... <script> $("#btn-login").on("click", function() { toggle_visibility('foo'); toggle_visibility('sidebar'); toggle_visibility('tiles'); toggle_visibility('wsf') }); </script> </body> | |
Re: You have 5 rows of select element and checkboxes so you have to keep track of which row a user has selceted / checked. You can do this if you add row number to the name attributes. So for row No. 1 the attribute would be: <select name="lang[1]"> <input name="speak[1]" … | |
Re: Are you using jquery or pure javascript? | |
Re: http://api.jquery.com/jquery.ajax/ You might have to do a bit of learning if you are not familiar with Ajax. | |
Re: Not sure if I understood ypur question but I'll have a go at it. The `mysqli_insert_id()` function returns the ID generated by a query on a table with a column having the `AUTO_INCREMENT` attribute (sentence copied from the [PHP manual](http://php.net/manual/en/mysqli.insert-id.php)). Now, in your insert query the ID is not treated … | |
Re: Assuming that you use the POST method the users name should be in the $_POST array. Read it from there. Details depend on whether you have insertion script and the form in the same script or not. Maybe you post your code. | |
Re: You use one of jquery [ajax methods](http://api.jquery.com/category/ajax/), i.e. `$.ajax()`. HTTP method should be `POST` since you are updating data (see some in-deepth explanation [here](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) and some simpler explanation [here](http://www.w3schools.com/tags/ref_httpmethods.asp)). You supply the data to be inserted in [JSON](https://en.wikipedia.org/wiki/JSON) format. The `$.ajax` method is usually called with a click event (e.g. … | |
Re: http://www.html-form-guide.com/php-form/php-form-checkbox.html and thousands of other resultls using duckduckgo search for *php checkbox example* (you can also try google) | |
Re: Test the insert statement. Put this simple debug code just before line 60: die($q); This will echo the insert query on screen and stop the script. Now inspect the query whether it is OK and copy and test it in phpmyadmin (or whatever you use). Also, you check if user … | |
Re: Nowhere you check if password and username have been entered which is not a good practice and might be a reason for your error. You should do it this way: if(!isset($_SESSION['auth_user']) && isset($_POST['cedula']) && isset($_POST['clave'])) { loginuser(); } Also use curly brackets even if you have only one statement, to … | |
Re: In my knowledge the `cal_days_in_month` function already takes into account leap years. I think the error is in line 10: $Start_Date="1/".$month."/".$year.""; To make string representation correct it should be in a format that represents a unique date (i.e. American month, day and year - `mm "/" dd "/" y`): $Start_Date=$month."/"."1/".$year.""; … ![]() | |
Re: Have you checked Apache log files? If you use xampp they should be in C:\xampp\apache\logs. | |
Re: Do not forget security if you want to be a really good web developer. Familiarize yourself with [OWASP top 10](https://www.owasp.org/index.php/Top_10_2013-Top_10) threats and guidelines how to handle them. Regarding graphics skills learn vector graphics and software like Inkscape. It often helps when bitmap graphics does not suffice. ![]() | |
Re: What would you like to do when `case 0`? I think `case 0` is when the import went without any problems. Then you don't have to do anything else apart from letting users know (which has already been done). ![]() | |
Re: If I understood correctly you just want to skip first row which is heading row. If that is true then start inserting at row 2. Something like: $heading = true; while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { // check if the heading row if($heading) { // unset the … | |
Re: Also, the method name in `$this->__('Email Me')` does not seem to be valid or is my knowledge of PHP a bit shaky? | |
Re: Line 7: change it to (add the $ sign): if ($username && $password) Hopefully you use prepared statements or do some sanitizing of input variables before using them in queries/urls/html/mail/script. | |
Re: There is no form in this script. What is the purpose here? | |
Re: Or use recursion, maybe sometnihg like this (not thoroughly tested, just to show the concept): function findMax($array, $curMax) { foreach($array as $val) { if(is_array($val)) { $curMax = findMax($val, $curMax); } else { if($curMax < $val) { $curMax = $val; } } } return $curMax; } // Usage arr[0][0] = 53; … | |
Re: There seem to be no syntax errors. Why do you assume there is an error? Do you get any messages? Is the result not what you expected? What is different from what you expected? | |
Re: Depending on what your password requirements are and what your approach is. Once you hash a password the hash will contain only database safe characters. I would expect you do not need so much a filter but a password quality checker. | |
![]() | Re: I've been a long time Eclipse user. Not very advanced usage though, there are still things that I don't quite understand or like. But I like the fact that I was able to switch between Windows (current job) and Linux (previous job, home) environments without much hassle. Also OOP, JS … |
The End.