Jump to content

PHPSpirit

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Posts posted by PHPSpirit


  1. Try this code:

    index.php
    [code]
    <?php

    /*
    * Modules
    */
    include("language.php");

    $language = new language();
    unset($language);

    ?>
    [/code]

    language.php
    [code]
    <?php
    class language
    {
      function language()
      {
        if( isset($_GET['lang']) )
        {
          $lang = $_GET['lang'];
          $lang = $this->set_language($lang);
        }
        elseif( isset($_COOKIE['lang']) )
        {
          $lang = $_COOKIE['lang'];
        }
        else
        {
          $lang = $this->set_language();
        }
        $this->load_language($lang);
      }
     
      function set_language($lang = "en")
      {
      switch($lang)
      {
      case "de": $lang = "de"; break;
      case "en": $lang = "en"; break;
      case "pl": $lang = "pl"; break;
      default: $lang = "en";
      }

        setcookie("lang", $lang , 0);

        return $lang;
      }

      function load_language($lang = "en")
      {
        //include_once("languages/" . $lang . ".inc");
        echo "include: ".$lang;
      }
    }
    ?>
    [/code]
  2. [quote author=christophe link=topic=116568.msg475026#msg475026 date=1164713206]
    Hi there,

    Right O.K I have this code

    [code]

    include_once("includes/config.php");

    $query="SELECT letter,id,word,description FROM dictionary";

    $result = mysql_query ($query);
    echo "<select name=word=''">Word</option>";

    while($nt=mysql_fetch_array($result)){
    echo "<option value=$nt[id]>$nt[word]</option>";

    }
    echo "</select>";

    ?>

    [/code]

    so my question:

    how do i make this script so when a user selects an option from the drop down box it pulls information from the description field in my database and displays this information on the same page?



    ive been stuck on this for ages now so any help will be much appreciated

    Thanks
    Alex
    [/quote]


    You need use AJAX.

    http://www.w3schools.com/ajax/default.asp


  3. [quote author=ali_kiyani link=topic=116557.msg474996#msg474996 date=1164701746]
    Hello,

    I have an application in PHP where users upload different files to server.

    Q1. Is there a way I can check those files for virus when user uploads?
    Q2. If a virus is found in some file, how can I display message to the user?
    Q3. Let's say if I have a dedicated server with antivirus installed, what do I need to do to integrate it with PHP?
    Q4. Can this be done on shared hosting environment?

    Thanks
    [/quote]

    A1. Yes, after the user upload.
    A2. Return a message:

    [code]
    echo "Go to hell !\n";
    [/code]

    A3: You can use the command "system()" for execute commands lines and check the files, like this:

    [code]
    $check = system("antivirus file");

    if($check ...
    [/code]

    A4: Yes.




  4. Nice code printf.

    There is other option with javascript:

    index.php
    [code]
    <?php
      if( isset($_GET['var']) )
        print_r( split(",", $_GET['var']) );
    ?>
    <html>
    < script language="javascript">

    function getInputsInOne(id)
    {
      x = "";
      e = document.getElementById(id).getElementsByTagName('input');
      for(i in e)
        if(e[i].checked) x+= e[i].value+",";
      return x;
    }

    function getNewSubmitForm(){
      var submitForm = document.createElement("FORM");
      document.body.appendChild(submitForm);
      submitForm.method = "GET";
      return submitForm;
    }

    function createNewFormElement(inputForm, elementName, elementValue){
      var newElement = document.createElement("input");
      inputForm.appendChild(newElement);
      newElement.name = elementName;
      newElement.value = elementValue;
      return newElement;
    }

    function createFormAndSubmit(id){
      x = getInputsInOne(id);
      var submitForm = getNewSubmitForm();
      createNewFormElement(submitForm, "var", x);
      submitForm.action= "index.php";
      submitForm.submit();
    }

    </script>

    <body>

    <div id="options">
    <input type="checkbox" value="a" id="opt_0">
    <input type="checkbox" value="b" id="opt_1">
    <input type="checkbox" value="c" id="opt_2">
    </div>

    <input type="button" value="Send" onclick="createFormAndSubmit('options')">

    </body>
    </html>
    [/code]

    I take some code from:

    here http://experts.about.com/q/Javascript-1520/create-form-submit-fly.htm
    here http://www.codingforums.com/showthread.php?t=65531
    here http://www.onlinetools.org/articles/unobtrusivejavascript/chapter2.html
    and here http://javascript.internet.com/buttons/check-all.html

  5. Perhaps the account does not have the permissions, or the syntax is incorrect.

    Try this:
    [code]
    INSERT INTO `pms` (`subject`, `message`, `recipient`, `from`, `status`) VALUES('$subject','$recipient','$message','$from','unread');"
    [/code]


  6. JJ


    You need configure the apache (httpd.conf) for php.

    Open the file httpd.conf and finds these places:

    ...
    #LoadModule vhost_alias_module modules/mod_vhost_alias.so
    #LoadModule ssl_module modules/mod_ssl.so
    --> LoadModule php5_module php/sapi/php5apache2.dll <--
    ...
    <IfModule mime_module>
        --> AddType application/x-httpd-php .php <--
        --> AddType application/x-httpd-php-source .phps <--
    </IfModule>
    ...

×
×
  • 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.