Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

I would suggest you look at SwiftMailer (my fav) or PHPMailer to send mails. For all practical purposes I don't use PHP mail()

Here's a sample from Documetation

require_once 'lib/swift_required.php';

// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
  ->setUsername('your username')
  ->setPassword('your password')
  ; 

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('john@doe.com' => 'John Doe'))
  ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
  ->setBody('Here is the message itself')
  ;

// Send the message
$result = $mailer->send($message);
Stefano Mtangoo 455 Senior Poster

The Code below shows how to iterate Strings.
With Efforts you should be able to get what you want
God bless you!

#include <string>
#include <iostream>

int main()
{
    int i=0;
    std::string s = "UJehova uyaphile Yesu Mwema!";
    for(i; i<s.length(); i++)
    {
        std::cout<<s[i]<<std::endl;
    }
    return 0;
}
Stefano Mtangoo 455 Senior Poster

couple of options

  1. Limit number of tags and strip off the rest (then encode string in case some entities made its way)
  2. Use HTML Purifier (google it)
  3. Use Markup language

Always validate your inputs

Stefano Mtangoo 455 Senior Poster

you seem to use GMail SMTP but the code below uses your host machine (which am sure is not google's SMTP servers

$mail->Host = "localhost";

So change it to google SMTP. here is example from their site (simplified)

$mail = new PHPMailer();
$body = "Your Body here!";
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "yourusername@gmail.com";  // GMAIL username
$mail->Password   = "yourpassword";            // GMAIL password

$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->Subject    = "PHPMailer Test Subject via smtp (Gmail), 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");
//optional
$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

It all boils don to what you want to do.
PHP and Python are different like spanner and screw driver. You will need each other for its task.

If you want web go for PHP and if it must be Python then Django helps here. There are others like Ruby and RoR. so you have a lot to explore!

Stefano Mtangoo 455 Senior Poster

I have a collection of resources on my site. Check if they be helpful to you!

Stefano Mtangoo 455 Senior Poster

In that case you need to use GUI toolkit for UI.
I suggest wxWidgets!

Stefano Mtangoo 455 Senior Poster

No Better OpenSource is there Yet and many people cannot pay when there is better free alternative!

Stefano Mtangoo 455 Senior Poster

not sure I understand your query but its easier to separate things like
loginform.php where all login form html/php data goes
member.php contain memeber are protected for non members
index.php for putting things together

Now in index.php

if($userIsLoggedIn)//your mechanism for logging in
{
//set some member area variables here is a sample
$isMember=true;
include("member.php");
}
else
{
include("loginform.php");
}
Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

Last one is the best plus, use parametric queries (Bind/execute)

Stefano Mtangoo 455 Senior Poster

hi,
the app is growing and everyday i must add new fields.

App growing or bad design? App growing should at worst add new table not alter a table.
I think it is time to check your design!

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

Simple xml is not something I've come across before...

http://www.phpro.org/tutorials/Introduction-To-SimpleXML-With-PHP.html

Another dirty option will be scrapping all html page from link and display them as they are!

pritaeas commented: Nice +14
Stefano Mtangoo 455 Senior Poster

Yes i got this, but my code does not work.

which code? I cannot peep in your computer and see your code. You have to post your RELEVANT current code!

diafol commented: Peep into your computer! Love it :) +14
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

If using DBs, the standard cleaner is mysql_real_escape_string().

Moving to MySQLi or PDO and do parametric queries is the recommended way !

Stefano Mtangoo 455 Senior Poster

I changed line 12 like u said but it still isn't working.

"isn't working" does not convey anything useful!

Stefano Mtangoo 455 Senior Poster

the auto detect solved the problem, thanks a lot

Mark it so then!

Stefano Mtangoo 455 Senior Poster

Seems to me like you need this to get up

Stefano Mtangoo 455 Senior Poster

Thanks, I had been looking and looking and totaly missed that.

Are we solved yet?

diafol commented: 2 posts - you'll be lucky! :) +14
Stefano Mtangoo 455 Senior Poster

I find it better to use the in built mail function because it uses the local mail server rather than a third party mail server. Also using the mail function can speed things up if you have configured the mail function correctly in the php.ini file along with an active mail server on the local server. :)

I agree with you but for newbees, dealing with mime is not funny :)

cwarn23 commented: agreed :) +12
Stefano Mtangoo 455 Senior Poster

have a look at this tutorial

Stefano Mtangoo 455 Senior Poster

So answer is yes, are we solved? :)

cwarn23 commented: thanks +12
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

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

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 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

System32 is one of those folders. Why not just put exe and dll in same folder? I always hate to put non system DLLs into my system folder. Alternatively just create libraries folder somewhere and add it to system PATH!

Stefano Mtangoo 455 Senior Poster


--------------------------------------------------------------------------------
Kepada : Kamu Subject : AdditivePesan : PesanDari : David
Error sending: Message body empty Telah dilakukan!

Why is it ?

Mh! You have to learn reading error messages!

Stefano Mtangoo 455 Senior Poster

Ok i am trying to create a simple program that will allow me to use an array with 8 numbers, the output form should show the numbers in their original order that the user inputs them, in numerical order, Highest number, lowest number and then the average number. If anyone could help me it would be much appreciated. here's waht i have so far.

<?php
if (isset($_POST['numbers']))
//if (is_numeric($_POST['numbers']))
//if (!empty($_POST['numbers'])) 
{ 
    $Numbers = $_POST['numbers'];
	$big = max($Numbers);  
	$small = min($Numbers);
	$average = array_sum($Numbers) / count($Numbers);
	print "Original Sequence:<br>";

	$sorted = sort($Numbers);	
 	print "Sorted Numbers: $sorted";
	echo implode(" ",$Numbers);
	print "<br>Largest Number: $big<br>";
	print "Smallest Number: $small<br>";
	print "Average Number: $average<br>";}
else {
	print "<font color='red'>Invalid Input Grades must be Numeric</font>";}
		
	 
	?>
$var = array(1,2,3,4,5);
foreach($var as $number){
    echo $number;
}
Stefano Mtangoo 455 Senior Poster

What I would do is:
I will store the full path in config file and store filename in session then I will simply concatenate the two!

Stefano Mtangoo 455 Senior Poster

if you have good BW this youtube channel have really good tutorials

Stefano Mtangoo 455 Senior Poster

Hi all,

Trying to get my head around OOP at long last. Finally got to the beggar on my to-do list.

Welcome to the world of beasts ;)

Just a quick question:

I was looking for a way to persist the object across pages, but on further research, I got the idea that this is a bad idea and that objects should be created anew on every page. Does this also apply to Ajax calls (I assume it does)? Seems like a lot of work for a straightforward part-of-page-update. I haven't got a specific use in mind, still at the concept stage.

Why would you want to persists objects across the page? Since technically AJAX call is just like other calls with no reloading of page then things goes just like the non Ajax page. I think that should be avoided and alternative is given below. If you persist on testing the concept, check serialize/unserialize and this one

Just thinking of all the include files req'd by a simple php script on a round trip from the client. Any thoughts on this? I'm noob^infinity on OOP.

I think the best way would be storing in session key (like ID) to a table containing info necessary to create an object. Then query the info and create an object that will persist per each page.

I just tried google and here is an interesting thread

diafol commented: Nice one Ev - I'll probably be back to pick your brains some more :) +13
Stefano Mtangoo 455 Senior Poster

Yes, thank you, of course image not a button as you said ( wrote it late at night ). I know JS doesn't need href. The point was: <a href='index.php?id=$value'> is passing them when you click the image that also calls JS. Ajax calls a php script that deletes the entries based on those values from <a href> and this php script is included in index.php.
So I wanted to stop the refresh when the image is pressed and ajax is called. I know a bit intricate so I've decided to re-program this now...but thanks a lot.

P.S. ...also the id or name need to pass a dynamic value from php to a href from a while loop. I just haven't included all script.

id should be added during creation of contents/comments from server. for example if your comments are in a div then add id of a button/image the same as id of the comment in database. Catch onclick events for all buttons/images, take an id and send it to delete.php (or whatever delete comments) via ajax.

Stefano Mtangoo 455 Senior Poster

THIS is really not helpfull, cant understand anything from it, provide link to download it for windows XP 32 bit.

Because it was not intended for you.
Don't resurrect old threads, let them lie dead.
Start new thread

Stefano Mtangoo 455 Senior Poster

Hi thanks for the links. I understand the difference and the main one is that the constructor does not get called with malloc. I guess my question is whats the difference between this:

vector< string > * u = (vector< string >*) malloc(  sizeof(vector< string >)) ;
 *u =  vector< string >(10,"test");

Note I have called the constructor after malloc, which correct me if i'm wrong calls the constructor of vector and puts in 10 string elements all intialised to "test".

and This:

vector< string > *u =  new vector< string >(10,"test");

What does new do to the memory block other than call the constructor?

Thanks

You are opening the whole can of worms. You have to find how each compiler implements the new operation and reinvent the wheel. I guess internally they use malloc/free
Here is related question:
http://stackoverflow.com/questions/1031301/can-i-implement-the-factory-method-pattern-in-c-without-using-new/1031375#1031375

Stefano Mtangoo 455 Senior Poster

clean, validate and verify all data and users, never trust any input
hash all your passwords and salt them with well long and random salt
each time there is database access operation requiring critical data, verify user by asking password
forms should have expirable tokens
there are many angles to conside and I would suggest you check with owasp.org sql cheetsheet

Stefano Mtangoo 455 Senior Poster

the 2nd, it comes from the mysql table (with double quotes escaped: <span style=\"background-color:yellow\">Expires $expdat.</span>. There's something being lost when the value comes from the table.

The problem is how you insert than the display part. Show us relevant code of your insert, especially how you construct SQL query!

faroukmuhammad commented: Yes, there may be mokey business inside the table +3
Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

O.k remove the apostrophe enclosing the "0", if the field is not char, varchar, text, etc.

mysql_query(" UPDATE table_name SET code_used= 0 WHERE param_code ='$submit' ", $con) or die (mysql_error());

In My Installation it makes no difference whether I use 0 or '0' in my TINYINT(1)

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

sorry, im a newbe here!

Welcome but be warned we don't do peoples' assignments and projects!

my project requires a system/software development project proposal document. Using a chosen system/software development model

Look at the bold and start here. Which model (among those you were taught) have you chose?

and its different stages e.g. planning, requirements analysis, etc. describe the steps or activities that need to be performed at each stage.!

Once you choose model the go through bolded stages, etc included :)

i dont have the idea where to start,,please help me

You have starting point there!
http://en.wikipedia.org/wiki/Software_development_process

Stefano Mtangoo 455 Senior Poster

Did you just revive a dead thread, evstevemd? Since when did Jwenting got ban? Or is his ban period over?

He got one...long ago when I was Java-man and frequently visited Java forum.

jingda commented: I see +0
Stefano Mtangoo 455 Senior Poster

i was used what in this post

but i am not familiar with xml

Check this video:
http://www.youtube.com/watch?v=Nke7SmhDh-M
and/Or:
http://www.php-beginners-guide.com/ch08.pdf

Stefano Mtangoo 455 Senior Poster

LOL! @WaltP: Pretty good timing for this thread! Don't you think?

Yet another example of "I compile this with DevC++ and it doesn't work, but it works with other IDEs like ..".

:D

But I would also recommend you pick another IDE besides DevC++, like Code.Blocks or Visual Studio, and try to pick a recent version.

Duh! DevCpp dies hard :)

Stefano Mtangoo 455 Senior Poster

.... Linux? The O/S is know to be a geek's O/S. You need to know more about the system to get things running. It's like using a car with a manual transmission -- more control, more knowledge needed. Not a bad thing.

Windows is the automatic transmission of the O/S world -- put it in drive and step on the gas. Any lameoid can use it.

Mh! When was your last time to play with Linux? Which Distro did you fiddle around with?
With Ubuntu (at least starting from version 10.04) and Fedora (From version 12, at least) they just work!
Anyway that is kind of myth even my friends had. They didn't even knew that 10.04 was Ubuntu, let alone being Linux! May be they thought it was Mac OSz;)

jingda commented: http://images.daniweb.com/smilies/sleek/qqb007.gif +9
Stefano Mtangoo 455 Senior Poster

For years when people post that they are using Turbo-C/C++ they always get a heated response saying basically "why are you using that piece of sh*t? Use Dev-C++ instead."

Dev-C++ was being recommended because it's newer, it followed the standard better, it's free, etc. A couple years ago, though, it stopped being supported. Now, just because it's not being supported, it's now terrible? It even elicits responses like

Buggy? If it was so buggy, why was it being recommended for so many years? What kind of bugs does it have? And why are programmers dissing it all of a sudden? When it became unsupported did it also break?

Here is why I don't recommend Dev-Cpp
1. Outdated Mingw (If you are so in love with it, compile/configure it yourself to the latest)
2. No Support, in case of any bug. The argument goes like this: If you find something buggy, no one will fix it for you. So why try it when there is better alternative?
3. Bad interface (At least for me), very ugly - But then, the pragmatist says: who cares? I do :)

If you insists on Dev-Cpp, there is active version developed called wxDevCpp (wxWidgets RAD + DevCpp). I would recommend though CodeLite (Which I use) and its rival, Code::Blocks. There are other like KDevelop et al but I have never loved them enough to learn them.

Stefano Mtangoo 455 Senior Poster

sanitize ALL input data.

It is huge process actually. I plan to do little series on security by the end of this month, God willing (Not expert at all but learning) But here is my suggestion on angles to check:
1. As ardav pointed out, always suspect user - Sanitize and validate ALL external data
2. Secure your session and site against CSRF, XSS and other common attacks
3. Escape all outputs
4. Guard your Database against SQL injection
5. Add DoD, that is in case one thing is compromised (like session variable) then intruder can still be delayed to get in
6. Log all login attempts and if username applies lock after several attempts and alert user with unlock link. If user does not exist, send email to admin.

Actually there are more to that but those are the one I can think for a moment

Stefano Mtangoo 455 Senior Poster

My Gosh,when i saw this thread i thought the worst Dani..... (On another site im on we just lost the admin.. (She passed away) and we are all very saddend by this.....)

I am sorry Davey is going thru this but im glad he hasnt left us... (Knock on wood)

Congrats Julienne,i know you will do as good a job as David Did :)


Peace and love to all :)

Last month we thought we had lost Davey as he was going through some tough personal times. Thankfully though, he has announced that he will resume his role and should be back in full force within the coming weeks. During his absence, the role of community admin was placed in the capable hands of Narue, another DaniWeb legend who has been with us since the beginning of time. Happily, once happygeek returns, we'll have two super stars guiding the ship.
DW News Letter
Cheeeerssss!

jingda commented: Cheers to you +0
WASDted commented: Thanks for the kind words. They sure deserve it. +0