Posts

Showing posts with the label php

How to Rename images while uploading in add / remove dynamic fields

How to Rename images while uploading in add / remove dynamic fields I am creating a project in which I have created several Dynamic Add/Remove fields. Every thing is working perfectly and have no issues. I have created add/remove image file fields. When I upload images it gets uploaded perfectly. But I want these images to get rename using rand() function. rand() <?php if ( isset( $_POST['project_draft'] ) ) { $member_details->member_image = array_map( 'sanitize_file_name', $_FILES['member_image']['name'] ); $member_details->member_name = array_map( 'sanitize_text_field', $_POST['member_name'] ); $member_details->member_role = array_map( 'sanitize_text_field', $_POST['member_role'] ); $member_details->member_email = array_map( 'sanitize_text_field', $_POST['member_email'] ); $member_details->member_facebook_id = array_map( 'sanitize_text_field', $_POST['member_facebook_id'...

Save linebreaks in textarea to tpl file with php

Save linebreaks in textarea to tpl file with php I want to edit html code in a textarea and then save it to a tpl-file. When opening the template file with my desktop editor the linebreaks should just look like in the textarea, so no n or br-tag (if not actually wanted for the code) in it. Thanks for any help! Ah, changing from tpl to txt when googeling did the trick. $code = str_replace('n', PHP_EOL, $code); – user2822542 Jul 1 at 10:51 What do you mean by "changing from tpl to txt"? – Nico Haase Jul 1 at 11:05 By clicking "Post Your Answer", you acknowledge that you have re...

php check if gravatar exists header error

php check if gravatar exists header error I'm trying to check if a gravatar exists. When I try the approach recommended in earlier questions, I get an error " Warning: get_headers() [function.get-headers]: This function may only be used against URLs" Anyone seen this or see the error in my code? PS I do not want to specify a default image for gravatar to serve as there could be more than one default possibilities if no gravatar exits. Also, I found a reference to error possibly being related to my ini file which I don't think my host gives me access to. If so, is there an alternative to getheaders? Many thanks. $email = $_SESSION['email']; $email= "person@gmail.com"; //for testing $gravemail = md5( strtolower( trim( $email ) ) ); $gravsrc = "http://www.gravatar.com/avatar/".$gravemail; $gravcheck = "http://www.gravatar.com/avatar/".$gravemail."?d=404"; $response = get_headers('$gravcheck'); echo $response; e...

How can I do to use Angular 5/6 for frontend and Codeigniter 3 for backend in the web same app?

How can I do to use Angular 5/6 for frontend and Codeigniter 3 for backend in the web same app? I want to buid a web using Angular 6 for frontend and Codeigniter 3 for backend . The problem is that I don't know how to combine the two, and all the tutorials I looked were using AngularJS which is the version 1 whereas i'm using version 6 , and it didn't really work. I am looking for something like JavaScript & CSS Scaffolding using Angular 6 (and not AngularJS ) with Codeigniter 3 What I want is to set the view to be the Angular app and let Codeigniter do the routing and handle the server Can anyone help me?? 1 Answer 1 You can create APi's in codeigniter and then implement those in Angular or any other front end language. I forgot to tell I am new to this, so please can you tell me exactly how to do that or redirect me to a place where I can find ...

Checkbox an values to transmit to database

Checkbox an values to transmit to database I'm new here and I need help with a PHP code. I want to transform a radio button into a checkbox, make it calculate the fee depending on how much checkboxes are checked, and to transmit the checked values to the predefined database. My code only takes the one predefined value for fee an doesn't actually adds them up when I click on the other checkbox. I tried everything but with no success. Here is the original unchanged code: <script src="<?php echo URL_FRONT_JS;?>jquery.js"></script> <script> function get_tutor_course_details() { course_slug = $('#course_slug option:selected').val(); selected_date = $('#start_date').val(); if(!course_slug || !selected_date) { $('#fee').text(''); $('#duration').text(''); $('#days_off').text(''); $('#content_li')....

How can we include php files without specifying the subfolder path

How can we include php files without specifying the subfolder path Normally we use the following code to include php files inside each other: <?php include_once 'include/config.php'; // OR include 'include/config.php'; // OR include_once $_SERVER['DOCUMENT_ROOT'].'include/config.php'; // ect... ?> But the above codes only apply if the php files are in the root file. I mean, if we move our files into a subfolder. We need to make a change to the code we included in the php files. For example like this: <?php include_once 'subfolder/include/config.php'; // OR include 'subfolder/include/config.php'; // OR include_once $_SERVER['DOCUMENT_ROOT'].'/subfolder/include/config.php'; // ect... ?> What I'm saying is that when we move our php files into the subfolder, then include_once want to see subfolder name like ( include_once 'subfolder/include/config.php'; ). This is a challenging s...

WooCommerce woocommerce_admin_settings_sanitize_option use

WooCommerce woocommerce_admin_settings_sanitize_option use I'm currently using the action woocommerce_update_option_X to save the settings of my plugin settings page. However, the following error occurs: woocommerce_update_option_X action is deprecated, use woocommerce_admin_settings_sanitize_option filter instead But when I try to find information on that filter, I can't figure out how to use it in my case. In my settings I have a table with fields that has to be saved. The table looks like this: ... <tbody> <?php $max_settings = get_option('max_settings',array()); foreach ( $max_settings as $data ) { ?> <tr> <td><input type="text" value="<?php echo esc_attr( $data['var'] ) ?>" name="max_settings[var]" /></td> <td><input type="text" value="<?php echo esc_attr( $data['productid'] ) ?>" name="max_settings[productid]" /></td> ...

Traversal tree - repair

Traversal tree - repair please, do you have any tips, where to find code or solution, how to repair traversal tree? I have table with cols lft, rgt, parent_ID and lvl and when I was moving nodes in this tree, I had fail in code so it broke lft and rgt indexes and I need to recount it. One solution, which I think is applicable is getting all nodes from table, store in array for example, clear table and recreate it, but this solution is not so efficient I think. Do you have any tips, how to solve it better? Thank you very much :) Please read: How to create a Minimal, Complete, and Verifiable example and also How do I ask a good question? – Magnus Eriksson Jul 1 at 9:14 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, p...

How to save E-mails from Comment

How to save E-mails from Comment i am very new with html/css too with php and my English is very poor.. so , my problem ... , i have this code: <?php date_default_timezone_set('Europe/Paris'); $content = ""; if(file_exists("messages.inc.html")) $content = file_get_contents("messages.inc.html"); if(isset($_POST['post'])) { $time = date('Y-m-d H:i:s'); $content .= "n<b>From:</b> " . htmlspecialchars($_POST['name']) . " <b>eMail:</b> " . htmlspecialchars($_POST['email']) . " <b>at:</b> $time<br><br>" . htmlspecialchars($_POST['text']) . <"hr">; file_put_contents("messages.inc.html", $content); } ?> <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> <title>Message schreiben</title> </head> ...

printing data a specific number of times with respect to a const and string length

Image
printing data a specific number of times with respect to a const and string length Let there be a sring $str with any number of characters and $cons=25 , also $rest=$cons-strlen( $str ) . $str $cons=25 $rest=$cons-strlen( $str ) Now i wanted to print the string inside boxes so i made a loop where it catches the characters inside the string and echo it inside a div with class w3-border Css: .w3-border { border: 1px solid #f1e1d4 !important; width:16px !important; height:25px; border-collapse: collapse; float: left; } Php: echo'<div class="w3-container" style="margin-bottom:5px !important">'; $str = $row['address']; $strlen = strlen( $str ); $rest=$cons-$strlen; echo'<div class="w3-left" style="width:150px">Address</div>'; for( $i = 0; $i <= $strlen; $i++ ) { $char = substr( $str, $i, 1 ); echo '<div class="w3-border w3-center">'.strtoupper($char).'</div>'; } if...

Can't receive PHP object by using AJAX

Can't receive PHP object by using AJAX I can't fetch the php file from the ajax. Firstly an object is created in the PHP file, then it is converted into JSON by using json_encode() function. The problem is: when I request that PHP file from ajax, nothing is shown as an output. ('Smith' is supposed to be an output though) Here is my php file: 1.php <?php $myObj->name = "Smith"; $myObj->age = 20; $myObj->Address = "Yangon"; $myJSON = json_encode($myObj); echo "$myJSON"; ?> Here is ajax file: ajaxfile.php <p id="demo"></p> <script type="text/javascript"> var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if (this.readyState == 4 && this.status == 200) { var myObj = JSON.parse(this.responseText); document.getElementById("demo").innerHTML = myObj.name; } }; xmlhttp.open(...

I want to restrict job seeker update/view his mysql data until admin panel approve his profile

I want to restrict job seeker update/view his mysql data until admin panel approve his profile This is the code I used but its for admins in the mysql not for a user(job seeker) in my website. REVOKE SELECT ON contacts FROM '*'@'localhost'; Where is the code and what do you want to achieve? – Nico Haase Jul 1 at 7:51 this makes very little sense – smith Jul 1 at 8:03 You have to restrict this feature on application level, not on database level, since I doubt that you create a separate mysql user acvount for each of your users. – Shadow Jul 1 at 8:23 ...

Display the name instead of the ID

Display the name instead of the ID Database setup: Table: customers id | name | address | zipcode | city | phone | email | active Table: todo id | customerid | description | information | active $sql = " SELECT * FROM todo ORDER BY `customerid` ASC , `description` ASC "; show results: echo $row['customerid'] $row['description'] $row['information']; output: customerid description information desired output: customername (from table customers) description information I have been reading this forum and i find that i should use INNER JOIN but i can't get it to work. Could anyone assist me? 2 Answers 2 First,you need use join to get the customername value join SELECT t.description,t.information,c.name FROM todo t JOIN customers c ON c.id=t.customerid ORDER BY `t.customerid` ASC, `description` ASC Then try with below: echo $row['name'] $row[...