Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hey guys, I wanted to share something with everyone. I hope this is helpful. This is basically a native solution to easily store PHP session data in a MySQL database. Session variables contain data that is saved for a specific user by associating the user with a unique identity. Typically, PHP would store session variables in a local file system on the server by default. While this may be acceptable to many people who are running small to moderate PHP applications, some larger applications that require load balancing would need to be run on multiple servers with a load balancer. In such cases, each server running PHP would need a way to ensure that sessions continue to work properly. One common way to achieve this is to override where PHP opens, reads, writes, and destroys the session variables so that it can perform these operations on a table inside of a MySQL database. When this is performed, the web application can gain advantages such as session management, session logging, and session interactions. I have provided my source code for your reference here: https://github.com/dominicklee/PHP-MySQL-Sessions Hope this helps someone out!
  2. i have a set of selects in html form and would like to validate them based on : if the first select is not null and the value is not equal to the selection of the second select,and the remaing selects are not empty or null,then pass else fail. how can i do that? here is my html <tr> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" name="home[0]"> <option value="">Select team</option> <option value="6">Seb FC</option> </select> </label> </td> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" name="away[0]"> <option value="">Select team</option> <option value="6">Sebo FC</option> </select> </label> </td> <td valign="middle" align="left"> <select class="t1-select" name="starthour[0]" style="width:55px"> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option></select></td> <td valign="middle" align="left"> <select class="t1-select" name="startminute[0]" style="width:55px"> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option><option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39">39</option><option value="40">40</option><option value="41">41</option><option value="42">42</option><option value="43">43</option><option value="44">44</option><option value="45">45</option><option value="46">46</option><option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option><option value="51">51</option><option value="52">52</option><option value="53">53</option><option value="54">54</option><option value="55">55</option><option value="56">56</option><option value="57">57</option><option value="58">58</option><option value="59">59</option><option value="60">60</option></select> </td> <!--<td valign="middle" align="left"> <select class="t1-select"name="endhour[0]"style="width:55px"> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option></select> </td> <td valign="middle" align="left"> <select class="t1-select"name="endminute[0]"style="width:55px"> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option><option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39">39</option><option value="40">40</option><option value="41">41</option><option value="42">42</option><option value="43">43</option><option value="44">44</option><option value="45">45</option><option value="46">46</option><option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option><option value="51">51</option><option value="52">52</option><option value="53">53</option><option value="54">54</option><option value="55">55</option><option value="56">56</option><option value="57">57</option><option value="58">58</option><option value="59">59</option><option value="60">60</option></select> </td>--> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" id="user_venue" name="venue[0]" style="width:55px"> <option value="">Select Venue</option> <option value="H">(H)HOME</option><option value="A">(A)AWAY</option><option value="N">(N)NEUTRAL</option> </select> </label> </td> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" id="user_stad" name="stadium[0]"> <option value="">Select Stadium</option> <option value="1">Nambo Stadium</option> </select> </label> </td> </tr> <tr> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" name="home[1]"> <option value="">Select team</option> <option value="6">Seb FC</option> </select> </label> </td> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" name="away[1]"> <option value="">Select team</option> <option value="6">Sebo FC</option> </select> </label> </td> <td valign="middle" align="left"> <select class="t1-select" name="starthour[1]" style="width:55px"> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option></select></td> <td valign="middle" align="left"> <select class="t1-select" name="startminute[1]" style="width:55px"> <option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option><option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39">39</option><option value="40">40</option><option value="41">41</option><option value="42">42</option><option value="43">43</option><option value="44">44</option><option value="45">45</option><option value="46">46</option><option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option><option value="51">51</option><option value="52">52</option><option value="53">53</option><option value="54">54</option><option value="55">55</option><option value="56">56</option><option value="57">57</option><option value="58">58</option><option value="59">59</option><option value="60">60</option></select> </td> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" id="user_venue" name="venue[1]" style="width:55px"> <option value="">Select Venue</option> <option value="H">(H)HOME</option><option value="A">(A)AWAY</option><option value="N">(N)NEUTRAL</option> </select> </label> </td> <td valign="middle" align="left"> <label for="tags"> <select class="t1-select" id="user_stad" name="stadium[1]"> <option value="">Select Stadium</option> <option value="1">Nambo Stadium</option> </select> </label> </td> </tr $hteam = $_POST['home']; $ateam = $_POST['away']; $starthour = $_POST['starthour']; $startminute = $_POST['startminute']; $venue = $_POST['venue']; $stadium = $_POST['stadium']; foreach($hteam as $key => $d ) { if((!empty($d)&& !empty($ateam[$key])&& ($ateam[$key]!= $d))/*&& empty($venue[$key])&& empty($stadium[$key])*/){ $mErrorMessage = 'Set full match details'; break;} }
  3. Hey everyone! I have been working on a text based mafia game, and one of the pages is "Weed Farm". In simple terms, Users can plant seeds and grow them. They can also upgrade there farm, the better the farm, the more they can grow. Everything works perfect, other than when you plant the seeds, and wait 24 hours, when you go back to sell them, it says you have 0. I guess for some of you guys it'll be simple code, but not for a Noob like me. Any help i will be thankful off. I have attached the necessary files, many thanks. weedfarm.php func.php
  4. Hey. Please help to solve the task Head John very busy lately. And it does not have time to plan the time of your employees manually. So he asked Jerry programmer to write a program that will calculate how much of a certain type of problems his department will be able to solve in the past month. John knows that to solve this type of problem he needs n employees, each of which will deal with a specific case and can not replace the other. Each of these employees will be engaged in the same task ai hours. Total monthly employee fulfills bi hours. Besides John have Jerry, which can be given to the problem of maximum k hours. Jerry can do the work of any other employee, one hour is equal to one hour of Jerry any other employee. John need to understand how the tasks can be performed per month maximum knowing n, k, a1-n, and b1-n Input data The first line is followed by two positive integers n and k (1 ≤ n ≤ 50000, 1 ≤ k ≤ 109) - the number of employees and number of hours of programmer Jerry. In the second line followed by a sequence a1, a2, ..., an (1 ≤ ai ≤ 109), where the i-th number equals the number of hours the i-th employee, required for solving a problem. The third line should be a sequence of b1, b2, ..., bn (1 ≤ bi ≤ 109), where the i-th number equals the number of hours the i-th employee, who is at John. Output Print a single number - the maximum number of tasks that can make the employees of the department with the help of their available hours and programmer Jerry. Examples: Input data 3 1 2 1 4 11 3 16 The result of 4
  5. I see all over the internet tutorials that are basically saying that setting up the ssh tunnel for mysql is easy, but I get an error, and no joy: Host key verification failed This error is in a log file that I created. I am attempting to use PHP's shell_exec on my Ubuntu desktop: shell_exec('ssh -p 2233 -f -L 3307:127.0.0.1:3306 acct@remote-server.com sleep 60 >> ./ssh.logfile 2>&1'); So, pretty standard according to the internet, but it's not working for me. 1) The remote server is a hosted website. It's a "semi-dedicated" plan, and just a glorified shared hosting account. 2) I can already do a passwordless SSH connection to the remote server by using the terminal. So my key based authentication is working for me. 3) I use SQLyog (MySQL tunneling through SSH) to this remote server. It's not key based, but the tunnel is there. 4) The host was not helpful. They were trying (I think), but nothing worked. 5) Yes, the remote server requires SSH connections on port 2233. Why is this failing? I need somebody to walk me through this. I saw somewhere online that the error message may mean that apache was not able to check a known_hosts file. I created an .ssh directory at /var/www/.ssh, and I put a known hosts file in there. Chowned these to www-data:www-data. Permission set at 600. Don't know what else to do or check.
  6. Without writing a regx, is there a php function/library that will take a string and try and convert it to a date? PHP's date is not adequate. For example, these are all "dates". I would expect it to succeed on any of these. On those that are ambiguous, there should be attribute that can be set like, expect year between 78 and 16. This is strictly best guess, I do not supply a format. Failure is expected. feb 21, 1999 Feburary 21, 1999 02/21/99 2/21/99 99/2/21 2-21-1999 19990221 sun, Feb 21, 1999 Sunday Feburary 21, 1999 anything returned by a mysql date (now(), datetime ...) Today's date is DATESTUFF You get the idea. Returns false on couldn't do it, and some array or seconds after N if successful. Thank you.
  7. Hello everyone im new here and im very happy that i found smth good here (just a think). im trying to create alphabetic power search module for joomla my web test is this ->http://vps365826.ovh.net/index.php/africa as you can see the alhabetic line ( A B C D E G I K L M N R S T U Z ) as you see some words missing well thats cause i dont have articles with words ex (F) photo ex. ( http://prntscr.com/e9j9iu ) well i want to create it with all alphabetic words even if we dont have article with that word i've created with my friend that code <div class="ordered"> <ul> <?php $db = JFactory::getDBO(); $query = 'SELECT count(*) as nm, SUBSTR(title,1,1) as alpha FROM #__content WHERE catid = '.$catid.' GROUP BY SUBSTR(title,1,1)'; $db->setQuery($query); $mostIng = $db->loadObjectList(); foreach ($mostIng as $row) { echo '<li data-text="'.$row->alpha.'">'.$row->alpha.' '.'</li>'; } ?> </ul> </div> but i want it somethink like that <div class="ordered"> <ul> <li class="orderedLabel closed">Αναζήτηση αλφαβητικά ></li> <li>A</li> <li>B</li> <li>C</li> <li>D</li> <li>E</li> <li>F</li> <li>G</li> <li>H</li> <li>I</li> <li>J</li> <li>K</li> <li>L</li> <li>M</li> <li>N</li> <li>O</li> <li>P</li> <li>Q</li> <li>R</li> <li>S</li> <li>T</li> <li>U</li> <li>V</li> <li>W</li> <li>X</li> <li>Y</li> <li>Z</li> </ul> </div> well thanks for your time and sorry for my bad english im trying to learing btw thank you very much!!!
  8. Hi, I am not a coder, but I have this issue with my ecommerce platform which is based on Prestashop. So could You please explain to me what is the purpose of this php script below? Whap is gonna to happen if I delete it (this script is giving me an error)? <?php $host = "http://localhost:8080"; $company = "BlueSky"; $email = "lisa.penvenen@gmail.com"; $price = "1000"; $offerNumber = "958"; $description = "My invoice"; $street = "Baker street 221B"; $city = "London"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERPWD, "lisa.penvenen:mypass"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HTTPAUTH, TRUE); $id = send($ch, $host, $company, $description, $price, $offerNumber, $street, $city); sendEmail($ch, $host, $company, $id, $email); curl_close($ch); function send($ch, $host, $company, $description, $price, $offerNumber, $street, $city) { curl_setopt($ch, CURLOPT_URL, $host . "/c/" . $company . "/invoice-issued.json"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); $invoice = array( "winstrom" => array( "invoice-issued" => array( "documentType" => "code:INVOICE", "mine" => "code:WINSTROM", "description" => $popis, "total" => $price, "noItems" => "true", "offerNumber" => $offerNumber, "street" => $ulice, "city" => $mesto, ) ) ); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($invoice)); $output = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200 && curl_getinfo($ch, CURLINFO_HTTP_CODE) != 201) { printf("Error occurred during the operation (HTTP %d): %sn", curl_getinfo($ch, CURLINFO_HTTP_CODE), $output); } else { $id = get_id($output); printf("Success (1) s ID: %s <br/>", $id); return $id; } } function get_id($output) { $id = 0; $jsonIterator = new RecursiveIteratorIterator( new RecursiveArrayIterator(json_decode($output, TRUE)), RecursiveIteratorIterator::SELF_FIRST); foreach ($jsonIterator as $key => $val) { if (!is_array($val)) { if ('id' == $key) { $id = $val; } } } return $id; } function sendEmail($ch, $host, $company, $id, $email) { curl_setopt($ch, CURLOPT_URL, $host . "/c/" . $company . "/invoice-issued/" . $id . "/sending-documents.xml"); curl_setopt($ch, CURLOPT_POSTFIELDS, "to=" . $email . "&subject=Invoice"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); $output = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200 && curl_getinfo($ch, CURLINFO_HTTP_CODE) != 201) { printf("rror occurred during the operation (HTTP %d): %sn", curl_getinfo($ch, CURLINFO_HTTP_CODE), $output); } else { printf("Success (2)"); } } ?>
  9. Hi all, I configured my localhost to work with Xdebug and then installed the plugins to work with note++. Everything worked fine and I got the sample two line program to work from the terminal as well as from a browser (chrome) by appending "?XDEBUG_SESSION_START=xyz" after the URL. It worked fine for small programs but for my multi-page application, the appended bit simply disappeared. I guess that's because of jumping to pages on menu clicks where the url is created depending upon the menu button being clicked. Code like : if(isset($_GET['menu_item'])) { $menu_item = fcheckPpage($_GET['menu_item']); switch ($menu_item) { case "menu1": require_once("/some/thing.php"); break; case "menu2": require_once("some/thingelse.php"); break; ... Then I tried the same on firefox by first installing the plugin for it which does not require any strings to be appended to the URL. That too got working but crashed each time at the very same place when it encountered the code shown above in the code box. These are the error messages that I got and It is clear that the the moment the application / program generated it's own url the link to the debugger is lost. Seems like a woeful limitation, I could try and append the XDEBUG... string to the end of each of the generated urls but that would not be a very pretty solution if that did work. If anyone has any suggestions or solutions or an alternative to this I will grateful. Thanks all.
  10. i want to display 'Welcome userid!' after user has successfully logged in. I managed to display it after successfully logged in, but when the user key in the wrong userid and password, the 'Welcome userid' is also displayed. What should i do about it? Below are my coding: login.html processLogin.php index.html
  11. $outp = ""; while($rs = $result->fetch_array(MYSQLI_ASSOC)) { if ($outp != "") {$outp .= "";} $outp .= '{"Portrait":"' . $rs["Portrait"] . '",'; $outp .= '"First Name":"' . $rs["FName"] . '",'; $outp .= '"Last Name":"' . $rs["LName"] . '",'; $outp .= '"DOI":"'. $rs["DOI"] . '",'; $outp .= '"MOI":"'. $rs["MOI"] . '",'; $outp .= '"YOI":"'. $rs["YOI"] . '",'; $outp .= '"ID":"'. $rs["id"] . '"}'; } $outp ='{"records":['.$outp.']}'; Hi for the above PHP code the output looks like this JSON format { "records": [{ "Portrait": "image1.png", "First Name": "Dave", "Last Name": "Smith", "DOI": "20", "MOI": "0", "YOI": "2017", "ID": "1" } { "Portrait": "image2.png", "First Name": "Sally", "Last Name": "Jones", "DOI": "20", "MOI": "0", "YOI": "2009", "ID": "2" }] } and this doesn't validate because there should be comma in between records like this: { "records": [{ "Portrait": "image1.png", "First Name": "Dave", "Last Name": "Smith", "DOI": "20", "MOI": "0", "YOI": "2017", "ID": "1" }, { "Portrait": "image2.png", "First Name": "Sally", "Last Name": "Jones", "DOI": "20", "MOI": "0", "YOI": "2009", "ID": "2" }] } I am trying to figure out how to get a comma added between records without also adding it at the end, b/c that is invalid also. Any ideas?
  12. I have made an ajax call (using file activedirectory.php) to active directory to retrieve information such as name,thumbnail photo,mail etc. the ajax call is made on click of a name in a leaderboard ,to fetch only that person's info by matching the post['id']. The problem is that I am unable to retrieve any information and the console gives me an error saying : SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data the error type makes it clear that it is unable to pull any data whatsoever. .php file that has been used here :(activedirectory.php) -- <?php /** * Get a list of users from Active Directory. */ $ad_users = ''; $message = ''; $ldap_password = 'Qwerty@33xxxxxx'; $ldap_username = 'maxxxxxxxxxxxx'; $server = 'ldap://xxxxxxxxxx'; $domain = '@asia.xxxxxx.com'; $port = 389; $ldap_connection = ldap_connect($server, $port); if (FALSE === $ldap_connection){ // Uh-oh, something is wrong... } // We have to set this option for the version of Active Directory we are using. ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version'); ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search. if (TRUE === ldap_bind($ldap_connection, $ldap_username.$domain, $ldap_password)){ $base_dn = "OU=Employees,OU=Accounts,OU=xxxxx,DC=xxxxx,DC=xxxxxx,DC=com"; $kid = 'NonExistingAccount'; if (preg_match('#SAM_NAME_MATCHING_REGEX#', $_POST['id'])) { $kid = $_POST['id']; } $search_filter = "(&(objectCategory=person)(samaccountname={$kid}))"; $attributes = array(); $attributes[] = 'givenname'; $attributes[] = 'mail'; $attributes[] = 'samaccountname'; $attributes[] = 'sn'; $result = ldap_search($ldap_connection, $base_dn, $search_filter, $attributes); $maxPageSize = 1000; if (FALSE !== $result){ $entries = ldap_get_entries($ldap_connection, $result); for ($x=0; $x<$entries['count']; $x++){ if (!empty($entries[$x]['givenname'][0]) && !empty($entries[$x]['mail'][0]) && !empty($entries[$x]['samaccountname'][0]) && !empty($entries[$x]['sn'][0]) && 'Shop' !== $entries[$x]['sn'][0] && 'Account' !== $entries[$x]['sn'][0]){ $ad_users[strtoupper(trim($entries[$x]['samaccountname'][0]))] = array('email' => strtolower(trim($entries[$x]['mail'][0])),'first_name' => trim($entries[$x]['givenname'][0]),'last_name' => trim($entries[$x]['sn'][0])); } } } ldap_unbind($ldap_connection); // Clean up after ourselves. } $message .= "Retrieved ". count($ad_users) ." Active Directory users\n"; ?> the javascript that has been used here : $('.leaderboard li').on('click', function () { $.ajax({ url: "../popupData/activedirectory.php", // your script above a little adjusted type: "POST", data: {id:$(this).find('.parent-div').data('id')}, success: function(data){ console.log(data); data = JSON.parse(data); $('#popup').fadeIn(); //whatever you want to fetch ...... // etc .. }, error: function(){ alert('failed, possible script does not exist'); } }); });
  13. So, I am trying to create a website where you enter a pin, it redirects you to a page, enter another pin, it redirects you to another page. I have two files: th1.php (the main file) <?php //require_once"app/init.php ;?> <!DOCTYPE HTML> <link rel="stylesheet" type="text/css" href="style.css" /> <form action="th.php" method="POST"> <div class="container"> <input type="text" placeholder="Enter PIN" name="pin" required> <button type="submit" name="sub" value="Submit">Submit</button> </div> <div class="container" style="background-color:#f1f1f1"> </div> </form> and th.php (the verification file) <?php if(isset($POST['pin']) AND !empty($POST['pin'])){ $input = $_POST['pin']; $pinI = "6203"; $pinII = "9471"; if($input === $pinI){ header("Location:pinI.html"); }else{ if($input === $pinII){ header("Location:pinII.html"); }else{ echo "PIN INCORRECT!"; }} }else{ echo "PIN EMPTY!"; } but any code I insert, even the correct one, it sais PIN EMPTY! can you help me please?
  14. Basically I am having an array something like below, this array has number of categories and sub, sub sub categories. $categories = array( array('id' => 1, 'parent' => 0, 'name' => 'Category'), array('id' => 2, 'parent' => 1, 'name' => 'Category A'), array('id' => 3, 'parent' => 1, 'name' => 'Category B'), array('id' => 4, 'parent' => 1, 'name' => 'Category C'), array('id' => 5, 'parent' => 1, 'name' => 'Category D'), array('id' => 6, 'parent' => 1, 'name' => 'Category E'), array('id' => 7, 'parent' => 2, 'name' => 'Subcategory F'), array('id' => 8, 'parent' => 2, 'name' => 'Subcategory G'), array('id' => 9, 'parent' => 3, 'name' => 'Subcategory H'), array('id' => 10, 'parent' => 4, 'name' => 'Subcategory I'), array('id' => 11, 'parent' => 9, 'name' => 'Subcategory J'), ); Using this array I have created a nested <ul>. This is the recursive function I have used for : foreach ($categories as $category) { $id = $category['id']; $parent = $category['parent']; $name = $category['name']; //echo $name."<br>"; $cats[$parent][$id] = $name; } function displayList(&$cats, $parent, $current=0, $level=0) { switch ($level) { case 0: $class = "level_1 has_sub no_active"; $a_class = "c1"; break; case 1: $class = "level_2 has_sub no_active"; $a_class = "c2"; break; case 2: $class = "level_3 has_sub no_active"; $a_class = "c3"; break; } if ($parent==0) { foreach ($cats[$parent] as $id=>$nm) { if (isset($cats[$id])) { displayList($cats, $id, $current); } } } else { echo "<ul class='$class'>\n"; foreach ($cats[$parent] as $id=>$nm) { $clear = preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags(html_entity_decode($nm))); $pageName = strtolower(str_replace(' ', '-', $clear)); $link = $pageName.'.php'; echo "<li><a href='$link' class='$a_class $sel'><span>$nm</span></a>\n"; if (isset($cats[$id])) { displayList($cats, $id, $current, $level+1); } echo '</li>'; } echo "</ul>\n"; } } Look at that function, I have created a link for each category. Category name itself has used as page name. (Removing by special chars.) My question is, when this function executing I want to create folders for level one categories. Those category names should be used as folder names. Example from above array: category_a category_b category_c category_d category_e So, every sub category pages should be inside these parent category folders. Can I know is this possible in this function? Thank you.
  15. Hi there, I was trying to do a live table edit for our site. Everything seemed to be going ok, till i realised that its not actually updating the database, there are no error messages, you have to refresh the page to see it hasn't worked. I'm at a loss as to why was hoping someone might be able to point me in the right direction. thanks, MsKazza tableedit.php table_edit_ajax.php
  16. good day dear php-freaks i need to rename files in _ one _ directory - more than 50 files are in this..folder: the files are named like so: 01 02 03 04 ... 49 50 each file has got a number as a file name. each file should get a character - like so: r01, r02, r03, r04 and so on . .... r50 how can we do this on commandline
  17. hi, On my website I have a form with a single text area and a submit button, the user will come to my site with a report of points and stats from hosting a tournament online, see attached picture for details of the report once they hit submit the form posts to my processing page, in the processing page I take all the information I need from the beginning of the report this was kind of easy to do, the part I seem to be struggling with is splitting the array at this point. I have exploded each line from my report into an array $records, what I need to do now is, take everything from the line "START POINTS" down to the line "STOP POINTS" from the main array into a new array so that I can get the new array and use a foreach loop on it to separate the player name from player points I already have the foreach loop setup ready as I had this all setup once but I was not getting the information from the top of the report now I need that information so my original foreach does not work
  18. Hi again, Hopefully the last question as I am not 100% how to solve this one. So on my website someone carried out a search from a search bar using the 'POST' method , teh search results show all whiskies in the databse. I have a number of whiskies with the same name but with different dates and prices. I would like it just to show one of each type that was searched for rather than all of them. I have attahced a clip of the databse. Thanks Index.php </head> <?php $page='index'; include('header.php'); include('navbar.php'); ?> <script type="text/javascript"> function active(){ var search_bar= document.getElementById('search_bar'); if(search_bar.value == 'Search for your whisky here'){ search_bar.value='' search_bar.placeholder= 'Search for your whisky here' } } function inactive(){ var search_bar= document.getElementById('search_bar'); if(search_bar.value == ''){ search_bar.value='Search for your whisky here' search_bar.placeholder= '' } } </script> <body> <div class="third_bar"> <div class="background_image"> </div> <div class="form"><form action= "search.php" method="post"> <input type="text" name="search" id="search_bar" placeholder="" value="Search for your whisky here" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/> </form> </div> </div> </body> </div> <?php include ('footer.php'); ?> Search.php <?php $page='search'; include('header.php'); include ('navbar.php'); echo "<br>"; include ('connect.php'); if (isset ($_POST['search'])) { //the 'search' refers to the 'search' name=search on the index page and makes does something when the search is pushed. $search = $_POST['search']; $search = "%" . $search . "%"; // MySQL wildcard % either side of search to get partially matching results // No wildcard if you want results to match fully } else { header ('location: index.php'); } $stmt = $conn->prepare("SELECT * FROM test_db WHERE name LIKE :name ORDER BY name ASC"); // Use = instead of LIKE for full matching $stmt->bindParam(':name', $search); $stmt->execute(); $count = $stmt->rowCount(); // Added to count no. of results returned if ($count >= 1) { // Only displays results if $count is 1 or more echo "<div class='results_found'>"; echo $count; echo " results found<br>"; echo "</div>"; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<div class='results'>"; echo "<div class='result_name'>"; echo "<b>Whisky Name:</b><br>"; echo "<a href='details1.php?id={$row['lot_id']}' >{$row['name']}</a>"; echo"<br>"; echo "</div>"; echo "</div>"; } } else { echo " Sorry no records were found"; } ?> </htm
  19. Hi I have a question about managing data from forms and database, to be exact for safe input/output data from form input fields. Do i need some filters to remove code from input if user try to insert ? When i making database table i limiting chars and same in form. Here is a piece of code i use just for test and example : // connection to database $dbh = new PDO('mysql:host=localhost;dbname=test123', 'root', ''); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // variables to insert into database $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; // query with prepare statements $stmt = $dbh->prepare("INSERT INTO members (username, password, email) VALUES (:username, :password, :email)"); $stmt->bindParam(":username", $username, PDO::PARAM_STR); $stmt->bindParam(":password", $password, PDO::PARAM_STR); $stmt->bindParam(":email", $email, PDO::PARAM_STR); $stmt->execute(); $lastId = $dbh->lastInsertId(); // checking if query is passed and data is inserted into dataabse if($lastId > 0) { echo 'Thank u for register.'; } else { echo 'Something went wrong, please try again.'; }
  20. I have this code that pulls data from a form and is supposed to check if the neptune and username are inserted 2 times it replies back with an error if not it posts the data to 2 lines with neptune username and email on one line and just email and username on the other The issue is the code i have gives me an error saying unexpected end of file below is my code any help will be appreciated <?php if(isset($_POST['choices']) && !empty($_POST['choices'])){ if($_POST['choices'] == 'four'){ //variables from form entered $username = $_POST['username']; $neptune = $_POST['neptune']; $email = $_POST['useremail']; //connect to the database $dbc = mysqli_connect('localhost', 'root', '', 'happygam_main') or die('Error connecting to MySQL server'); $check=mysqli_query($dbc,"select * from ballot where username='$username' and neptune='$neptune'"); $checkrows=mysqli_num_rows($check); if($checkrows>0) { echo "This combination of neptune and username has already been processed"; } else { //insert results from the form input in 2 rows one with neptune one without $query = "INSERT IGNORE INTO ballot(username, useremail, neptune) VALUES('$username', '$email', '$neptune')"; $query1 = "INSERT IGNORE INTO ballot(username, neptune) VALUES('$username', '$neptune')"; $result = mysqli_query($dbc, $query, $query1) or die('Error querying database.'); mysqli_close($dbc); } } ?>
  21. I have just begun dabbling with javascript as a hobby and have a very crude understanding of php so please bare with me, I am a noob! I am using a javascript onclick button to reference the function shown below. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); location.reload(); } When the button is pressed and the function executes it does as it should. It deletes the forum reply post as its told and the page reloads and the post is gone! But without some sort of explanation, success message or something telling me that it did what its intended is very unsatisfying. I read around and found that an additional function is needed to give me a little message. success : function() { var x="Success"; alert(x); } Looks simple enough and one would think should be easy to incorporate but when I add it in every way shape or form I cannot get it to work. The original function wont even work after adding this. Below is basically what I am wanting to do but not quite sure how to go about it. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); success : function() { var x="<?php $mtg->success("Reply has been deleted."); ?>"; alert(x); location.reload(); } } I want to use the php $mtg->success() function to echo the message in the pre defined output location and format and want to output the message after the reload... Any ideas on how to go about this?
  22. Hey guys. I have this php code and it tells me there a problem, but I can seem to figure out what the problem is. Hope you can help. Here is the code - mysql_query("INSERT INTO `wp_dc_mv_configuration` (`id`, `palettes`, `administration`) VALUES (1, 'a:2:{i:0;a:3:{s:4:\"name\";s:7:\"Default\";s:6:\"colors\";a:70:{i:0;s:3:\"FFF\";i:1;s:3:\"FCC\";i:2;s:3:\"FC9\";i:3;s:3:\"FF9\";i:4;s:3:\"FFC\";i:5;s:3:\"9F9\";i:6;s:3:\"9FF\";i:7;s:3:\"CFF\";i:8;s:3:\"CCF\";i:9;s:3:\"FCF\";i:10;s:3:\"CCC\";i:11;s:3:\"F66\";i:12;s:3:\"F96\";i:13;s:3:\"FF6\";i:14;s:3:\"FF3\";i:15;s:3:\"6F9\";i:16;s:3:\"3FF\";i:17;s:3:\"6FF\";i:18;s:3:\"99F\";i:19;s:3:\"F9F\";i:20;s:3:\"BBB\";i:21;s:3:\"F00\";i:22;s:3:\"F90\";i:23;s:3:\"FC6\";i:24;s:3:\"FF0\";i:25;s:3:\"3F3\";i:26;s:3:\"6CC\";i:27;s:3:\"3CF\";i:28;s:3:\"66C\";i:29;s:3:\"C6C\";i:30;s:3:\"999\";i:31;s:3:\"C00\";i:32;s:3:\"F60\";i:33;s:3:\"FC3\";i:34;s:3:\"FC0\";i:35;s:3:\"3C0\";i:36;s:3:\"0CC\";i:37;s:3:\"36F\";i:38;s:3:\"63F\";i:39;s:3:\"C3C\";i:40;s:3:\"666\";i:41;s:3:\"900\";i:42;s:3:\"C60\";i:43;s:3:\"C93\";i:44;s:3:\"990\";i:45;s:3:\"090\";i:46;s:3:\"399\";i:47;s:3:\"33F\";i:48;s:3:\"60C\";i:49;s:3:\"939\";i:50;s:3:\"333\";i:51;s:3:\"600\";i:52;s:3:\"930\";i:53;s:3:\"963\";i:54;s:3:\"660\";i:55;s:3:\"060\";i:56;s:3:\"366\";i:57;s:3:\"009\";i:58;s:3:\"339\";i:59;s:3:\"636\";i:60;s:3:\"000\";i:61;s:3:\"300\";i:62;s:3:\"630\";i:63;s:3:\"633\";i:64;s:3:\"330\";i:65;s:3:\"030\";i:66;s:3:\"033\";i:67;s:3:\"006\";i:68;s:3:\"309\";i:69;s:3:\"303\";}s:7:\"default\";s:3:\"F00\";}i:1;a:3:{s:4:\"name\";s:9:\"Semaphore\";s:6:\"colors\";a:3:{i:0;s:3:\"F00\";i:1;s:3:\"FF3\";i:2;s:3:\"3C0\";}s:7:\"default\";s:3:\"3C0\";}}', 'a:15:{s:5:\"views\";a:4:{i:0;s:7:\"viewDay\";i:1;s:8:\"viewWeek\";i:2;s:9:\"viewMonth\";i:3;s:10:\"viewNMonth\";}s:11:\"viewdefault\";s:5:\"month\";s:8:\"language\";s:5:\"en-GB\";s:13:\"start_weekday\";s:1:\"0\";s:8:\"cssStyle\";s:9:\"cupertino\";s:12:\"paletteColor\";s:1:\"0\";s:6:\"btoday\";s:1:\"1\";s:11:\"bnavigation\";s:1:\"1\";s:8:\"brefresh\";s:1:\"1\";s:14:\"numberOfMonths\";s:2:\"12\";s:7:\"sample0\";N;s:7:\"sample1\";s:5:\"click\";s:7:\"sample2\";N;s:7:\"sample3\";s:0:"";s:7:\"sample4\";s:10:\"new_window\";}');");
  23. Hi I have been working on my OOP and have put together some class files to aid my test application ( photo album ) on the upload page I have the browse box, a caption text box and an upload button this page posts to self, Once you click on upload it is also supposed to insert a database entry to allow tracking of the file's attributes, once I click the upload button I get this error message back, " Database Query Failed: Incorrect integer value ' ' for column 'id' at row 1 " so I have re looked over my codes in regards to uploading files and just can not seem to put my mouse on the spot that's causing me an issue so here is the codes that matter to the file uploads... this one is from my database.php class file, public function insert_id() { // get the last id inserted over the current db connection return mysql_insert_id($this->connection); } and this one is one comes from my photograph class file, public function create() { global $database; $attributes = $this->sanitized_attributes(); $sql = "INSERT INTO ".self::$table_name." ("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)) { $this->id = $database->insert_id(); return true; } else { return false; } } Looking at my error and the information in those functions I can guess that's where the issue is coming from just don't get why any ideas please?
  24. I have a form with a table with columns and many rows. The form uses Post and submits to an insert.php I am looking for an example of how I can insert the table info into a mysql table. I know I should use a while loop but unsure how to step through the form info. Can someone suggest or provide and example that I can follow, or a tutorial somewhere? Thanks
  25. Hi, I have an application where during registration a user will choose when they want to be reminded of an event. For instance the event lets say will start on 2017-02-02 and i scheduled it on 2016-12-30 and i want to be reminded everyday from 10days to the event date(2017-02-02). How do i go about it? I need idea as to know how to go about it. I dont know if cron will be good. Thanks
×
×
  • 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.