Stefano Mtangoo 455 Senior Poster

ok, the file attached.

Tracing down I believe here is a problem:

if (empty($id)){
    $sqlstr = "INSERT INTO banner(link, gambar) VALUES('".$link."','".$gambar."')";
    echo $sqlstr;

}else{

    $sqlstr = "UPDATE banner SET link = '".$link."',gambar = '".$gambar."' WHERE id =".$id;
    //other codes goes on....
}

But checking thru I found $gambar is an array containing:
'name' => string '956.png' (length=7)
'type' => string 'image/png' (length=9)
'tmp_name' => string '/tmp/phpvHQioh' (length=14)
'error' => int 0
'size' => int 627511
So Instead of using $gambar use either $gambar or whatever variable you want.
Sorry for being late, I have other things to do :)

Stefano Mtangoo 455 Senior Poster

do_upload($path)<--------------------did you forget $path??

Stefano Mtangoo 455 Senior Poster

I would like to thank you all for sharing your valuable posting.

Close thread!

Stefano Mtangoo 455 Senior Poster

if you cant answer or you dont know what to do you can say i dont have any idea about that and dont ever never waste your and any body's time .

I'm off the bandwagon!

Stefano Mtangoo 455 Senior Poster

This will upload images into a single folder.Needed to upload 3 images of a single form into different folder.

you can do a trick:

function do_upload($path)
	{
		$config['upload_path'] = $path;
		$config['allowed_types'] = 'gif|jpg|png';
		$config['max_size']	= '100';
		$config['max_width']  = '1024';
		$config['max_height']  = '768';

		$this->load->library('upload', $config);

		if ( ! $this->upload->do_upload())
		{
			$error = array('error' => $this->upload->display_errors());

			$this->load->view('upload_form', $error);
		}
		else
		{
			$data = array('upload_data' => $this->upload->data());

			$this->load->view('upload_success', $data);
		}
	}

Then each call in loop (for loop or while: whatever) supply different path!

Stefano Mtangoo 455 Senior Poster

could you attach the files so that I test in my system?

Stefano Mtangoo 455 Senior Poster

My dear i create css style i dont need to add any styles
Please answer my question it is not about creating any styles
As i said i create 2 style for my buttons class="button_active_small" style and class="button tertiary small" so, now i want to set first style for page that i already visiting it that with FOR LOOP COMMAND created and the other style for other pages.

do you pay me for anything I contribute?:(

Stefano Mtangoo 455 Senior Poster

its CSS issue try and adapt this code to your need

<style>
.button_active_small{
    font-weight:bold;
    text-decoration: none;
    color:maroon;
    border:1px;
}
</style>

<?php $j=23; $i=100; ?>
 <a class="button_active_small" href="<?php echo 'showcodes.php?ss='.$j; ?>"><?php echo $i; ?> </a>
Stefano Mtangoo 455 Senior Poster

Before you jump in one's script you must know what is happening. Try understanding how PHP Mail works. then it will make your task easier

Stefano Mtangoo 455 Senior Poster

Hello!! What i need to know to build this system?

You need to know:
1. What DSS is and how it works
2. HTML/CSS for styling and markup
3. PHP/Javascript for making things happen
4. SQL for storage
5. Optional but adds whistles and bell that is AJAX

Stefano Mtangoo 455 Senior Poster

use textmate or any other editor

Stefano Mtangoo 455 Senior Poster

here is an example from user guide

<?php

class Upload extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form', 'url'));
	}

	function index()
	{
		$this->load->view('upload_form', array('error' => ' ' ));
	}

	function do_upload()
	{
		$config['upload_path'] = './uploads/';
		$config['allowed_types'] = 'gif|jpg|png';
		$config['max_size']	= '100';
		$config['max_width']  = '1024';
		$config['max_height']  = '768';

		$this->load->library('upload', $config);

		if ( ! $this->upload->do_upload())
		{
			$error = array('error' => $this->upload->display_errors());

			$this->load->view('upload_form', $error);
		}
		else
		{
			$data = array('upload_data' => $this->upload->data());

			$this->load->view('upload_success', $data);
		}
	}
}
?>
Stefano Mtangoo 455 Senior Poster

Warning: Cannot modify header information - headers already sent by (output started at /home/leomconn/public_html/index.php:9) in /home/leomconn/public_html/index.php on line 190

Please I need somebody to help

As ardav said you cannot do that but there is a workaround. Use ob_start. If you want to know why, someone did took a trouble of explaining here

Stefano Mtangoo 455 Senior Poster

please help me to set active button for active page. page that you are in it.
and other style for other pages, page that you are not.

<?php
$j=0;
	
for($i=1;$i<=$cc;$i++)
{
	?> <li><a class="button active small" href="showcodes.php<? echo "?ss=$j"; ?>"><span><? echo"$i"; ?></span></a></li>
       <li><a class="button tertiary small" href="showcodes.php<? echo "?ss=$j"; ?>"><span><? echo"$i"; ?></span></a></li>
    
     <? 
	
	$j=$j+$nn; 
}}
?>

You mean styling the button? That is CSS and differs from person to person!

Stefano Mtangoo 455 Senior Poster

how do i then make each of the files in the directory able for download

http://stackoverflow.com/questions/364946/how-to-make-pdf-file-downloadable-in-html-link

Stefano Mtangoo 455 Senior Poster

pls close the thread!

Stefano Mtangoo 455 Senior Poster

That's a bit big-headed of you ev. :)

That will work of course ev, if you set up the system to log emails. However, if you go to the whole trouble of that, you may as well do a login - the user still has to go to the email account and 'stuff'. The only diff is that you supply and username and password as well.

Hehehe! I mean't that he have to do a login system to save himself some pain!

Stefano Mtangoo 455 Senior Poster

its a lot of code ev - what if there were 15 search terms or more?
I'd have a list of search-keys and place them in an array:

$post = array_map("mysql_real_escape_string",$_POST); //clean input
$s_where = ""; //set where clause to nothing as default
$params = array("tags","age","rating","city","state"); //search-* fields to include
foreach($post as $k=>$v){
	//if the post key is in the array, add the value to the $r_where array 
	if(substr($k,0,7) == 'search-' && $v != '' && in_array(substr($k,7),$params))$r_where[] = substr($k,7) . " = '$v'" ;	
}
//if $r_where exists, create the where clause
if(isset($r_where))$s_where = " WHERE " . implode(" AND ", $r_where);
//run the query
$result = mysql_query( "SELECT * FROM `bgc_models`{$s_where}" ) or trigger_error( mysql_error() );

This way if you need to add extra search fields, you just add a value to the $params array - otherwise you'd need to add a whole conditional statement.

I agree with that ardav, but one thing you have forgotten: you know how dangerous what you have just done and mitigation and s/he is likely not knowing. it increases angles hacker can use can use to penetrate your app.

If he was experienced, I would say s/he would just build list of column into array of whitelist and check if hacker have tempered with column name in POST array. So your code (which is simpler and extensible) plus whitelist of column plus parametric queries makes simple and powerful code!

However, I agree with ev, PDO is safer, although if you clean your …

Stefano Mtangoo 455 Senior Poster

your datagrid class is poorly designed and here is why:
1. You have mixed Database issues with non database
-Either make it fully database with all connections and queries in one class
2. You make mistake of adding html into class. Html should be in separate php class where you will be calling class methods. Here is small skeletal example. I have mixed DB functions and data getting but it is best to separate them

<?php
class DataClass{
    private $host="localhost";
    private $username="database_username";
    private $password = "password";
    private $db = "blog_database";
    private $conn; //shared connection by all class function via $this->conn
    
    public function __construct(){
       $this->conn = mysql_connect(.....);
       mysql_select_db(...); //use $this->db/conn
    }
    
    public function getBlogData($id){
        //get all the data using query
        //get array of blog data
        $array = mysql_fetch_assoc(....);//array of blog data
        return $array;
    }
    
    //other functions

}
?>


<html>
    <head>
    </head>
    
    <body>
        <div>
        <?php
            $blog_obj = new DataClass();        
            foreach($blog_obj->getBlogData($_POST['id']) as $heading=>$contents){
                echo "<h3>$heading</h3> $contents";
            }
        ?>
        </div>
    </body>

</html>
Stefano Mtangoo 455 Senior Poster

introducing variables into query will expose you to dangers of SQL injection. it is bad practice AFA security is concerned. I would have if..else for that, something like below. Also instead of using mysql_** I would use PDO or MySQLi

$tags = $_POST["search-tags"];
$age = $_POST["search-age"];
$rating = $_POST["search-rating"];
$city = $_POST["search-city"];
$state = $_POST["search-state"];

$sql = "";
if($tags==""){
    //tags is empty, write query excluding age column
    $sql = "SELECT * FROM bgc_models WHERE age = '$age'  AND rating ='$rating' AND city = '$city' AND state='$state' ";

}else if($age==""){
    //age is empty, write query excluding age column
    $sql = "SELECT * FROM bgc_models WHERE tags = '$tags'  AND rating ='$rating' AND city = '$city' AND state='$state' ";
}
//more if else
else{
//no empty field, write full query
$sql = "SELECT * FROM bgc_models WHERE age = '$age'  AND tags = '$tags'  AND rating ='$rating' AND city = '$city' AND state='$state' ";
}
$res = mysql_query($sql) or die(mysql_error());
//more code
Stefano Mtangoo 455 Senior Poster

just a hint based on your code. foreach loop works better than for loop!
$array = array("Moja", "Mbili", "Tatu");

foreach(array as $key=>$value){
    echo "Array Key is: ".$key." And value is: ".$value;
}

Arghhhhh!
You have just resurrected old thred ;)
Let them die and open new thread for your question!

Stefano Mtangoo 455 Senior Poster

If you need to activate something, send them secret code and not any user information. If you want to be more secure, use double word activation in that two keywords are needed to activate and they are sent separately in different times. You can use tri-keyword...et al depending on sensitivity.

if they are things like credit card accounts, make usage of account possible some time after activation and send a warning to an email that somebody activated their account. if that somebody was not them they should send email to admin or whoever. That will help in case hacker did interfere communication!

Stefano Mtangoo 455 Senior Poster

Also is cookies enabled on browser?

Stefano Mtangoo 455 Senior Poster

Are you serious? How do you expect to do this? I could vote in your poll, then change machines and vote again. You need to have a login to vote. IP addresses are clumsy and don't work anyway. I've seen, place your email account here boxes, but that's pointless - I could give them yours. :) Cookies can be cleared by the user anyway.

There is a way, more "excellent" than login. let them fill their email and a link is sent to them and they can vote. you will have simple work of blacklisting emails after vote. This is very convenient and fast way. It makes users happy as they have to go thru simple and easy step of filling email, waiting for the emails and vote. it is simple to implement in that you have to monitor for all fake emails like 10minutesmail.com or mailinnator.com that can make same person vote virtually million of times.

This system is very simple and efficient than old hard and user unfriendly login-based!
This post is very useful if you read it backward,
thank you!

Stefano Mtangoo 455 Senior Poster

What to do to make it stretch the div if it's too long(about 100 lines of text)?

If I understand well your question, then you would use same css proerty you used with element itself

Stefano Mtangoo 455 Senior Poster

I use CSS but what code I need to use to make it stretch itself along with the div?

What do you mean?

Stefano Mtangoo 455 Senior Poster

have tried that commands, it's now saying "E: Unable to locate package build-essentials"

Sorry my typo: it is build-essential

sudo apt-get install build-essential
Stefano Mtangoo 455 Senior Poster

Thanks evstevemd, works a treat!!!!

Cheers!

Enjoy!

Stefano Mtangoo 455 Senior Poster

How can anyone in the world write form like this

<form method="post" action="proseslogin.php">

and catch by this?

$username = $_REQUEST['username'];

Use explicitly $_POST or $_GET

Stefano Mtangoo 455 Senior Poster

session_start() on top of a page?

Stefano Mtangoo 455 Senior Poster
If($var){
include "page1.php";
}
else{
include "page2.php;
}
Stefano Mtangoo 455 Senior Poster

Now, after I destroy session, I cannot login at all to admin.php by entering the url nor by login.

I insert session_destroy(); by accident in proseslogin.php instead of in logout.php only. Now I leaving session_destroy(); in logout.php only.

I still unable to login though evenif I enter the correct username and password.

----------

Nevermind, I am able to login back by using the correct username and password after commenting out unset($_SESSION); in proseslogin.php and using it back. But then, the condition returning to first condition where I am able to enter admin.php by url besides login.

We cannot say for sure, we cannot see what is in your family!

Stefano Mtangoo 455 Senior Poster

how do i install the gnu compiler collection for ubuntu? my internet connection is too slow for me to download such big files so compiling source is the way top go for me

What will you compile them with?

sudo apt-get install build-essentials

Stefano Mtangoo 455 Senior Poster

but even when I fill in the form, I have not see the form capturing the data and insert them to the database. Because after I press save button and check the database none of the data is there.

If something goes wrong with isset($_FILES) then it will default to empty string. You can do var_dump($_FILES); to see if everything you are sending is actually available. from there you can know what to check!

Stefano Mtangoo 455 Senior Poster

so what is your question Doug?

Stefano Mtangoo 455 Senior Poster
<?php
function fix_it($name)
{
    $name=ucwords(strtolower($name));
    //echo $name; <----Don't echo just return it
    return $name;
}
?>
Stefano Mtangoo 455 Senior Poster

simple wxPyCode that does nothing, just a display!
import wx

class wxDemo(wx.Frame):
    def __init__(self, parent): 
        wx.Frame.__init__(self, parent, title='Demo Frame')
        self.panel = wx.Panel(self, -1)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.combo = wx.ComboBox(self.panel, choices=['Moja', 'Mbili', 'Tatu', 'Nne', 'Tano'])
        self.text = wx.TextCtrl(self.panel, wx.ID_ANY, style=wx.TE_MULTILINE)
        
        self.sizer.Add(self.combo, 0, wx.EXPAND)
        self.sizer.Add(self.text, 1, wx.EXPAND)
        
        self.panel.SetSizer(self.sizer)
        self.panel.Layout()
        
app = wx.App()
fr = wxDemo(None)
fr.Show()
app.MainLoop()
Stefano Mtangoo 455 Senior Poster

And don't say OOP isn't hard! It took me 5 years to knock on the door! :)

:)

Stefano Mtangoo 455 Senior Poster
$gambar = isset($_FILES['gambar']) ? $_FILES['gambar'] : '';

If gambar is not set then it sets it to empty. this is bad. if file is empty you should redirect to the form as something is wrong with it!

Stefano Mtangoo 455 Senior Poster

unset session then destroy it

unset($_SESSION);
session_destroy();
Stefano Mtangoo 455 Senior Poster

i m sorry to say that i havnt create any api communication between php and javascript before! .

Check w3Schools

Stefano Mtangoo 455 Senior Poster

Only way JS and any server language is via AJAX. I cannot see any other way!

Stefano Mtangoo 455 Senior Poster

do you mean AJAX?

Stefano Mtangoo 455 Senior Poster

I still don't completely understand. I thought by using search criteria in the array I could link the pagination to my search results. But you're saying that is impossible?

So I shouldn't use this and make a completely different script?

What I'm saying is, your pagination should be free from database issues. It should not care where data come from. For example if your script receives array of data and paginate them you can use it pretty anywhere than when it is tied to DB queries or other stuffs!

Stefano Mtangoo 455 Senior Poster
int func1(int x){
    //do something with int
   return func1(x-1);
}

see also this and this one

Stefano Mtangoo 455 Senior Poster

use GUI toolkit. If you go for wxPython there is wxComboBox as one of options

Stefano Mtangoo 455 Senior Poster

Database arrays does not understand where result came from (search or article, all it knows is it is from db). It seems your pagination code is tied to DB code which is quiet bad thing to do!

Stefano Mtangoo 455 Senior Poster

May be use CSS

Stefano Mtangoo 455 Senior Poster

I don't think there is PHP solution as issue is HTML. I would suggest you use Javascript to just show heading and one drop list per click(accordion). I know my explanation are unclear but check this JQuery UI element to get picture:
http://jqueryui.com/themeroller/#themeGallery

Stefano Mtangoo 455 Senior Poster

$topic is shows up as blank.. even though the id is in the url... I dont know why its not retrieving it from the url...

post the url and how you do retrieve the id!