cereal 1,524 Nearly a Senior Poster Featured Poster

For the table use:

default charset = utf8 collate utf8_general_ci

then change the charset of the form sending the data:

<form accept-charset="utf8" action="" method="post">

and it should work fine. If this is not enough then change the configuration of Apache by adding:

AddDefaultCharset UTF-8

More information: http://httpd.apache.org/docs/2.2/mod/core.html#adddefaultcharset

EDIT
Wondering: the problem is related only to PHPMyAdmin? Could be your browser encoding.

cereal 1,524 Nearly a Senior Poster Featured Poster

Not sure if this is what you're searching for:

According to the article, you run the query from MSSQL, but I don't have experience on this, I don't know if you can do the reverse action, i.e. query MSSQL from MySQL.

cereal 1,524 Nearly a Senior Poster Featured Poster

The search form should use the GET method, because it's a reading instance, the update form a POST method because it writes to the database. So you can do:

# read
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
    # execute search
    if(isset($_GET['search']))
    {
        # code and populated form
    }

    else
    {
        # blank form
    }
}

# write
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    if(isset($_POST['update']))
    {
        # execute update query & redirect to referer page
    }
}

The redirect after a POST request is important, otherwise, by refreshing the page it will be submitted another time. Check header():

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, I think you could serve PHP as CGI script, for more information check this link:

cereal 1,524 Nearly a Senior Poster Featured Poster

Check AddThis: https://www.addthis.com/get/sharing

Once selected the style, you include a javascript in your code and a div as container of the share buttons.

cereal 1,524 Nearly a Senior Poster Featured Poster

I intended this:

<?php 
ini_set("session.cookie_domain", ".example.com"); 
session_start();

If you use Chrome//Firefox console, you can check the cookies created for the current domain. You cannot create a cookie for another domain or subdomain, but the dot gives you the ability to extend the cookie to subdomains. If, for example, you are on miami.example.com domain, you can:

setcookie('city', 'miami', time()+300, '/', '.miami.example.com');

That way, when you access to: hotels.miami.example.com or airports.miami.example.com the city cookie will be available.

Also, please, do not open multiple threads with the same question, I just noticed, there is already another one:

cereal 1,524 Nearly a Senior Poster Featured Poster

I see two problems here:

  1. the function session_start() is missing and so the session cookie will not be created;
  2. the set_cookie() for city is lacking of the domain attribute, so, if you want to make it available only for the current subdomain, it should be:

    set_cookie('city', 'value', 'ttl', 'path', 'sub.domain.com');
    
cereal 1,524 Nearly a Senior Poster Featured Poster

@Gurumoorthi you can use the GeoIP library, check this thread for more information:

cereal 1,524 Nearly a Senior Poster Featured Poster

Check the documentation of the fputcsv() function:

Read also the comments, there are some examples you could use.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

After:

if(isset($_POST['submit']))
{

Insert:

$_POST = array_map('trim', $_POST);

If, instead, you want to apply it only to one variable then write only this:

$billno = trim($_POST['billno']);

Ref: http://www.php.net/trim

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, have you tried to enable the module? You can try with a2enmod:

sudo a2enmod cgi

If you remove the last argument then you get a list of the available modules. Then reload the server:

sudo service apache2 reload

Regarding the warning check with:

apache2 -V

or with httpd -V the command will list some information about the Apache configuration, try also with -l to get the modules included when the server was compiled.

cereal 1,524 Nearly a Senior Poster Featured Poster

That page (kosnica.html) needs to be processable by the PHP engine, so you can:

  • change the extension to .php
  • otherwise modify Apache to process .html files as php scripts

As suggested you should use tables to save data, otherwise when the browser window is closed the data is lost, at the end of this post there's a link to the PDO library.

To simply send data from a page to another you can use session. In the page in which you calculate the total, start the session and save the data:

<?php

    session_start();

    # other code here
    # . . .


    # set the sessions
    $_SESSION['total_in_cart'] = array_sum($sum);
    $_SESSION['items_in_cart'] = count($sum);

When you go to kosnica.php, again start the session and retrieve what you have saved in the previous page:

<?php

    session_start();

    echo '<p>Items in cart('.$_SESSION['items_in_cart'].')</p>';
    echo '<p>The total is '.$_SESSION['total_in_cart'].'</p>';

This is a simple example, if you check the documentation I linked to you in my previous post you will find few examples about the session.

In addition, you should read:

Good work!

Stefce commented: SOLVED +0
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use session to send data from a page to another:

but if you're building a cart then use tables, here you can find an example of the structure you need:

Once defined the tables, it will be easy to write the scripts.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you're using my previous example you can use count($sum), it will return the total of the selected items. Otherwise you need to create a new loop and apply the IF statements there.

cereal 1,524 Nearly a Senior Poster Featured Poster

That happens because if the first IF condition is satisfied it will stop executing the other statements. Can you explain what you want to achieve?

For the next time, consider also, to start a new thread, since your new request is different from the original.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you can use sprintf for this task:

echo sprintf($eng['profile_permission'], $group, $permission);

However before doing this you need to change the variables in the array with the value types, in your case:

$eng['profile_permission'] = 'You belong to %s with a permission of %s';

Where %s stands for string, here the documentation:

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Aside Note

Check CodeIgniter (CI) framework you can find an example of what you want to achieve, refer to their session library, here you can find the documentation:

Basically they do what Lsmjudoka is suggesting, so you have to create a table like this one:

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
    session_id varchar(40) DEFAULT '0' NOT NULL,
    ip_address varchar(45) DEFAULT '0' NOT NULL,
    user_agent varchar(120) NOT NULL,
    last_activity int(10) unsigned DEFAULT 0 NOT NULL,
    user_data text NOT NULL,
    PRIMARY KEY (session_id),
    KEY `last_activity_idx` (`last_activity`)
);

Where the session_id changes every five minutes (they allow you to set the time), and saves the new cookie to the client. The column user_data is used to store a serialized array of each element you want to load in session, this gives you the ability to save whatever you want, even a user_id if, for example, you want to refer the session to a registered user.

Keep in mind, that if the session_id is predictable an attacker can send a cookie with the value and gain access and this is why diafol suggested you:

Before you start implementing 'save my details', consider all the security implications involveed with providing this type of convenience.

In CodeIgniter they also encrypt the cookie, so the session_id is not directly exposed, and this gives a bit more security to the application. If you want to create your own system then try to read through their code it will help you …

cereal 1,524 Nearly a Senior Poster Featured Poster

Check the information_schema.tables:

> explain information_schema.tables;
+-----------------+---------------------+------+-----+---------+-------+
| Field           | Type                | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+-------+
| TABLE_CATALOG   | varchar(512)        | NO   |     |         |       |
| TABLE_SCHEMA    | varchar(64)         | NO   |     |         |       |
| TABLE_NAME      | varchar(64)         | NO   |     |         |       |
| TABLE_TYPE      | varchar(64)         | NO   |     |         |       |
| ENGINE          | varchar(64)         | YES  |     | NULL    |       |
| VERSION         | bigint(21) unsigned | YES  |     | NULL    |       |
| ROW_FORMAT      | varchar(10)         | YES  |     | NULL    |       |
| TABLE_ROWS      | bigint(21) unsigned | YES  |     | NULL    |       |
| AVG_ROW_LENGTH  | bigint(21) unsigned | YES  |     | NULL    |       |
| DATA_LENGTH     | bigint(21) unsigned | YES  |     | NULL    |       |
| MAX_DATA_LENGTH | bigint(21) unsigned | YES  |     | NULL    |       |
| INDEX_LENGTH    | bigint(21) unsigned | YES  |     | NULL    |       |
| DATA_FREE       | bigint(21) unsigned | YES  |     | NULL    |       |
| AUTO_INCREMENT  | bigint(21) unsigned | YES  |     | NULL    |       |
| CREATE_TIME     | datetime            | YES  |     | NULL    |       |
| UPDATE_TIME     | datetime            | YES  |     | NULL    |       |
| CHECK_TIME      | datetime            | YES  |     | NULL    |       |
| TABLE_COLLATION | varchar(32)         | YES  |     | NULL    |       |
| CHECKSUM        | bigint(21) unsigned | YES  |     | NULL    |       |
| CREATE_OPTIONS  | varchar(255)        | YES  |     | NULL    |       |
| TABLE_COMMENT   | varchar(2048)       | NO   |     |         |       |
+-----------------+---------------------+------+-----+---------+-------+

From here you can query for TABLE_SCHEMA which is the database name, and the UPDATE_TIME which saves the last update datetime to a table:

select update_time from information_schema.tables where table_schema = 'database_name' order by update_time desc limit 1;

Or you're referring to something else?

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use insteadof to declare the first trait, then go with as, example:

trait TheErrorOfYourWays{
   public function booboo(){
       echo 'You had a booboo :(';
   }
}
trait SpectacularStuff1 {
    use TheErrorOfYourWays; 
}

trait SpectacularStuff2 {
    use TheErrorOfYourWays;
}

trait SpectacularStuff3 {
    use TheErrorOfYourWays;
}

class DoSomethingSpectacular {
        use SpectacularStuff1, SpectacularStuff2, SpectacularStuff3 {
            SpectacularStuff1::booboo insteadof SpectacularStuff2, SpectacularStuff3;
            SpectacularStuff2::booboo as booboo2;
            SpectacularStuff3::booboo as booboo3;
        }
    }

$do = new DoSomethingSpectacular;
$do->booboo();
$do->booboo2();
$do->booboo3();

Live sandbox: http://sandbox.onlinephpfunctions.com/code/8893d9672a02cf0ceefafe792d3159ce3bf2935e

diafol commented: You're good :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

You can create an array of prices, for example:

$prices = array(
    'sol' => 60,
    'prasok' => 200,
    'vegeta' => 100
);

And then, use a loop to check if the keys of this array matches with the $_GET/$_POST array:

$sum = array();
$getkeys = array_keys($_GET);

foreach($prices as $key => $value)
{
    if(in_array($key, $getkeys)) $sum[] = $value;
}

At the end use array_sum to add the values saved in the $sum array:

echo array_sum($sum);

This works also as white list, since only the values in the array of prices are considered, and everything else sent by the form is discarded.

cereal 1,524 Nearly a Senior Poster Featured Poster

@Laura if you want to be helped then open a new thread, explain the problem and attach the relevant code. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, on line 13 remove the last quote, so change this:

echo "Error#: " 60"

to:

echo "Error#: " 60
cereal 1,524 Nearly a Senior Poster Featured Poster

That's C++ ?

I think so, but I could be wrong, at first when I saw cout I though it was Python, but the switch method is different.

cereal 1,524 Nearly a Senior Poster Featured Poster

And you need it in C++(?) or in PHP? What have you done so far?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, here you can find all the versions:

You can use multiple versions in the same box, just run the executable that you want to use. However you may want to setup different profiles for each Firefox instance.

Refer to: https://support.mozilla.org/it/questions/974208

cereal 1,524 Nearly a Senior Poster Featured Poster

I can only think to an internal redirect, that will empty the $_POST array.

I should add to the OP that the form is located in pages/forums.php and the handler is located in administration.php, but pages/forums.php is included in administration.php

This confuses me :D Can you show more about the script?

cereal 1,524 Nearly a Senior Poster Featured Poster

Place this die(print_r($_POST)); before the IF statement and check what you get, you can do the same with $_SESSION. Otherwise just try to echo something before and after the conditional statement, if everything works fine, then it's something else. I don't think it's related to $_POST because the redirect seems correct, although I don't see how this is generated.

Unless $_POST['id'] is received as a string, verify it with var_dump, in that case change this:

$stmt->bind_param('isi', $_POST['id'], $_POST["category"], $position);

to:

$stmt->bind_param('isi', intval($_POST['id']), $_POST["category"], $position);
cereal 1,524 Nearly a Senior Poster Featured Poster

With some CSS you could place a link over that area. If the container has relative position, then you can use position:absolute, for example:

a.logo {
    position:absolute;
    top:10px;
    left:10px;
    display:block;
    width:100px;
    height:100px;
    text-decoration:none;
    text-indent:-9999px;
    z-index:100;
    margin:0;
    padding:0;
    border:1px solid red;
    color:red;
}

<div id="header">
    <a href="/" class="logo">Company Name</a>
</div>

then, when you have placed the link, you can remove the border and the color attributes. If you want to get better support, then paste the code here.

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, there are different caches, check the documentation for more information:

And there are some limitations, as the subqueries cannot be cached:

But if you use MariaDB, which is a fork of MySQL, you can cache even those queries:

cereal 1,524 Nearly a Senior Poster Featured Poster

The attribute of the form is enctype not encrypt, that should help to get the correct data, then you have to refer to the $_FILES array, check the documentation:

cereal 1,524 Nearly a Senior Poster Featured Poster

You missed a dot near $url:

'".$url"'

change it to:

'".$url."'

But you can rewrite it in a cleaner way:

$sql = "UPDATE serv SET title = '$title', description = '$description', url = '$url' WHERE id = $id";
cereal 1,524 Nearly a Senior Poster Featured Poster

When you use LAST_INSERT_ID() you cannot select the table. Also the id must be an auto increment column, if for example you're using uuid_short() you will get an empty result. And the value is related to the session of the client, if the insert is done by client A, client B will not see the last inserted id:

If this does not help show your insert query and the table structure.

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm not sure this is the best method and if can be useful, but I'm playing a bit with RewriteMap, once defined the map inside the vhost config file:

RewriteMap id2album txt:/tmp/idmap.txt

The contents of the file are:

123 jazz
301 summer

And the rules are:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^(.*)/album/(.*)$ /watch_album.php?id=$1&video_url=$2? [L]

RewriteCond %{QUERY_STRING} ^id=([0-9]*)&video_url=([0-9]*)$
RewriteRule ^watch_album.php$ /${id2album:%1|NOTFOUND}/album/%2? [R=301,L,NC]

</IfModule>

It seems to work fine: when accessing an url as /watch_album.php?id=123&video_url=17 Apache redirects to /jazz/album/17.

More information here: http://httpd.apache.org/docs/current/rewrite/rewritemap.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Start from the database schema, when you've realized all the connections between the tables you can write the scripts.

cereal 1,524 Nearly a Senior Poster Featured Poster

Here you find the documentation: http://httpd.apache.org/docs/2.4/logs.html

You shouldn't change permissions or the user/group that writes the logs, because from that user an attacker will be able to compromise the server. If you want to be able to read the logs then add the user to the adm group.

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to change the values of that configuration to match the directories in which you have your website and in which you want to save the log files. Currently you just pasted the example of the link I gave you in my previous post, and for this reason it does not work.

So, or you edit it or you reset the configuration to the previous state.

But the most important information is to understand if CodeIgniter is in the root or inside a subdirectory. Because in the second case you have to modify or move the rewrite rule in the .htaccess file.

If you want you can create a new directory under C:, for example c:\www\mywebsite and use this for the virtual host configuration:

<VirtualHost *:80>
    ServerAdmin admin@localhost
    DocumentRoot c:/www/mywebsite
    ServerName mywebsite.tld
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/mywebsite_error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog ${APACHE_LOG_DIR}/mywebsite_access.log combined


    <FilesMatch "^.ht">
        order allow,deny
        deny from all
    </FilesMatch>
</VirtualHost>

Once you've done this, edit the hosts file by adding this line to the end of the file:

127.0.0.1 mywebsite.tld

And reload the server. At the end move your website to the directory you've created c:\www\mywebsite and in the config.php of CI set:

$config['base_url']     = "http://mywebsite.tld/";

At this point, from the browser you can access the website and the redirect should automatically point to the correct path.

cereal 1,524 Nearly a Senior Poster Featured Poster

Then reverse it:

foreach($list as $key)
{
    echo in_array($key, $db2) ? "<input type='checkbox' checked value='$key' />$key" : "<input type='checkbox' value='$key' /> $key";
}
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use a loop with in_array():

foreach($db2 as $key)
{
    echo in_array($key, $list) ? "<input type='checkbox' checked value='$list' />$list" : "<input type='checkbox' value='$list' /> $list";
}

More information: http://php.net/in_array

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, can you repost the link, it seems daniweb doesn't like it. And what about the DocumentRoot?

cereal 1,524 Nearly a Senior Poster Featured Poster

This is created by the Apache Auto-Index module:

You can disable it by using Options -Indexes, or by placing an index.html (or index.php) into each directory. In alternative, if you need to create directory indexes, you should be able to stop the column sorting by using:

Options +Indexes
IndexOptions SuppressColumnSorting IgnoreClient

If you still have issues show your .htaccess file or the configuration of the virtual host.

cereal 1,524 Nearly a Senior Poster Featured Poster

The hosts file of the server should point to 127.0.0.1, each client hosts file to the remote IP, i.e. to 10.5.135.75. If this is the setting and there is no firewall blocking port 80 on the server, try the telnets commands and let us know the results. You can also include the error and access logs into the virtual hosts, so you can register these activities on the server, as example:

<VirtualHost *:80>
    ServerAdmin joao.dias@centralcervejas.pt
    DocumentRoot "C:/xampp/htdocs/ad/adtable"
    ServerName kadar
    ServerAlias www.kadar

    ErrorLog ${APACHE_LOG_DIR}/kadar_error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog ${APACHE_LOG_DIR}/kadar_access.log combined

    <Directory "C:/xampp/htdocs/ad/adtable/" >
        Options Indexes FollowSymLinks ExecCGI Includes
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
cereal 1,524 Nearly a Senior Poster Featured Poster

What do you mean? Do you get some kind of errors or the rules are not applied? Give us more information and post your .htaccess contents here. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition to AARTI suggestions, you can do this task with one single query:

insert into jannuary (ejant) select (htotal + ptotal + ttotal) as total from house, personal, transport;

Consider also to switch to PDO or MySQLi, since MySQL is deprecated and will be removed by the incoming versions of PHP.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, have you tried with another browser? The message can be due to an encoding problem of the page, it is not sure it's related to the server settings. Can you telnet from the clients to 10.5.135.75 80:

telnet 10.5.135.75 80
GET / HTTP/1.1

And then send two returns, if you can connect repeat with the domain name:

telnet kadar 80
GET / HTTP/1.1

Or 1.0 in case you get 400 bad request. It should return the index page. Otherwise post the response here.

cereal 1,524 Nearly a Senior Poster Featured Poster

The name of the file is not influent, it can be info.php if you prefer. You can also use phpinfo() instead of the previous:

<?php phpinfo(); ?>

you will get some information about your configuration, including the Apache Environment block, which returns also the value of the DocumentRoot.

To set the VirtualHost and the ServerName you have to edit the config file of Apache, in the below links you can find the instructions to do that:

If you have doubts attach those files to the thread, I'll help to edit them.

cereal 1,524 Nearly a Senior Poster Featured Poster

Agree, it doesn't seems correct. But it can be fixed, I think it depends on your setup:

  • IndonusaCI is the DocumentRoot? It's a section of a bigger website? To be sure about the DocumentRoot just place a PHP file in the root of the server with these instructions:

    <?php echo $_SERVER['DOCUMENT_ROOT']; ?>

  • have you set a ServerName in the VirtualHost of the Apache configuration file? Have you edited the hosts file to include the ServerName?

  • what is the value of $config['base_url'] in your config.php file?

Since I do not know your exact setup, I cannot suggest more to fix the issue. The only suggestion I can think is to avoid, for the moment, the rewritten links and to change the redirects by adding the /index.php/ segment:

redirect('/index.php/admin/home')

Or if this is a subfolder to:

redirect('/IndonusaCI/index.php/admin/home')

If this does not help, explain the structure of your application and show your Apache and CodeIgniter config files.

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to paste my previous instructions into the root .htaccess file, as example:

/
/.htaccess                 <-- edit this file
/index.php
/application/
/system/

Also, you have to remove the index.php from $config['index_page'] as already suggested, and change $config['enable_query_strings'] = TRUE; to FALSE, once you do this the ? will disappear and the link should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you be more precise? The edit regards the .htaccess in the root of the server or in that in the application directory? If the answer is the former then post the contents of the .htaccess here and also the contents of the config file.

cereal 1,524 Nearly a Senior Poster Featured Poster

That is the .htaccess of the application directory, which is not responsible for the rewrite of the url. In the root of the server you should have an .htaccess file, the basic contents of this file should be at least these:

<Files .htaccess>
order allow,deny
deny from all
</Files>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

This will allow your application to use rewritten links as in your form_open('/admin/verifylogin') otherwise you have to write:

form_open('/index.php/admin/verifylogin')

Also, in the config file /application/config/config.php change this:

$config['index_page'] = 'index.php';

To:

$config['index_page'] = '';

Because, as you can read in the file comments:

If you are using mod_rewrite to remove the page set this variable so that it is blank.

I think this should help to solve your problem. Let us know.