Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

with my hint above modulo operation is unnecessary!
:)

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

And note that Python does not compete with C++ to the fullest sense of the word. It compliments it. you speedily develop in python and when you need critical operations you can make a C/C++ program and use it for that Part.

Have you heard of CTypes? One of best things ever occured to Python :)

Stefano Mtangoo 455 Senior Poster

I'm not as professional as Mike, Vijay, and the co on C++ compiler but I will throw my experience.

If you need something that will work and be reasonably productive, you can go for GCC/GDB. If you need an advanced debugger then MSVC is better for you than GCC/GDB.
I hear a lot about intel as being the best, but never tried.

I would further add that for windows, VC is said to produce small exe but for cross platform GCC is still better.

On IDEs I would vote for CodeLite. It is similar to C::B but have many usefull features and is simple to get started. I had a bad expericence with complexity of MS VS so I always hesitate to recommend to newbie.

HTH,
Stefano

Stefano Mtangoo 455 Senior Poster

Yes:

$date = '26.01.2012';
echo date("d\<\s\u\p\>S\<\/\s\u\p\> F Y",strtotime($date));

I've probably overdone the escaping, but it works.

That was easiest than my thought

Stefano Mtangoo 455 Senior Poster

easiest way would be tokenize the string and use the tokens. Somewhere you can have array of Months. Also a simple function to check whether to use st, nd, rd or th

Stefano Mtangoo 455 Senior Poster

Why is it bad the JS, it is working perfectly...

What about a browser with JS turned off?

Stefano Mtangoo 455 Senior Poster

to log out just unset variables you did set and destroy the session. I can see validation in JS, that is bad unless it there is of course another check in Server side.

Stefano Mtangoo 455 Senior Poster

Thank you it works.

But I would like to ask: I have read somewhere (I can't remember where anymore), that when session starts, it may set a cookie named SSID on client-side.

Is that true, and if it is , can it be used for such a thing?

I would advice you to stay away with internals of PHP.
That being said, I will quote Vikram's explanation found here:

Sessions work by associating every session with a session ID (a unique
identifier for the session) that is automatically generated by PHP. This session ID is
stored in two places: on the client using a temporary cookie, and on the server in a
flat file or a database. By using the session ID to put a name to every request received,
a developer can identify which client initiated which request, and track and maintain
client-specific information in session variables (variable-value pairs which remain alive
for the duration of the session and which can store textual or numeric information).

Stefano Mtangoo 455 Senior Poster
if(!isset$_SESSION['expiry']){
    $_SESSION['expiry']=time()+$time_to_expire;
}else{
    //if time have expired
    if( time()>$_SESSION['expiry']){
        //echo message and redirect to the page
        //unset variable
    }
}

*untested*

Stefano Mtangoo 455 Senior Poster

Thanks for your replies. I think I have found the solution to my problem.

If (entered_name) in page is equal as (name) in database && (email_entered) in page is equal as (email) in databse then show error message

else insert entered details in database.

Can I do that?

that is it! go ahead implement it and mark thread solved :)

Stefano Mtangoo 455 Senior Poster

first use code tags. also in your script you dont do error checking may be assuming script is perfect. Please test the code and print any error

<?php
/*Set to error level to development modes*/
ini_set("display_errors", 1);
error_reporting(E_ALL);
if ( isset($_POST['username'])) {
$ret = add_to_database();
if (!$ret) {
print "Error: Database error";
} else {
print "Thank you for submission";
}
} else {
write_form();
}

//functions
function write_form() {
$self =$_SERVER['PHP_SELF'];
echo <<<EOT
<form action="$self" method="POST">
<table>


<tr>
<td>User Name:</td>
<td><input type="text" name="username" /></td><br/>
</tr>
<tr>
<td>E-mail:</td>
<td><input type="text" name="useremail" /></td><br/>
</tr>
<tr>
<td>Comment:</td> <textarea cols="50" rows="8" wrap="VIRTUAL" name="comment"></textarea>
</tr>


<tr>
<td>&nbsp</td>
<td><input type="submit" /></td>
</tr>
</table>
</form>
EOT;
}

function add_to_database() {

$username = trim($_POST['username']);
$email = trim($_POST['useremail']);
$comments=trim($_POST['comment']);
mysql_connect("localhost","root","") or die("Couldn't connect to server");
mysql_select_db("comments");
check_user($username);
check_email($email);

$sql = "INSERT INTO dig_users (user_id, username, useremail,comment ) VALUES ('', '$username', '$email','$comment')";
echo $sql;
mysql_query($sql);
mysql_close();
return true;
}

//this will check whether there is user with same user name
function check_user($usr) {

$sql = "SELECT * FROM dig_users WHERE username='$usr'";
$result = mysql_query($sql);
if(!$result){
die("Function check_user failed: ".mysql_error());
}
$rows =mysql_num_rows($result);
if ($rows>0) {
print "The user $usr already exists. Please select another username.";
exit;
}
}
//checks that email is unique
function check_email($em) {


$sql = "SELECT * FROM dig_users WHERE useremail='$em'";

$result = mysql_query($sql);
if(!$result){
die("Function check_email failed: ".mysql_error());
}
 
$rows =mysql_num_rows($result);
#
if(is_resource($result))
{
if ($rows>0)
{
print "The e-mail address $em already exists. Please type another e-mail address.";
exit;
}


}
}
?>
Stefano Mtangoo 455 Senior Poster

Hi guys,

I finally managed to solve the issue. It was evstevem who gave me the clue of the notepad. Finally, i was able to change my file to .php from the .php.txt and it worked.

Thank you so much for all the support everyone.

I will be back with more queries since its just my first day of programming.

Thank you!!

Regards
Laya

Throw notepad, it is useless and stubborn when it comes to programming. Alternatively use something like NPP

Please mark thread solved!

Stefano Mtangoo 455 Senior Poster

suppose you have field in database called email and php form field named email then

$email = mysql_real_escape_string($_POST['email']);
$sql = "SELECT * FROM users_table WHERE email='$email'";
$res = mysql_query($sql)
if($res){
    if(mysql_num_rows($res)>0){
        //email found
    else{
        //email not found
    }
}else{
// nothing came from db perhaps errors or such
}
//code totally untested!
Stefano Mtangoo 455 Senior Poster

Hi

I recently installed XAMPP and tried my first test page by creating a sub-folder in htdocs namely password_test which containts 2 files: password.txt and an index.php.

While trying to execute i get the following: file:///C:/xampp/htdocs/password_test/

--------------
Index of C:\xampp\htdocs\password_test\
Name Size Date Modified
[parent directory]
index.php.txt 129 B 11/18/11 12:23:16 PM
password.txt.txt 13 B 11/18/11 11:55:39 AM

I am just able to see the code i typed on clicking the files but not the result. Can someone telling me if i am traveling the wrong way.

Awaiting your reply

Thank you
Laya

rename the file index.php.txt to index.php
BTW did you use notepad?

Stefano Mtangoo 455 Senior Poster

Change the relevant code to below and post error message here

$sql = "SELECT * FROM `dig_users` WHERE useremail='$em'";
$result = mysql_query($sql);
if(!$result)
die(mysql_error());
Stefano Mtangoo 455 Senior Poster

close the thread and never use REQUEST again ;)

Stefano Mtangoo 455 Senior Poster
isset($_POST['file'])

Anything with tag "<input type="file"" goes to $_FILES not $_POST

Stefano Mtangoo 455 Senior Poster

Hey Steve, I know :)

Tha problem is that with GET is working but with POST and REQUEST is not.

mesaje_furnizori.php?furnizor=53443&file=mesaje.png&mesajTrimis=adsdasd&trimis=ok

This is the weird part ...

If I have to help you have to remove that bad $_REQUEST and we can then troublshoot together. PHP should remove REQUEST alltogether!

Stefano Mtangoo 455 Senior Poster

Pls read my signature, I don't want to yell at you :)

Stefano Mtangoo 455 Senior Poster

Mh! What is exactly your question?

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

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

unset session then destroy it

unset($_SESSION);
session_destroy();
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

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

you could tune the codes to make it become safer, faster and generic
as your need, if there are bugs, please tell me, I will try my best to
fix it

size_t *remove_adjacent(size_t *first, size_t *last, std::vector<size_t> &result)
{
  if(first == last) return 0;

  size_t *next = first + 1;
  if(next == last) result.push_back(*first);
  while(next != last)
  {
    if(*first <= *next)
    {
      std::cout<<*first<<", "<<*next<<std::endl;

      result.push_back(*first);
      ++first; ++next;
      if(next == last)
      result.push_back(*first);
    }
    else if(*first > *next)
    {
      std::cout<<*first<<", "<<*next<<std::endl;
      result.push_back(*first);
      if(last - next > 1)
      {
        first += 2;
        next  += 2;
      }
      else
      {
        return last;
      }
    }
  }
}

void case_03()
{
  size_t A[] = { 1, 2, 3, 4, 2, 1, 6, 9 };
  std::vector<size_t> result;
  remove_adjacent(A, A + sizeof(A) / sizeof(*A), result);
  std::copy(result.begin(), result.end(), std::ostream_iterator<size_t>(std::cout, "\n") );
}

This is bad!!!!

Stefano Mtangoo 455 Senior Poster

.please solve my problem.

So what is your problem?

Stefano Mtangoo 455 Senior Poster

$encoded = base64_encode("<script> or <scripting>");
//work with $encoded

If it is client side then you need to encode using JS. See
http://stackoverflow.com/questions/246801/how-can-you-encode-to-base64-using-javascript

Stefano Mtangoo 455 Senior Poster

what exactly you want to encode? Following links there are examples

Stefano Mtangoo 455 Senior Poster

you can use PHP url encode or just encode/decode using base 64 encode

Stefano Mtangoo 455 Senior Poster
/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
*/
$config['global_xss_filtering'] = FALSE;

and

var_dump($this->config->item("global_xss_filtering"));
           exit;

result

bool(false)

When I put in a

<script> or <Scripting>

nothing shows! just blank...
Can you try and see if you have the same issue?

Thanks

Global might be off but you can specify it during sending. Please post your form code

Stefano Mtangoo 455 Senior Poster

global_xss_filtering is False… by default…

No solution found…

Anyone with the system and a form can u try submiting the word

<script>

or

<scripting>

and see if it gives you a blank page?

Thanks…

Tried in every form I have and it gives the same blank page… I thougth it could be my code… but every single form, thats just a bit too much…

Check again. That sounds to me XSS filtering is enabled. can you post your code?

Stefano Mtangoo 455 Senior Poster
else
(

is supposed to be

else
{

line 157

Stefano Mtangoo 455 Senior Poster

Are you sure XSS filtering is not enabled?

Stefano Mtangoo 455 Senior Poster

awesome. thank you. I'll look more into it tonight after work. see what I can do since this guy is using xampp and I am using wamp. not sure how big the differences are. Also, are you a Christian? Just curious. :)

Me in nutshell:A man that loves Jesus and explores science & technology
for anything else PM me!

Stefano Mtangoo 455 Senior Poster

wand I just realized that phpmyadmin won't let me in cause it said my username and password were incorrect. :(

Check the this

Stefano Mtangoo 455 Senior Poster

C:\wamp\WWW\dynamic maps to http://localhost/dynamic not http://localhost/dynamic website/welcome7.php. That is why bing redirects you. if Bing was not active you woulf get page not found

Stefano Mtangoo 455 Senior Poster

Here you go..
http://www.microsoft.com/web/platform/server.aspx
See, its free :D

Thanks!

Stefano Mtangoo 455 Senior Poster

I may have to go the route of a reinstall. I managed to get it to "work", but I have to go to http://localhost and then navigate to the file from that page. kinda annoying

what do you mean?

Stefano Mtangoo 455 Senior Poster

you can mark thread solved :)

Stefano Mtangoo 455 Senior Poster

@evstevemd: I'm not clear about it but I'm pretty sure I read somewhere in the Microsoft website that "IIS is free" although not available for download. And as per my observation it is free, you can just use add/remove components menu to add IIS. In windows 7, control panel>programs>turn on and off features and add it. I have a feeling that there might be some commercial addons but do tell if you know more regarding it.

Can you link me to article?

Stefano Mtangoo 455 Senior Poster

html pages can't display php unless you stipulate this in .htaccess. Change .html to .php and it should work (if your code is OK).

I just tested code blow and it didn't work!

<html>
<head> </head>
<body>
<?php echo "It works!"; ?>
</body>
<html>

adding this line in htaccess file worked:

AddType application/x-httpd-php .html .htm