Stefano Mtangoo 455 Senior Poster

I looked and looked and worked with them and found other related material.

Anyway thanks for pointing me in the right direction :) .. IM onto my next step :))

if you hit a wall with your new code just be welcome!

Stefano Mtangoo 455 Senior Poster

so what did you do with links I gave?

Stefano Mtangoo 455 Senior Poster

It seems there is issue with server you are using. I would suggest you install WAMP/XAMPP to avoid the issue!

Stefano Mtangoo 455 Senior Poster

please post your current code and ask from there!

Stefano Mtangoo 455 Senior Poster

Is there something better i can do w/ the Values before i insert the array into MYSQL ?

What does better means? And w/ is meaningless to my head. Please write full words!

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

try rebooting server may be (if local). Cant see anything big with code unless you have loops in your "secret" code !

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

That is AJAX!

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

Newbees should learn to use google :)
If you did here is one of results
http://stackoverflow.com/questions/5164930/fatal-error-maximum-execution-time-of-30-seconds-exceeded

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

Ardav,
It makes sense to me now especially that bitwise operation!

Stefano Mtangoo 455 Senior Poster

I'd have these levels built on bits:

master = 16
admin = 8
sup'vr = 4
gp = 2
pat. = 1

SO if storing levels for an user:

if a gp and a master - value = 2 + 16 = 18

store this in your users table

then when user logged in you can check if they are a gp and should see the gp tab like so:

if($row['level'] & 2){
  ..show gp tab...
}

if($row['level'] & 16){
  ..show master tab ..
}

etc.

The beauty of this is that you can keep on adding new levels without having to mess up your DB structure.

though didn't ask the question, I got lost as I was reading :)

Stefano Mtangoo 455 Senior Poster

so does it still give you troubles?

Stefano Mtangoo 455 Senior Poster

So answer is yes, are we solved? :)

cwarn23 commented: thanks +12
Stefano Mtangoo 455 Senior Poster

enjoy :)

Stefano Mtangoo 455 Senior Poster

make hidden form element capt_id and make a copy of it in session. When form submitted compare the two. IF they don't match reject form, someone have just tempered to with your form. else process it with variable in session or form (since they are equal)

Stefano Mtangoo 455 Senior Poster

I agree with Sorcher. If you have enough bandwith there is "e-teacher" somewhere on youtube

Stefano Mtangoo 455 Senior Poster

@ev

Did you understand that? Crickey! I made more sense of a mad Greek taxi driver shouting over his shoulder at me when I was asleep in his cab. :(

I just guessed that he was explaining his project and asking if it was possible to do that with PHP. If I'm wrong, then it does not matter anyway ;)

Stefano Mtangoo 455 Senior Poster

Maybe I will if I don't find a way to fix it. But I am used to xampp, some configuration, on wamp there migth be some other things I don't know. But thanks of course for this advice also

Actually configuring Wamp is as breeze as right clicking the tray icon and behold all configs are there :)

Stefano Mtangoo 455 Senior Poster

Yeah it is possible with HTML forms and PHP (sessions)

Stefano Mtangoo 455 Senior Poster

I believe what you are after is a piece of software called "Mercury". Mercury is a program which allows you to receive and send emails on windows however I'm not sure what the Linux equivalent would be. You would also have to ask your isp for a static ip and do some port forwarding on your modem and/or router for the emails to process through your computer.

http://www.linuxmail.info/

Stefano Mtangoo 455 Senior Poster

Mail Server? I'm sure you don't want to code one. Unless you mean installing mail server or you want to create mailing script!

Stefano Mtangoo 455 Senior Poster

But I don't know programming so it would take you a lot less time and it is good for everyone because this way you can have free storage of all your videos of your family without storing them on your personal hard drives which can fail and lead to irreparable loss of important videos.

Learn to program first and then move into doing programming projects!
http://www.w3schools.com/php/default.asp

diafol commented: my thoughts exactly :) +14
Stefano Mtangoo 455 Senior Poster

if you don't mind waste time fixing things you can use Wamp. In windows is what I use!

Stefano Mtangoo 455 Senior Poster

evstevemd, Thanks again for the heredoc pointer.

Enjoy and welcome to Daniweb!

Stefano Mtangoo 455 Senior Poster

Thanks !! raphie

I have one query also.I have a registration form where i am checking whether the given(by user) email is exist or not.
after googling found some code:
This code is working fine.but i have other validations also.like email format,password same,& empty fields.
want to work my form in proper sequence
i.e.
It checks empty condition,email format,then email availability.
Need help/suggestions

Don't do final validation on JS, it can be easily bypassed. You can do empty variable checks and maybe other but make sure you do final validations at Server side! That is a security note :)

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

Check directory iterator class. Here is sample code

<?php 
$dirIterator = new DirectoryIterator(dirname(__FILE__));
foreach ($dirIterator as $fileInfo) {
    if($fileInfo->isDot() || !$fileInfo->isFile()) {
        continue;
    }
    echo "<p>".$fileInfo->getFilename() . "</p>";
}
Stefano Mtangoo 455 Senior Poster

This appears:

Array ( [link] => www.banner.com [id] => [simpan] => Simpan )

there is no element with name gambar as you can see from array. Either!
Check your HTML form

Stefano Mtangoo 455 Senior Poster

note that you have to edit location of ckeditor.js in head tag!

Stefano Mtangoo 455 Senior Poster

ending tags and string for values are missing

<input name="nama" size="20px" type="text" value =<?php echo $data['nama_produk']; ?>>

is supposed to be

<input name="nama" size="20px" type="text" value ="<?php echo $data['nama_produk']; ?>"/>
Stefano Mtangoo 455 Senior Poster

I had to go and fix all unquoted values in your input plus you didnt close much of your html tags
<input ..../> was missing a lot. Take a look of rough fix below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
<link href="admin-style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="includes/navstyleadmin.css" />
<script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="includes/superfish.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<link href="ckeditor/content.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
jQuery(function(){
	jQuery('ul.menu').superfish({
		animation: {opacity:'show',height:'show'},
		speed: 'slow', 
		autoArrows: true
	});
});
</script>

<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>
</head>

<body>
<div id="header">
      <p><a href="#">Home </a>| <a href="index.php">Logout </a>| <a href="admin.php">Admin Panel</a></p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
    </div>
    
    <div id="search">
      
      <form action="search.php" method="post" name="login" target="_self" id="login" style="style.css" title="search">
      	<br>
        <label>search :
        <input type="text" name="search" id="search2" />
</label>
        <br />
                    
      </form> 		
	</div>
    
    <div id="menu">
            
<?php //include ("includes/navigation_admin.php"); ?>
<?php //include ("includes/koneksi.php"); ?>        
	 </div>     
        

<?php


// DATA BARU

//if ($_REQUEST[mode]=='edit')
//{extract ($_REQUEST);
//do something  

//echo $_REQUEST['id'];
//will give us the valid id from the previous page.
//}

if (empty($_GET['id']))
{
$nama = '';
$kategori = '';
$harga = '';
$deskripsi = '';
}


$nama = isset($_POST['nama']) ? $_POST['nama'] : '';	  
$kategori = isset($_POST['kategori']) ? $_POST['kategori'] : '';
$harga = isset($_POST['harga']) ? $_POST['harga'] : '';	  
$gambar = isset($_POST['gambar']) ? $_POST['gambar'] : '';	  

// SETELAH TOMBOL SIMPAN DI TEKAN

if (isset($_GET['save'])){
		$nama = $_GET['nama'];
		$kategori = $_GET['kategori'];
		$harga = $_GET['harga'];
		$gambar = $_GET['gambar'];
		
		/*if (empty($_GET['id'])){
			$result = mysql_query("INSERT INTO produk(nama_produk, harga, gambar) VALUES('".$nama."','".$kategori."','".$gambar."')");
			}
		else{
			$result …
Stefano Mtangoo 455 Senior Poster

if i do this, it works....But is it a good way?

Bad way and here is why

function getArticles() {
		global $mysqli;
}

You are using global instance not the one in class. you should user class property instead and remove the global thing

if ($result = $this->mysqli->query($query) )
Stefano Mtangoo 455 Senior Poster

using prepared statements will easy your code as well as give extra protection against SQL injection
http://devzone.zend.com/article/686

Stefano Mtangoo 455 Senior Poster

what is your definition of large data?

Stefano Mtangoo 455 Senior Poster

have you confirmed problem is gone when you comment out CKEditor related code?

Stefano Mtangoo 455 Senior Poster

couldyou add print_r($_POST); die(); and comment out $gambar = $_POST;

Stefano Mtangoo 455 Senior Poster

I remember using # comment for Python have never tried that for PHP.
BTTT,
You have mixed HTML and PHP to a point f confusing me, cant help with that. If you need to print something like for use HEREDOC syntax. And goto? Can't beilieve it!

here is clean way of adding html in PHP

$form = <<<EOT
<form action={$_SERVER["PHP_SELF"]} method="post" enctype="multipart/form-data">
    <label for="file">Select File...</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
</form>

EOT;
echo $form;
Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

may be issue is with CKEditor. I have not included it in my JS so it should be in my shot. Try to remove CKEditor codes to confirm that it is a culpit then open new thread specifically for that problem!

Stefano Mtangoo 455 Senior Poster

line 154:

<textarea name="deskripsi" cols="30" rows="15" value=<?php echo $data['deskripsi']; ?></textarea>

Stripping the PHP Database code everything runs fine
see the shot!

Stefano Mtangoo 455 Senior Poster

I have this:

Notice: Undefined index: deskripsi in C:\xampp\htdocs\Masterlink\cgoods\product_edit.php on line 154

in side deskripsi text area.

//$data['deskripsi'] = ''; // I have to keep the following disable otherwise, it will show me a text area that are filled with codes or the ckeditor disabled.

error cannot be here. Here you are just adding to array. Try checking where you actually use the array value!

Stefano Mtangoo 455 Senior Poster

are we solved yet?

Stefano Mtangoo 455 Senior Poster

I found a blog docummenting changes in hotmail Auth

require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.live.com"; // sets HOTMAIL as the SMTP server
$mail->Port = 25; // alternate is "26" - set the SMTP port for the HOTMAIL server
$mail->Username = "yourusername@hotmail.com"; // HOTMAIL username
$mail->Password = "yourpassword"; // HOTMAIL password

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->Subject = "PHPMailer Test Subject via smtp (Hotmail), basic";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

As Usual I suggest wxWidgets and the wxBook is a good place to start

Stefano Mtangoo 455 Senior Poster

Try moving $data outside if/else

$data = array();
if(!empty($_GET['id']))
	{
	$result = mysql_query("SELECT * FROM produk AS p, kategori AS k WHERE id_produk='".mysql_real_escape_string($_GET['id'])."'AND 			    p.id_kategori = k.id_kategori") or die(mysql_error());
    $data = mysql_fetch_array($result); //here you define data
    }
else
	{
	$data['nama_produk'] = '';//it skipped data and hence data is undefined
	$data['nama_kategori'] = '';
	$data['harga'] = '';
	//$data['deskripsi'] = '';
	$data['gambar'] = '';
	}
Stefano Mtangoo 455 Senior Poster

Which version are you using? This question suggests that version 5 have it fixed