[PHP] Weird while issue

2010-04-27 Thread Juan Rodriguez Monti
Hi guys,
I have some issues with while.

I have an HTML Form, that uses GET to process its contents. Then
there's a PHP Script that receives the data, and evaluates the fields.

So, in some instance of the code, I do something like :

if (empty($a) AND empty($b)) {

echo something;
echo something;
echo something;

while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {

And here I print some echo's to print an HTML's Table with the results
of the while.
echo Something more;
echo etc;

}
} elseif (empty($c) AND empty($d)) {

Here there is another elseif similar to the first one explained above.

}

I have four or five elseif's that analizes the fields of the HTML's
Form and then the PHP's Code do things depending of the combinations
of fields submited and so on.

The problem is that if I want to add an echo saying Come Back to
Index to index.html, I'm not able to show it after the while's
iteration.

The PHP code prints the table with its results taken from SQlite
perfectly. Also it evaluates all the conditions flawessly. However, If
I add a link to come back with the text Go to Index after the while
and before the } close to the next elseif, PHP prints it in the wrong
ubication.

I got something like:

TITLE

*** Go to Index ***

While results. This is the table containing all the results of the
SQlite's Query.

If I move the echo to other part of the block, I receive so many
echo's as iterations the while do ( this is logical ). However I don't
understand why the echo is printed above the while even when I put it
after the while and out of the while's block.

Thanks a lot!.

Juan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Weird while issue

2010-04-27 Thread Juan Rodriguez Monti
2010/4/27 Peter Lind peter.e.l...@gmail.com:
 On 27 April 2010 14:36, Juan Rodriguez Monti j...@rodriguezmonti.com.ar 
 wrote:
 Hi guys,
 I have some issues with while.

 I have an HTML Form, that uses GET to process its contents. Then
 there's a PHP Script that receives the data, and evaluates the fields.

 So, in some instance of the code, I do something like :

 if (empty($a) AND empty($b)) {

 echo something;
 echo something;
 echo something;

 while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {

 And here I print some echo's to print an HTML's Table with the results
 of the while.
 echo Something more;
 echo etc;

            }
 } elseif (empty($c) AND empty($d)) {

 Here there is another elseif similar to the first one explained above.

 }

 I have four or five elseif's that analizes the fields of the HTML's
 Form and then the PHP's Code do things depending of the combinations
 of fields submited and so on.

 The problem is that if I want to add an echo saying Come Back to
 Index to index.html, I'm not able to show it after the while's
 iteration.

 The PHP code prints the table with its results taken from SQlite
 perfectly. Also it evaluates all the conditions flawessly. However, If
 I add a link to come back with the text Go to Index after the while
 and before the } close to the next elseif, PHP prints it in the wrong
 ubication.

 I got something like:

 TITLE

 *** Go to Index ***

 While results. This is the table containing all the results of the
 SQlite's Query.

 If I move the echo to other part of the block, I receive so many
 echo's as iterations the while do ( this is logical ). However I don't
 understand why the echo is printed above the while even when I put it
 after the while and out of the while's block.


 Check your html for broken html table code.

 Regards
 Peter

Hi Peter,
That was the problem. Solved!.

Thanks,
Juan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
Hello Guys,
I would like to implement a two color row table for some queries that I'm doing.

I use PHP to query a DB, then I use while to print all its results. I
have a code pretty similar to this one :

 $results = Here the QUERY;
echo html;
echo head;
echo 'link rel=stylesheet type=text/css href=style.css /';
echo /head;
echo body;
echo 'div id=container';

echo centerh2Results/h2/centerbr /;
echo (table border='1');
echo tdstrongAt1/strong/td
tdstrongAt2/strong/td tdstrongAt3/strong/td  $

  while ($row = while condition )) {
echo (tr);
echo td$row[0]/tdtd$row[1]/td td$row[2]/td
td$row[3]/tdtd$row[4]/td ;
echo /div;
echo /body;
echo /html;

I just want to show you how I write the table. What I would like to
know is what do you suggest to do a two color row format.

Thanks!,
Juan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Jay Blanchard jblanch...@pocket.com:
 [snip]
 I just want to show you how I write the table. What I would like to
 know is what do you suggest to do a two color row format.
 [/snip]

 Before your table;

 $trColor = 0;

 Then during the loop;

 while(foo){
 $tr = (0 == $trColor % 2)? #E8E8E8 : #FF;
 echo tr style=\background-color:.$tr.\;
 ...

 Replace the hex values with the colors you desire.

Thank you all for the replies!, I wanted something like this. It was
very useful.

I agree that JS might be turned off , and isn't in all browsers.

Best,
Juan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Jay Blanchard jblanch...@pocket.com:
 [snip]
 Before your table;

 $trColor = 0;

 Then during the loop;

 while(foo){
 $tr = (0 == $trColor % 2)? #E8E8E8 : #FF;
 echo tr style=\background-color:.$tr.\;
 ...

 Replace the hex values with the colors you desire.

 Just one more question about this.

 I'm getting something like this[0], and I would like to get something
 like this[1] using something similar to Jay's suggestion.
 [/snip]

 My suggestion should produce the results you desire. Can you post your
 current code?

Yes!. Here is: http://pastebin.com/3vPfvssX

Juan.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Fernando ferna...@ggtours.ca:
 What about this:

 $color = even;
 while ($row = while condition )) {
       $color = ($color == even) ? odd : even;
       echo (tr class=\$color\);
       echo td$row[0]/tdtd$row[1]/td
  td$row[2]/tdtd$row[3]/tdtd$row[4]/td  ;
       echo (/tr)
 }

 And have two classes in your style sheet that format each row differently.

 Hope this helps.

Thanks to all guys!. Now it's working perfectly as I wanted.

Also was interesting to read the points you showed about JS and PHP.

Best,
Juan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-29 Thread Juan Rodriguez Monti
2010/4/29 tedd tedd.sperl...@gmail.com:
 At 8:29 AM -0300 4/28/10, Juan Rodriguez Monti wrote:

 Hello Guys,
 I would like to implement a two color row table for some queries that I'm
 doing.

 I use PHP to query a DB, then I use while to print all its results. I
 have a code pretty similar to this one :

  $results = Here the QUERY;
        echo html;
        echo head;
        echo 'link rel=stylesheet type=text/css href=style.css /';
        echo /head;
        echo body;
        echo 'div id=container';

        echo centerh2Results/h2/centerbr /;
        echo (table border='1');
        echo tdstrongAt1/strong/td
 tdstrongAt2/strong/td tdstrongAt3/strong/td      $

  while ($row = while condition )) {
        echo (tr);
        echo td$row[0]/tdtd$row[1]/td td$row[2]/td
 td$row[3]/tdtd$row[4]/td ;
        echo /div;
        echo /body;
        echo /html;

 I just want to show you how I write the table. What I would like to
 know is what do you suggest to do a two color row format.

 Thanks!,
 Juan


 Juan:

 Everyone has done this at one time or another -- this is my solution.

 http://webbytedd.com/b/color-rows/

 Plus, it validates and keeps things simple.

 Cheers,

 tedd

Tedd,
Thanks. I'm gonna check it. I finally solved it using:

if ( CONDITIONS )) {

  $results = query( QUERY );
 $colors = array('#97b7cd','#96bf8c');
 $index= 0; 
echo html;
echo head;
echo 'link rel=stylesheet type=text/css href=is.css /';
echo /head;
echo body;
echo 'div id=container';

echo table border='1';
echo tdstronga1/strong/td tdstronga2/strong/td
tdstronga3/strong/td tdstronga4/strong/td
tdstronga5/strong/td ;

  while ($row = CONDITIONS )) {
echo 'tr style=background-color: ' .  $colors[$index ++ %  2] .  
';';   
echo td$row[0]/tdtd$row[1]/td td$row[2]/td
td$row[3]/tdtd$row[4]/td ;
  }
echo /tr;
echo /table;
echo /div;
echo 'pa href=back.htmlback/a/p';
echo /body;
echo /html;

This solution was the best for me. It's solved with your help.

Thanks a lot!.

Juan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP Site with CSS and Internet Explorer

2010-05-15 Thread Juan Rodriguez Monti
I guys,
I'm having some problems with the following.

I have a PHP Site working perfectly with HTML and CSS. The CSS runs
flawlessly in Firefox and Google Chrome. However, I'm having some
problems with Internet Explorer.

I'm not able to show it centered ( the .css is to show centered
content ) in any version of Internet Explorer. The CSS's Code is
available here[0].

Might be this is an Off-Topic question, however is closely related to
my PHP development.

If you know some hack or modification that I should do to make this
site compatible with IE, I would appreciate it a lot.

Thanks,
Juan

[0] http://pastebin.com/eLhz2CzM

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Site with CSS and Internet Explorer

2010-05-17 Thread Juan Rodriguez Monti
2010/5/15 Jim Lucas li...@cmsws.com:
 Juan Rodriguez Monti wrote:

 I guys,
 I'm having some problems with the following.

 I have a PHP Site working perfectly with HTML and CSS. The CSS runs
 flawlessly in Firefox and Google Chrome. However, I'm having some
 problems with Internet Explorer.

 I'm not able to show it centered ( the .css is to show centered
 content ) in any version of Internet Explorer. The CSS's Code is
 available here[0].

 Might be this is an Off-Topic question, however is closely related to
 my PHP development.

 If you know some hack or modification that I should do to make this
 site compatible with IE, I would appreciate it a lot.

 Thanks,
 Juan

 [0] http://pastebin.com/eLhz2CzM



 Using your #container { ... } example.  the only change I would make is like
 this

 body
 {
        text-align: center;
 }

 #container
 {
        margin: 0 auto;
        width: 600px;
        background:#fff;
        text-align: left;
 }

Hi Jim,
Thanks. This CSS code solved the IE's problem.

Best,
Juan.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] User's IP Validation

2010-06-16 Thread Juan Rodriguez Monti
Hi people,
I would like to know the best way to perform some kind of validation
for an application that I've written.

I have a system that ask through an HTML Form some questions to users.
I use some cookies to save some information from the user side.

However, I would like to implement some code in PHP that would let me
limit to 1 the number of times that the page with the questions was
executed.

I mean, the user fills the HTML's Form, then send it through an HTML
Button, then PHP receives this informations and send an Email
containing the replies to the questions. I would like to limit to one,
the times one single user is able to execute this form.

I thought getting the IP Address, then doing some kind of validation
with it. However I don't know if using cookies is the best idea. I
don't have access to a DataBase for this. So I thought might be a good
idea write to a file in the server the IP, then perform some if to
know if the user already replied the form.

As far as I don't know which is the best way to code this, I felt free
to ask you guys.

Thanks a lot.

Juan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] User's IP Validation

2010-06-17 Thread Juan Rodriguez Monti
2010/6/16 Ashley Sheridan a...@ashleysheridan.co.uk

  On Wed, 2010-06-16 at 20:36 +0200, David Cesal wrote:

 Please, don't forget IP address can be same for many users. I see only way 
 with cookies. When user deletes cookies, form pops up again. I don't know any 
 better way.

 David

 Sent from my HTC

 -Original Message-
 From: Juan Rodriguez Monti j...@rodriguezmonti.com.ar
 Sent: 16. cervna 2010 20:26
 To: php-general@lists.php.net
 Subject: [PHP] User's IP Validation

 Hi people,
 I would like to know the best way to perform some kind of validation
 for an application that I've written.

 I have a system that ask through an HTML Form some questions to users.
 I use some cookies to save some information from the user side.

 However, I would like to implement some code in PHP that would let me
 limit to 1 the number of times that the page with the questions was
 executed.

 I mean, the user fills the HTML's Form, then send it through an HTML
 Button, then PHP receives this informations and send an Email
 containing the replies to the questions. I would like to limit to one,
 the times one single user is able to execute this form.

 I thought getting the IP Address, then doing some kind of validation
 with it. However I don't know if using cookies is the best idea. I
 don't have access to a DataBase for this. So I thought might be a good
 idea write to a file in the server the IP, then perform some if to
 know if the user already replied the form.

 As far as I don't know which is the best way to code this, I felt free
 to ask you guys.

 Thanks a lot.

 Juan

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




 Like others have said, unless you have specific user logins, there's no way
 to prevent people from viewing the form more than once. As you are emailing
 them the answers, I assume there is some form of login system being used, so
 you could use that, with some sort of flag to indicate the email has been
 sent. If you want to future-proof the system, you could use some sort of
 binary bit flag to indicate what forms they've been sent answers to, for
 example:

 0 - no answers have been sent
 1 - only the first set of answers
 4 - the 3rd set of answers only
 5 - the 3rd and 1st set of answers


Yes, tha't s true. However I'm not using a DB for this little job.

There's no login system. There's a little script that runs the form, and
then send an email to some directions, but not for the user's Email address.

I thought I should use cookies, however is far from secure.

Thanks a lot people!.

Juan


[PHP] Limit failed logins attempts

2010-08-09 Thread Juan Rodriguez Monti
Hi guys,
I would like to know what do you suggest to implement a limit for
failed login attempts.

I thought that might be a good idea, to define a session variable
called ( failedattempts ), then check and if $failedattempts is
greater than, suppose, 4 write to a Database ( ip, username and
last-time-attempt ). If ater that, the user/bot tries again to login
unsuccessfully, then the system should ban that user  ip combination.

Some questions about this situation:

- Do you think that is a good idea to use sleep() ?.
- How should I send a 503 HTTP error to the user after 5 attempts ?
- Is this a good idea to do all this work for this security purpose ?
- Do you know/suggest a better way to solve this?

Thanks in advance,
Juan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php