Jump to content

nitiphone2021

Members
  • Posts

    85
  • Joined

  • Last visited

Everything posted by nitiphone2021

  1. Dear Friends. Just now I tried to create PHP to make Rest API for my mobile application and I would like to know that it's good coding and need any improve? it is my first time for Rest API. normally I just connect to PHP file directly on .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([0-9A-Za-z_]+)$ function.php?func=$1 [L,QSA] RewriteRule ^([0-9A-Za-z_]+)/$ function.php?func=$1 [L,QSA] on function.php $func = $_GET['func']; switch( $func) { case 'lab_info': //ໜ້າຫຼັກ define( '_FUNC', 'lab_info.php'); break; case 'customer_info': //ຂໍ້ມູນຜູ້ໃຊ້ define( '_FUNC', 'customer_info.php'); break; default: // No function define( '_FUNC', 'functionnotfound.php'); break; } if( defined( '_FUNC') && constant( '_FUNC') !='') require( "func/" . _FUNC); on customer_info.php $error = array(); if(isset($_POST['user']) != 'lung'){ $error['status'] = "422"; $error['title'] = "Authentication Fail"; $error['detail'] = "Invalid user authentication"; echo json_encode($error);die(); } if(!isset($_POST['user'])){ $error['status'] = "401"; $error['title'] = "Invalid Attribute"; $error['detail'] = "Invalid Attribute For Information"; echo json_encode($error);die(); } $result = $conn->query("select Lab_Name,Lab_Username,Lab_Password from tb_labmanagers"); $customer = array(); while($row =mysqli_fetch_assoc($result)) { $customer[] = $row; } echo json_encode($customer); this image attached file is result from postman, client need to send user = 'lung' to get information
  2. But on windows OS, I don't need to set up DNS la. Just install Xampp and access from other computer to the web computer by computer name
  3. Dear All, Now I am setthing Ubuntu server for my intranet network and now I can access the web intranet when we stay on the same wifi network but I can access only the website by IP address. like http://192.168.101.250 so I want to set website name like http://website...... Do you have any idea about it? This one can work on windows by setting computer name
  4. This is the result: Httpful\Response::__set_state(array( 'body' => 'Not Found', 'raw_body' => 'Not Found', 'headers' => Httpful\Response\Headers::__set_state(array( 'headers' => array ( 'cache-control' => 'no-cache, no-store, max-age=0, must-revalidate', 'pragma' => 'no-cache', 'expires' => 'Mon, 01 Jan 1990 00:00:00 GMT', 'date' => 'Wed, 17 Mar 2021 07:58:44 GMT', 'vary' => 'Origin,Accept-Encoding', 'content-type' => 'text/html; charset=UTF-8', 'x-content-type-options' => 'nosniff', 'x-frame-options' => 'SAMEORIGIN', 'content-security-policy' => 'frame-ancestors \'self\'', 'x-xss-protection' => '1; mode=block', 'server' => 'GSE', 'alt-svc' => 'h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', 'accept-ranges' => 'none', ), )), 'raw_headers' => 'HTTP/2 404 cache-control: no-cache, no-store, max-age=0, must-revalidate pragma: no-cache expires: Mon, 01 Jan 1990 00:00:00 GMT date: Wed, 17 Mar 2021 07:58:44 GMT vary: X-Origin vary: Origin,Accept-Encoding content-type: text/html; charset=UTF-8 x-content-type-options: nosniff x-frame-options: SAMEORIGIN content-security-policy: frame-ancestors \'self\' x-xss-protection: 1; mode=block server: GSE alt-svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43" accept-ranges: none', 'request' => Httpful\Request::__set_state(array( 'uri' => 'https://www.googleapis.com/freebase/v1/mqlread?query=%7B%22type%22:%22/music/artist%22%2C%22name%22:%22The%20Dead%20Weather%22%2C%22album%22:%5B%5D%7D', 'method' => 'GET', 'headers' => array ( 'Content-Length' => 0, ), 'raw_headers' => 'GET /freebase/v1/mqlread?query=%7B%22type%22:%22/music/artist%22%2C%22name%22:%22The%20Dead%20Weather%22%2C%22album%22:%5B%5D%7D HTTP/1.1 Host: www.googleapis.com Expect: User-Agent: Httpful/0.2.19 (cURL/7.70.0 PHP/7.4.9 (WINNT) Apache/2.4.46 (Win64) OpenSSL/1.1.1g .4.9 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36) Content-Type: Accept: */*; q=0.5, text/plain; q=0.8, text/html;level=3; Content-Length: 0 ', 'strict_ssl' => false, 'content_type' => NULL, 'expected_type' => NULL, 'additional_curl_opts' => array ( ), 'auto_parse' => true, 'serialize_payload_method' => 2, 'username' => NULL, 'password' => NULL, 'serialized_payload' => NULL, 'payload' => NULL, 'parse_callback' => NULL, 'error_callback' => NULL, 'send_callback' => NULL, 'follow_redirects' => false, 'max_redirects' => 25, 'payload_serializers' => array ( ), '_ch' => NULL, '_debug' => NULL, )), 'code' => 404, 'content_type' => 'text/html', 'parent_type' => 'text/html', 'charset' => 'UTF-8', 'meta_data' => array ( 'url' => 'https://www.googleapis.com/freebase/v1/mqlread?query=%7B%22type%22:%22/music/artist%22%2C%22name%22:%22The%20Dead%20Weather%22%2C%22album%22:%5B%5D%7D', 'content_type' => 'text/html; charset=UTF-8', 'http_code' => 404, 'header_size' => 615, 'request_size' => 460, 'filetime' => -1, 'ssl_verify_result' => 0, 'redirect_count' => 0, 'total_time' => 0.22407, 'namelookup_time' => 0.024054, 'connect_time' => 0.070344, 'pretransfer_time' => 0.160193, 'size_upload' => 0.0, 'size_download' => 9.0, 'speed_download' => 40.0, 'speed_upload' => 0.0, 'download_content_length' => -1.0, 'upload_content_length' => -1.0, 'starttransfer_time' => 0.223987, 'redirect_time' => 0.0, 'redirect_url' => '', 'primary_ip' => '216.58.199.10', 'certinfo' => array ( ), 'primary_port' => 443, 'local_ip' => '192.168.1.118', 'local_port' => 59839, 'http_version' => 3, 'protocol' => 2, 'ssl_verifyresult' => 0, 'scheme' => 'HTTPS', 'appconnect_time_us' => 159930, 'connect_time_us' => 70344, 'namelookup_time_us' => 24054, 'pretransfer_time_us' => 160193, 'redirect_time_us' => 0, 'starttransfer_time_us' => 223987, 'total_time_us' => 224070, ), 'is_mime_vendor_specific' => false, 'is_mime_personal' => false, 'parsers' => NULL, ))
  5. Dear Friend, I am learning to use PHP code for using API and I found that Httpful is good. so I tried to use it but it is error. I ever use this \ but not understand what's meaning of it
  6. How can I use loop to get all information? it is information from database query and it has 2 rows
  7. Sorry, my question is not clear. I want to loop to get all information from the array. it's information from database 2 rows
  8. Dear All, How can I get information that return from this array Array ( [0] => Array ( [id] => 5 [t_test_date] => 2021-02-11 [t_test_number] => 1 [t_uid] => 202102110001 [t_test_type] => 1 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 0 [t_test_time] => 2021-02-11 11:39:00 [t_report_date] => [p_first_name] => tesdt [p_last_name] => tesdt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 11:40:18 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 11:39 ) [1] => Array ( [id] => 7 [t_test_date] => 2021-02-11 [t_test_number] => 3 [t_uid] => 202102110003 [t_test_type] => 2 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 1 [t_test_time] => 2021-02-11 18:38:00 [t_report_date] => [p_first_name] => Hhh [p_last_name] => Tttt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 18:38:51 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 18:38 ) );
  9. I am comming back to build website from my 10 years past. Now I am trying to learn new technology about bbuild website and i don't sure that my knowledge is correct? so I need your suugestion how can make website better. Now My knowledge : HTML, CSS, JS, PHP. JS I only use jquery library and PHP only real code, never use any framework I am thinking about use Axios replace jquery also but not sure it's better. my target is timming of build website faster. example normally I use 1 month for 1 website. How can I use only 2 weeks for 1 website. like this. also security issue. on JS part. I do nothing about security. I protect website on PHP part my use Param concept. Thank you very much for your suggestion
  10. As I am writting a project manager website and I found that I can use datatable to add button infront of row to add more sub program It's work but I want to add the class details-control by a condition So Any way I can do that? var table = $("#requests_lab").DataTable({ data: JSON.parse(data), "aoColumns": [ { "orderable": false, "mData": function (data){ if (data.Project_status >= 4) { return "className": 'details-control',; } else { return "", } } },
  11. Yes, you are right, it is jshjohnson, now i am looking for the way to create javascript to select it. if on javascript, i have var name = AFG and AFG is a value of select option. How can I create javascript to select it? From example is mean create new choice? how about existing choice? const example = new Choices(element, { choices: [ { value: 'One', label: 'Label One' }, { value: 'Two', label: 'Label Two', disabled: true }, { value: 'Three', label: 'Label Three' }, ], }); example.setChoiceByValue('Two'); // Choice with value of 'Two' has now been selected.
  12. I tried to select option base on data-value now my javasript is work for document.querySelector('.choices__item[data-value="AFG"]').setAttribute('aria-selected', 'true'); But I need to add class name and remove some class name, I tried as below code but it's work document.querySelector('.choices__item[data-value="AFG"]').addclass("is-selected is-highlighted");
  13. <div class="choices__list" role="listbox"><div id="choices--p_nationality-do-item-choice-1" class="choices__item choices__item--choice choices__placeholder choices__item--selectable" role="option" data-choice="" data-id="1" data-value="" data-select-text="ກົດເລືອກ" data-choice-selectable=""></div><div id="choices--p_nationality-do-item-choice-2" class="choices__item choices__item--choice is-selected choices__item--selectable is-highlighted" role="option" data-choice="" data-id="2" data-value="AFG" data-select-text="ກົດເລືອກ" data-choice-selectable="" aria-selected="true">Afghanistan</div><div id="choices--p_nationality-do-item-choice-3" class="choices__item choices__item--choice choices__item--selectable" role="option" data-choice="" data-id="3" data-value="ALA" data-select-text="ກົດເລືອກ" data-choice-selectable="">Åland Islands</div> According to I have list option as the code and I want to create a javascript to select it refer by data-id Example I want to make data-value="AFG" selected, how can i do?
  14. Dear All, from begin I have a Button, when user click this button, on javascript will create a input text name and button submit show on dialog of jquery like this var modal_content = '<div id="user_dialog_' + to_user_id + '" class="user_dialog" title="' + office + '">'; modal_content += '<div style="height:310px; overflow-y: scroll; margin:0px; padding:0px;" class="chat_history " data-touserid="' + to_user_id + '" id="chat_history_' + to_user_id + '">'; modal_content += '</div>'; modal_content += '<div class="form-group">'; modal_content += '</div><div class="form-group" align="right">'; modal_content += '</div>'; modal_content += '<hr style="margin:10px;padding:0">'; modal_content += '<div class="input-group">'; modal_content += '<input type="text" name="chat_message_' + to_user_id + '" id="chat_message_' + to_user_id + '" placeholder="ພິມຂໍ້ຄວາມຢູ່ບ່ອນນີ້" class="form-control chat_message" style="border: none;">'; modal_content += '<div class="input-group-append">'; modal_content += '<span class="input-group-text" style="background-color: transparent !important;border: none;padding:0"><div class="filediv"><input type="file" id="file"><label for="file-7"><strong><i class="fa fa-file fa-lg ml-1" aria-hidden="true"></i></strong></label></div><i name="send_chat" id="' + to_user_id + '" class="fa fa-paper-plane fa-lg pl-1 mb-1 send_chat" aria-hidden="true"></i></span>'; modal_content += '</div>'; modal_content += '</div><span id="attachedfile"></span><script>$("#chat_message_' + to_user_id + '").keyup(function(event) {if (event.keyCode === 13) {$("#' + to_user_id + '").click();}});</script>'; $('#user_model_details').html(modal_content); so I tried to create a script as below to get enter key of input text name then make like user click on the button. If I tried to double enter then I will get below error message I don't know why it's not work. Do you have any idea to fix it?
  15. According to i upload my mpdf to my real host on internet and try to print pdf out but i got fail at code below: I dont't know why this code $mpdf = new \Mpdf\Mpdf(); cann't work it's print out only "01" echo "0"; require_once __DIR__ . '/vendor/autoload.php'; echo "1"; $mpdf = new \Mpdf\Mpdf(); echo "2"; $mpdf->WriteHTML('Hello World'); $mpdf->Output('filename.pdf');
  16. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z_]+)$ function.php?func=$1 [L,QSA] RewriteRule ^([a-z_]+)/$ function.php?func=$1 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/?$ function.php?lang=$1&func=$2 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/([a-z_]+)/?$ function.php?lang=$1&func=$2&sub=$3 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/([a-z_]+)/([0-9]+)/?$ function.php?lang=$1&func=$2&sub=$3&my_id=$4 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/([a-z_]+)/([0-9]+)/([0-9]+)/?$ function.php?lang=$1&func=$2&sub=$3&parent_id=$4&my_id=$5 [L,QSA] as my purpose code,I want to send parameter of url to my function.php and make decide that the request can access the URL. but as my tried, If I go to put the URL on brownser as normally, it's work. ---- If I use ajax go to the URL, it's no need authentication of function.php make decide. Is it right ?
  17. 1 . RewriteRule ^([a-z_]+)$ function.php?func=$1 [L,QSA] 2 . RewriteRule ^([a-z_]+)/$ function.php?func=$1 [L,QSA] 1. It's correct that we use both command line? or we just use only one line? 2. below command it's mean (if user request a existing file, then process next command?) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
  18. I changed htaccess to .htaccess but the result still the same
  19. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z_]+)$ function.php?func=$1 [L,QSA] RewriteRule ^([a-z_]+)/$ function.php?func=$1 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/?$ function.php?lang=$1&func=$2 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/([a-z_]+)/?$ function.php?lang=$1&func=$2&sub=$3 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/([a-z_]+)/([0-9]+)/?$ function.php?lang=$1&func=$2&sub=$3&my_id=$4 [L,QSA] RewriteRule ^([a-z]+)/([a-z_]+)/([a-z_]+)/([0-9]+)/([0-9]+)/?$ function.php?lang=$1&func=$2&sub=$3&parent_id=$4&my_id=$5 [L,QSA] I think .htaccess will be the first file when user request to and I try to send paramter to file function.php to show the request URL of user. but when I tried it. brownser open index.html file. question: 1. why not open function.php? 2. function.php can get parameter by $_POST or $_GET? http://localhost/testsmarty/
  20. I created a login form for my system and I don't sure that it's enought for security to protect my website? include("database.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form $stmt = $conn->prepare("SELECT Sale_ID FROM tb_sales WHERE Login_Name = ? AND Login_Password = ? LIMIT 1"); $stmt->bind_param("ss", $_POST['username'], $_POST['password']); $stmt->execute(); $res = $stmt->get_result(); $count = mysqli_num_rows($res); if($count == 1) { // session_register("myusername"); $_SESSION['login_user'] = $_POST['username']; echo "Login Succcess"; //header("location: index.php"); }else { echo "Your Login Name or Password is invalid"; } }
  21. I have a problem about the javascript datepicker. in index.html it has startdate and enddate it's work but when i click a button, it will open new modal up and the new modal has a date picker(I create it again as below command ) but it's not work, this datepicker name SamplingDate is not create from beginning and startdate & enddate create from begining var col4 = "<div class='row p-2'><div class='col'><label>Send Sampling Date:</label><div div class='input-group date'><div class='input-group-prepend'><span class='input-group-text'><i class='far fa-calendar-alt'></i></span></div><input type='text' class='form-control' data-inputmask-alias='datetime' data-inputmask-inputformat='dd/mm/yyyy' data-mask='' inputmode='numeric' id='SamplingDate'></div></div></div></div>"; var formupdate1 = col1.concat(col2,col3,col4,col5,submit); document.getElementById('Updateform').innerHTML = formupdate1; Work, startdate and enddate after load page $('#startdate').datepicker({ autoclose: true }) $('#enddate').datepicker({ autoclose: true }) // not work $('#SamplingDate').datepicker({ autoclose: true })
  22. If I don't want to create real table, is there any way can create temp table?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.