Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Carlos Medina

Michael Kubler schrieb:
The easiest way would be to use GET parameters (i.e data in the actual 
URL).
There are a number of ways you can structure a HTML link to get what you 
want.

You can have something basic (but not very elegant looking), like
   a href=index.php?page=HomeHome/a

Then in your index.php code you'd probably have something like :

   ?php
   $page = urldecode(*$_GET['page']); *
   include_once header.inc; //Include a script that contains the
   general header information
   if(is_file(pages/*$page*.inc;)) //make sure they haven't requested a
   non-existant file
   {
   include_once pages/*$page*.inc; //Doesn't have to be .inc you
   could simply output HTML data if that's all your using.
   }
   else
   {
  include_once pages/Home.inc; //If the user wanted a file that
   doesn't exist, then just take them to the home page (or you could
   take them to an error page if that's what you want).
   }
   include_once footer.inc; //Which would contain the footer if you've
   got one.
   ?


This is approximately how I do it although sometimes have a functions 
file I call, or a config file with basic presets, and various other 
things. I use .inc (for inclusion) as the file extension, so I can 
easily differentiate between .php files that customers will use (such as 
index.php, admin.php, login.php, etc..), and the included files.


In the header file I usually have something like that below.

--- header.inc starts below this line ---

   !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
   html lang=en
   head

   title?php echo *$page*; ? - Insert Company or Website Name/title

   !-- Meta Tags --
   meta http-equiv=content-type content=application/xhtml+xml;
   charset=utf-8
   meta name=robots content=index, follow

   !-- CSS --
   link rel=stylesheet href=css/main.css
   media=screen,projection,tv,tty,handheld,embossed,braille,aural
   type=text/css
   link rel=stylesheet href=css/print.css media=print
   type=text/css
   /head
   body
   div id=header
   h1HEADER INFORMATION (or image) HERE/h1
   br /
   !-- end header div --
   /div
   div id=mainNav
   ?php
   *$main_navigation_list* = array(0 = array( 'name' = 'Home',
 
'url' = 'index.php?page=Contact',
  
'title' = 'The home page'),
  
1 = array('name' =

   'Contact' ,
 'url'
   = 'index.php?page=Contact',
   
'title' = 'The contact details')

   );
   ?
   ul id=main_nav_list
   ?php
   foreach(*$main_navigation_list* as *$index* = *$nav_list*)
   {
   echo 'lia href=' . *$nav_list*['url'] .' title=' .
   *$nav_list*['title'] . ''. *$nav_list*['name'] . '/a/li';
   }
   ?
   /ul
   /div
 !-- end mainNav div --
   /div

--- END header.inc --



In the header.inc I've manually created an array, then got PHP to go 
through the array to add the name, URL and other details from the array, 
but that's just to simplify this, usually I pull the navigation data 
from a database (or if there's no MySQL installed I might unserialise it 
from a file).


There are other ways of pulling the data. If you want nice URLs, you can 
have something like /pages/Home/ and then have a mod_rewrite rule in 
Apache to then change that into index.php?page=Home, (although you'll 
also need to change the a href to the new links. If you aren't running 
on apache, you can manually find the page information by doing 
print_r($_SERVER), and seeing what bits and pieces you can put together, 
but that's not nearly as good or reliable.


Sorry if there's too much info, but I'm guessing this is roughly what 
you'll be doing.
If you want to have more than one variable (like say a sub page) then 
you add  *amp;* between each variable. E.g


   a href=index.php?page=Homeamp;sub_page=more%20newsHome -
   Archived News/a

You can usually get away with just using ** as the separator but it 
probably won't validate properly if your making it in xhtml (as you 
should be). Also, if your not sure what the %20 means (a space) then 
look up urlencode http://au.php.net/manual/en/function.urlencode.php 
and urldecode http://au.php.net/url_decode.


Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



Christopher W wrote:

At least I hope it is simple...

I am trying to get an HTML menu link to set a variable's value.  For 
example, when a user clicks the Home button on my page it would 
cause $page = home; or clicking the About Us button will set 
$page=about_us; etc.


I think this should be 

Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Carlos Medina

Christopher W schrieb:

Mr. Kubler,

Thank you for the help.  I have to admit, I am still in over my head, I 
think.  Perhaps I should just stick to static pages...


Anyway what I was attempting to do, in the full picture, was be able to just 
switch the text in the text area without actually changing pages.  For 
example, if the user clicks About Us (from the home page)the page doesn't 
change, just the text (in the area I designated for text).


Since I have never used php before (but have read some online and in books)
what I was trying was:

if ($page == home) {echo $home_text;}
elseif ($page == about) {echo $about_text;}
...
else {echo $error_text;}

My problem is that I can't figure out how to get the link-click to assign 
the value to the variable.  I didn't try any php for that end because I 
really didn't know where to begin.  Perhaps I am just going about this the 
wrong way but from the extremely little I have learned about php, I thought 
that I could do it this way easily.


Thanks for the replies and the help.  I truly appreciate it.



Hi Christopher,
please buy a PHP Book. Read it and if you have any questions come back.

Regards

Carlos Medina

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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Ashley Sheridan
On Sun, 2009-01-25 at 10:51 +0100, Carlos Medina wrote:
 Michael Kubler schrieb:
  The easiest way would be to use GET parameters (i.e data in the actual 
  URL).
  There are a number of ways you can structure a HTML link to get what you 
  want.
  You can have something basic (but not very elegant looking), like
 a href=index.php?page=HomeHome/a
  
  Then in your index.php code you'd probably have something like :
  
 ?php
 $page = urldecode(*$_GET['page']); *
 include_once header.inc; //Include a script that contains the
 general header information
 if(is_file(pages/*$page*.inc;)) //make sure they haven't requested a
 non-existant file
 {
 include_once pages/*$page*.inc; //Doesn't have to be .inc you
 could simply output HTML data if that's all your using.
 }
 else
 {
include_once pages/Home.inc; //If the user wanted a file that
 doesn't exist, then just take them to the home page (or you could
 take them to an error page if that's what you want).
 }
 include_once footer.inc; //Which would contain the footer if you've
 got one.
 ?
  
  
  This is approximately how I do it although sometimes have a functions 
  file I call, or a config file with basic presets, and various other 
  things. I use .inc (for inclusion) as the file extension, so I can 
  easily differentiate between .php files that customers will use (such as 
  index.php, admin.php, login.php, etc..), and the included files.
  
  In the header file I usually have something like that below.
  
  --- header.inc starts below this line ---
  
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 html lang=en
 head
  
 title?php echo *$page*; ? - Insert Company or Website Name/title
  
 !-- Meta Tags --
 meta http-equiv=content-type content=application/xhtml+xml;
 charset=utf-8
 meta name=robots content=index, follow
  
 !-- CSS --
 link rel=stylesheet href=css/main.css
 media=screen,projection,tv,tty,handheld,embossed,braille,aural
 type=text/css
 link rel=stylesheet href=css/print.css media=print
 type=text/css
 /head
 body
 div id=header
 h1HEADER INFORMATION (or image) HERE/h1
 br /
 !-- end header div --
 /div
 div id=mainNav
 ?php
 *$main_navigation_list* = array(0 = array( 'name' = 'Home',
   
  'url' = 'index.php?page=Contact',

  'title' = 'The home page'),

  1 = array('name' =
 'Contact' ,
   'url'
 = 'index.php?page=Contact',
 
  'title' = 'The contact details')
 );
 ?
 ul id=main_nav_list
 ?php
 foreach(*$main_navigation_list* as *$index* = *$nav_list*)
 {
 echo 'lia href=' . *$nav_list*['url'] .' title=' .
 *$nav_list*['title'] . ''. *$nav_list*['name'] . '/a/li';
 }
 ?
 /ul
 /div
   !-- end mainNav div --
 /div
  
  --- END header.inc --
  
  
  
  In the header.inc I've manually created an array, then got PHP to go 
  through the array to add the name, URL and other details from the array, 
  but that's just to simplify this, usually I pull the navigation data 
  from a database (or if there's no MySQL installed I might unserialise it 
  from a file).
  
  There are other ways of pulling the data. If you want nice URLs, you can 
  have something like /pages/Home/ and then have a mod_rewrite rule in 
  Apache to then change that into index.php?page=Home, (although you'll 
  also need to change the a href to the new links. If you aren't running 
  on apache, you can manually find the page information by doing 
  print_r($_SERVER), and seeing what bits and pieces you can put together, 
  but that's not nearly as good or reliable.
  
  Sorry if there's too much info, but I'm guessing this is roughly what 
  you'll be doing.
  If you want to have more than one variable (like say a sub page) then 
  you add  *amp;* between each variable. E.g
  
 a href=index.php?page=Homeamp;sub_page=more%20newsHome -
 Archived News/a
  
  You can usually get away with just using ** as the separator but it 
  probably won't validate properly if your making it in xhtml (as you 
  should be). Also, if your not sure what the %20 means (a space) then 
  look up urlencode http://au.php.net/manual/en/function.urlencode.php 
  and urldecode http://au.php.net/url_decode.
  
  Michael Kubler
  *G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz
  
 

Re: [PHP] New PHP User with a simple question OT

2009-01-25 Thread Carlos Medina

Hi Ashley,
yes this is the right answer. The Problem is not a PHP Question but a 
programming question. To be clear: i think, the Problem can you solve, 
if you get two or tree books or tutorials about the programming 
language. You should *try* to solve the problem self and then to post a 
question in a list or forum. I think this is the normal way.


To the code i think this is very bad php code. You will get more XXS and 
other exploits with this code. Please tell me what is your site and i 
show you



Regards

Carlos Medina

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



[PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Stephen Alistoun

Hi all,

My captha code is working but the session code is not matching image
code(captha code).

How do i get them to match each other.


PHP CAPTHA
session_start(); 

$fontArray = array('arial.tff' , 'impact.tff' , 'tahoma.tff' , 
'tunga.tff'
, 'verdana.tff');

$fontOne = md5(rand(0,50));
$fontTwo = md5(rand(0,50));
$fontThree = md5(rand(0,50));
$fontFour = md5(rand(0,50));

//Let's generate a totally random string using md5
$md5_hashOne = md5(rand(0,999)); 
$md5_hashTwo = md5(rand(0,999)); 
$md5_hashThree = md5(rand(0,999)); 
$md5_hashFour = md5(rand(0,999)); 
//We don't need a 32 character long string so we trim it down to 5 
$wordOne = substr($md5_hashOne, 15, 1); 
$wordTwo = substr($md5_hashTwo, 15, 1);
$wordThree = substr($md5_hashThree, 15, 1);
$wordFour = substr($md5_hashFour, 15, 1);
//Set the image width and height
$width = 400;
$height = 150; 
//Create the image resource 
$image = @imagecreatefromjpeg(CapthaBack.jpg); 
$grey  = imagecolorallocate($image, 255, 255, 255);

imagettftext($image,20, rand(0,70), 30, 30, $grey , 'impact.ttf' ,
$wordOne);
imagettftext($image,20, rand(0,70), 70, 30, $grey , 'impact.ttf' ,
$wordTwo);
imagettftext($image,20, rand(0,70), 110, 30, $grey , 'impact.ttf' ,
$wordThree);
imagettftext($image,20, rand(0,70), 150, 30, $grey , 'impact.ttf' ,
$wordFour);

session_unset($_SESSION[security_code]);

$_SESSION[security_code] = $wordOne .  . $wordTwo .  . $wordThree 
.
 . $wordFour;

header(Content-Type: image/jpeg); 
//Output the newly created image in jpeg format 
ImageJpeg($image);
//Free up resources
ImageDestroy($image); 


HTML CODE
session_start(); 
table
tr

td/td
td 
colspan=2input type=text name=captha value=?php
echo Test:.$_SESSION[security_code] ?/td
/table

Thanks, 

Stephen
-- 
View this message in context: 
http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21650616.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Ashley Sheridan
On Sun, 2009-01-25 at 03:25 -0800, Stephen Alistoun wrote:
 Hi all,
 
 My captha code is working but the session code is not matching image
 code(captha code).
 
 How do i get them to match each other.
 
 
 PHP CAPTHA
 session_start(); 
   
   $fontArray = array('arial.tff' , 'impact.tff' , 'tahoma.tff' , 
 'tunga.tff'
 , 'verdana.tff');
   
   $fontOne = md5(rand(0,50));
   $fontTwo = md5(rand(0,50));
   $fontThree = md5(rand(0,50));
   $fontFour = md5(rand(0,50));
   
   //Let's generate a totally random string using md5
   $md5_hashOne = md5(rand(0,999)); 
   $md5_hashTwo = md5(rand(0,999)); 
   $md5_hashThree = md5(rand(0,999)); 
   $md5_hashFour = md5(rand(0,999)); 
   //We don't need a 32 character long string so we trim it down to 5 
   $wordOne = substr($md5_hashOne, 15, 1); 
   $wordTwo = substr($md5_hashTwo, 15, 1);
   $wordThree = substr($md5_hashThree, 15, 1);
   $wordFour = substr($md5_hashFour, 15, 1);
   //Set the image width and height
   $width = 400;
   $height = 150; 
   //Create the image resource 
   $image = @imagecreatefromjpeg(CapthaBack.jpg); 
   $grey  = imagecolorallocate($image, 255, 255, 255);
   
   imagettftext($image,20, rand(0,70), 30, 30, $grey , 'impact.ttf' ,
 $wordOne);
   imagettftext($image,20, rand(0,70), 70, 30, $grey , 'impact.ttf' ,
 $wordTwo);
   imagettftext($image,20, rand(0,70), 110, 30, $grey , 'impact.ttf' ,
 $wordThree);
   imagettftext($image,20, rand(0,70), 150, 30, $grey , 'impact.ttf' ,
 $wordFour);
   
   session_unset($_SESSION[security_code]);
   
   $_SESSION[security_code] = $wordOne .  . $wordTwo .  . $wordThree 
 .
  . $wordFour;
   
   header(Content-Type: image/jpeg); 
   //Output the newly created image in jpeg format 
   ImageJpeg($image);
   //Free up resources
   ImageDestroy($image); 
 
 
 HTML CODE
 session_start(); 
 table
 tr  
   
 td/td
   td 
 colspan=2input type=text name=captha value=?php
 echo Test:.$_SESSION[security_code] ?/td
 /table
 
 Thanks, 
 
 Stephen
 -- 
 View this message in context: 
 http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21650616.html
 Sent from the PHP - General mailing list archive at Nabble.com.
 
 
Is it possible the captcha image is being cached?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Stephen Alistoun

Hi ash,

Thanks for your reply but the image does change when i refresh the page but
the session value is one before the image value.

If this is a cache problem how would i prevent this?

Thanks, 

Stephen
-- 
View this message in context: 
http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21650839.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Richard Heyes
 ...

1. It's captcha, not captha - http://en.wikipedia.org/wiki/Captcha
2. As far as I can see (and that's not too far), you appear to be
sending HTML along
   with the image. You need to have one script to generate the page,
and another to
   create and send the captcha image.


-- 
Richard Heyes

HTML5 Graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.org (Updated January 17th)

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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Stephen Alistoun

Hey Richard,

Thanks for your reply but the Captcha php code is a seperate file to the
html code but the code is working but the values are not matching.

Thanks,

Stephen 

-- 
View this message in context: 
http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651034.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Re: process creation

2009-01-25 Thread Tom Sinclair
Per Jessen wrote:
 Török Alpár wrote:
 
 as i said it's hate here, and i might be wrong but consider the
 following  :

 for($icount=0;$icount11;$icount++)
 {
   $iPid  =  pcntl_fork();
   $iChildrenCount = 0;
   if ($iPid == 0)
   {
 // child
 echo (child $icount\n);
   }
   else
   {
 // parrent
   }
 }

 this is essential what you do in your example? If so, this code does
 not start 10 children. It starts more.
 
 Thats right - with the code above, each new child will continue creating
 more processes. To get exactly 10 children running the same code:
 
 if ($iPid == 0)
 {
// child
echo (child $icount\n);

// do childish stuff
// then exit
exit;
 }
 
 
 /Per Jessen, Zürich
 

for($icount=0;$icount11;$icount++)

Iterates 10 times??
Hmm

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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Ashley Sheridan
On Sun, 2009-01-25 at 04:09 -0800, Stephen Alistoun wrote:
 Hey Richard,
 
 Thanks for your reply but the Captcha php code is a seperate file to the
 html code but the code is working but the values are not matching.
 
 Thanks,
 
 Stephen 
 
 -- 
 View this message in context: 
 http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651034.html
 Sent from the PHP - General mailing list archive at Nabble.com.
 
 
Have you tried outputting what the image text is (and commenting out the
line that outputs the image) and comparing this directly with what is
going in your session. 


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Stephen Alistoun

Hey Ash,

Is I have but the Session Value is one before the Captha Image Value.

Regards,

Stephen
-- 
View this message in context: 
http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651258.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Re: process creation

2009-01-25 Thread Per Jessen
Tom Sinclair wrote:

 Per Jessen wrote:
 
 for($icount=0;$icount11;$icount++)
 
 Iterates 10 times??
 Hmm

10, 11 - no big difference is there?


/Per Jessen, Zürich


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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread tedd

At 4:33 AM -0800 1/25/09, Stephen Alistoun wrote:

Hey Ash,

Is I have but the Session Value is one before the Captha Image Value.

Regards,

Stephen



Stephen:

It's looks to me that your code is generating a CAPTCHA from a key, 
but your key is not being recorded in the SESSION as what is 
current.


I had the same problem, but solved it by making sure that the key 
that was used to generate the CAPTCHA was the same key that was 
expected to be entered by the user. It's just a logic problem you 
have to work out.


Here's some of what I did:

http://webbytedd.com/aa/assorted-captcha/

Cheers,

tedd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread tedd

At 2:29 AM -0500 1/25/09, Christopher W wrote:

My problem is that I can't figure out how to get the link-click to assign
the value to the variable.  I didn't try any php for that end because I
really didn't know where to begin.


It sounds to me like you're trying to create a smart menu. Perhaps 
this might help:


http://sperling.com/examples/smart-menu/

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Re: process creation

2009-01-25 Thread Michael Kubler

Hmm, are people getting confused between  and = ?
for($icount=0;$icount11;$icount++) (is less than 11)
for($icount=0;$icount=10;$icount++) (is less than or equal to 10)

Both iterate 10 times.

Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



Per Jessen wrote:

Tom Sinclair wrote:
  

Per Jessen wrote:

for($icount=0;$icount11;$icount++)
  

Iterates 10 times??
Hmm



10, 11 - no big difference is there?
/Per Jessen, Zürich


Re: [PHP] Re: process creation

2009-01-25 Thread Ashley Sheridan
On Mon, 2009-01-26 at 00:42 +1030, Michael Kubler wrote:
 Hmm, are people getting confused between  and = ?
 for($icount=0;$icount11;$icount++) (is less than 11)
 for($icount=0;$icount=10;$icount++) (is less than or equal to 10)
 
 Both iterate 10 times.
 
 Michael Kubler
 *G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz
 
 
 
 Per Jessen wrote:
  Tom Sinclair wrote:

  Per Jessen wrote:
 
  for($icount=0;$icount11;$icount++)

  Iterates 10 times??
  Hmm
  
 
  10, 11 - no big difference is there?
  /Per Jessen, Zürich
No, both iterate 11 times, because you start at 0.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] New PHP User with a simple question OT

2009-01-25 Thread tedd

At 11:56 AM +0100 1/25/09, Carlos Medina wrote:

Hi Ashley,
yes this is the right answer. The Problem is not a PHP Question 
but a programming question. To be clear: i think, the Problem can 
you solve, if you get two or tree books or tutorials about the 
programming language. You should *try* to solve the problem self and 
then to post a question in a list or forum. I think this is the 
normal way.


To the code i think this is very bad php code. You will get more XXS 
and other exploits with this code. Please tell me what is your site 
and i show you



Regards

Carlos Medina


Carlos:

Whoa dude -- this list IS for people to ask questions and from what 
the OP asked it WAS a php question.


I totally agree with Ashley and your response is not common for this list.

As to the OP's code being bad or whatever, he is asking for help. 
If you want to show him where his code is bad, then be my guest -- 
but to tell him to go buy a book and come back to this list after he 
has reads it is not something you can dictate -- you have no control 
over this list.


I suggest -- if you want to help, then do so. If not, then you go read a book.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] New PHP User with a simple question OT

2009-01-25 Thread Jason Pruim


On Jan 25, 2009, at 9:19 AM, tedd wrote:


At 11:56 AM +0100 1/25/09, Carlos Medina wrote:

Hi Ashley,
yes this is the right answer. The Problem is not a PHP Question  
but a programming question. To be clear: i think, the Problem can  
you solve, if you get two or tree books or tutorials about the  
programming language. You should *try* to solve the problem self  
and then to post a question in a list or forum. I think this is the  
normal way.


To the code i think this is very bad php code. You will get more  
XXS and other exploits with this code. Please tell me what is your  
site and i show you



Regards

Carlos Medina


Carlos:

Whoa dude -- this list IS for people to ask questions and from what  
the OP asked it WAS a php question.


I totally agree with Ashley and your response is not common for this  
list.


As to the OP's code being bad or whatever, he is asking for help.  
If you want to show him where his code is bad, then be my guest --  
but to tell him to go buy a book and come back to this list after he  
has reads it is not something you can dictate -- you have no control  
over this list.


I suggest -- if you want to help, then do so. If not, then you go  
read a book.


I agree completely with tedd here... If it wasn't for this list when I  
first started out... I would have given up... There was alot that  
didn't make sense and people on this list helped me get it sorted out.




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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Jason Pruim


On Jan 24, 2009, at 11:06 PM, Christopher W wrote:


At least I hope it is simple...

I am trying to get an HTML menu link to set a variable's value.  For
example, when a user clicks the Home button on my page it would  
cause
$page = home; or clicking the About Us button will set  
$page=about_us;

etc.

I think this should be fairly simple but being completely new to php  
I just

cannot seem to get it right.

Any help would be greatly appreciate.


Hi Christopher,

Here's a code sample of something that I use to change the page  
without reloading the entire thing... It is in the proces of  
developing into somewhat of a template system where the presentation  
info (The look of the site) is included in one file, and then when a  
link is clicked it loads in the actual content for that page.


Let me know if you have any questions about it.


?PHP
include(php.ini.php);
include(dbconnect.php);
include(defaults.php);
include(doctype.txt);
include(main.css);


$link = dbconnect($server, $username, $password, $database);
if(!isset($data)) {
$data = explode(/, $_SERVER['REQUEST_URI']);
}

// Used for grabbing which page to bring in to include
$url = basename($_SERVER['REQUEST_URI']);

$sql = SELECT * from raosetc_purl.schreur where  
url='{$data[1]}' AND subscribed='0';;
$row[] = mysql_query($sql) or die(Database Error:  
 .mysql_error());

$result = $row[0];

//Navigation must be below call to $data for it to function properly
include(nav.php);
while($row = mysql_fetch_assoc($result)){

echo HTML
body
div class=wrapper
div class=text
h1 class=white{$row['FName']}! It's great to see  
you!/h1



!--[if lte IE 7]

div style=position:relative; height: 105px; width:  
206px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
(src='HTTP://purl.raoset.com/media/SPC.logo.new.png',sizingMethod='scale') 
;/div

![endif]--

img class=logo src=HTTP://purl.raoset.com/media/SPC.logo.new.png 
 width=250px height=auto ALT=SPC

Logo
HTML;

switch($url) {
case design;
include(design.php);
//$purl = $data['1'];
break;

case print;
include(print.php);
break;

case mail;
include(mail.php);
break;

case purl;
include(purl.php);
break;

case test;
include(body.test.php);
break;
case thankyou;
include(thankyou.php);
break;
default;
include(body.php);
break;
}
   }

echo HTML
   /div!--End of text div --
/div!-- End of wrapper div --
/body
HTML;
?


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



Re: [PHP] Authentication by client certificate

2009-01-25 Thread Edmund Hertle
2009/1/23 Jesus Campos jesus...@cm-barcelos.pt

 Hi there,

 I would like to create a application that can be able to authenticate by
 client certificate.
 Can I make this by apache/php? Anyone can recomend me documantation?

 Thanks,
 JCampos
  http://www.php.net/unsub.php


Hey,

I do not really understand what do you want to do? Are you talking about
ssl-certificates?

-eddy


[PHP] Dirty Button

2009-01-25 Thread tedd

Hi gang:

I had a problem and solved it -- here's the write-up:

http://www.webbytedd.com/b/update-select/index.php

What do you think of the solution?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Dirty Button

2009-01-25 Thread tedd

Hi gang:

I had a problem and solved it -- here's the write-up:

http://www.webbytedd.com/b/update-select/index.php

What do you think of the solution?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Dirty Button

2009-01-25 Thread Robert Cummings
On Sun, 2009-01-25 at 12:55 -0500, tedd wrote:
 Hi gang:
 
 I had a problem and solved it -- here's the write-up:
 
 http://www.webbytedd.com/b/update-select/index.php
 
 What do you think of the solution?

Dirty button is all fine and dandy, but since you're using JavaScript to
update the button's CSS (or colour), then why not update the information
similarly so that the information is up to date?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Dirty Button

2009-01-25 Thread Edmund Hertle
2009/1/25 tedd t...@sperling.com

 Hi gang:

 I had a problem and solved it -- here's the write-up:

 http://www.webbytedd.com/b/update-select/index.php

 What do you think of the solution?

 Cheers,

 tedd
  http://www.php.net/unsub.php


Hey,

It does not work as described, because the button will also get red if I
just click the select field but does not chose anything different (using
firefox...)
You use Javascript? Then why not sending formular when somethings change...
I think this is quite common for select-fields

-eddy


Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Al



Stephen Alistoun wrote:

Hi all,

My captha code is working but the session code is not matching image
code(captha code).

How do i get them to match each other.


PHP CAPTHA
session_start(); 
	

$fontArray = array('arial.tff' , 'impact.tff' , 'tahoma.tff' , 
'tunga.tff'
, 'verdana.tff');

$fontOne = md5(rand(0,50));
$fontTwo = md5(rand(0,50));
$fontThree = md5(rand(0,50));
$fontFour = md5(rand(0,50));

//Let's generate a totally random string using md5
	$md5_hashOne = md5(rand(0,999)); 
	$md5_hashTwo = md5(rand(0,999)); 
	$md5_hashThree = md5(rand(0,999)); 
	$md5_hashFour = md5(rand(0,999)); 
	//We don't need a 32 character long string so we trim it down to 5 
	$wordOne = substr($md5_hashOne, 15, 1); 
	$wordTwo = substr($md5_hashTwo, 15, 1);

$wordThree = substr($md5_hashThree, 15, 1);
$wordFour = substr($md5_hashFour, 15, 1);
//Set the image width and height
$width = 400;
	$height = 150; 
	//Create the image resource 
	$image = @imagecreatefromjpeg(CapthaBack.jpg); 
	$grey  = imagecolorallocate($image, 255, 255, 255);


imagettftext($image,20, rand(0,70), 30, 30, $grey , 'impact.ttf' ,
$wordOne);
imagettftext($image,20, rand(0,70), 70, 30, $grey , 'impact.ttf' ,
$wordTwo);
imagettftext($image,20, rand(0,70), 110, 30, $grey , 'impact.ttf' ,
$wordThree);
imagettftext($image,20, rand(0,70), 150, 30, $grey , 'impact.ttf' ,
$wordFour);

session_unset($_SESSION[security_code]);

$_SESSION[security_code] = $wordOne .  . $wordTwo .  . $wordThree 
.
 . $wordFour;

	header(Content-Type: image/jpeg); 
	//Output the newly created image in jpeg format 
	ImageJpeg($image);

//Free up resources
	ImageDestroy($image); 



HTML CODE
session_start(); 
table

tr  

td/td
td colspan=2input 
type=text name=captha value=?php
echo Test:.$_SESSION[security_code] ?/td
/table

Thanks, 


Stephen


Pear has 3 very nice classes for generating and handling captchas.

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



Re: [PHP] Dirty Button

2009-01-25 Thread Nitsan Bin-Nun
Since you are using JS why not just update the content straight away?
(ajax/etc)

On Sun, Jan 25, 2009 at 7:55 PM, tedd tedd.sperl...@gmail.com wrote:

 Hi gang:

 I had a problem and solved it -- here's the write-up:

 http://www.webbytedd.com/b/update-select/index.php

 What do you think of the solution?

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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




Re: [PHP] Dirty Button

2009-01-25 Thread tedd

At 1:02 PM -0500 1/25/09, Robert Cummings wrote:

On Sun, 2009-01-25 at 12:55 -0500, tedd wrote:

 Hi gang:

 I had a problem and solved it -- here's the write-up:

 http://www.webbytedd.com/b/update-select/index.php

 What do you think of the solution?


Dirty button is all fine and dandy, but since you're using JavaScript to
update the button's CSS (or colour), then why not update the information
similarly so that the information is up to date?

Cheers,
Rob.


Rob:

This is one of the reasons why I like bouncing ideas off this group. 
I've changed values before in real-time by using javascript, as 
evidenced by this:


http://webbytedd.com/c/form-calc/

But somehow that didn't come to mind as I was trying to solve my 
Dirty-Button problem.


Thanks, I will change the values on the fly and make the 
Dirty-Button problem moot.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Dirty Button

2009-01-25 Thread Edmund Hertle
2009/1/25 tedd tedd.sperl...@gmail.com

 At 1:02 PM -0500 1/25/09, Robert Cummings wrote:

 On Sun, 2009-01-25 at 12:55 -0500, tedd wrote:

  Hi gang:

  I had a problem and solved it -- here's the write-up:

  http://www.webbytedd.com/b/update-select/index.php

  What do you think of the solution?


 Dirty button is all fine and dandy, but since you're using JavaScript to
 update the button's CSS (or colour), then why not update the information
 similarly so that the information is up to date?

 Cheers,
 Rob.


 Rob:

 This is one of the reasons why I like bouncing ideas off this group. I've
 changed values before in real-time by using javascript, as evidenced by
 this:

 http://webbytedd.com/c/form-calc/

 But somehow that didn't come to mind as I was trying to solve my
 Dirty-Button problem.

 Thanks, I will change the values on the fly and make the Dirty-Button
 problem moot.

 Cheers,

 tedd


Would be an interesting solution if you didn't used JavaScript (css +
:active attribute, but I think this is not well supported by all browsers)


Re: [PHP] Dirty Button

2009-01-25 Thread tedd

At 1:18 PM -0500 1/25/09, tedd wrote:

At 1:02 PM -0500 1/25/09, Robert Cummings wrote:

Dirty button is all fine and dandy, but since you're using JavaScript to
update the button's CSS (or colour), then why not update the information
similarly so that the information is up to date?

Cheers,
Rob.


Rob:

Now I remember why I didn't do that.

The demo I provided was a stripped down version of a problem I was 
trying to solve where the user's selection was tied to a trip to the 
server to pull data from a database.


The trip to the database should be done only after the user selects 
ALL the control values they are interested in.


True, I could use AJAX to trigger a php slave script to get the data 
from the dB and throw it back to the page in real time, but that 
might be premature depending upon what the user really wanted to do.


For example, if the user selected something from two, or more, 
selection controls but didn't want to see the results until they were 
finished thereby clicked the Submit button. Otherwise, it might 
annoy them to have the data change with every change in the selection 
controls. That's the problem I faced and thus the solution I came up 
with was the Dirty Button.


My madness makes sense to me now.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Dirty Button

2009-01-25 Thread Ashley Sheridan
On Sun, 2009-01-25 at 19:04 +0100, Edmund Hertle wrote:
 2009/1/25 tedd t...@sperling.com
 
  Hi gang:
 
  I had a problem and solved it -- here's the write-up:
 
  http://www.webbytedd.com/b/update-select/index.php
 
  What do you think of the solution?
 
  Cheers,
 
  tedd
   http://www.php.net/unsub.php
 
 
 Hey,
 
 It does not work as described, because the button will also get red if I
 just click the select field but does not chose anything different (using
 firefox...)
 You use Javascript? Then why not sending formular when somethings change...
 I think this is quite common for select-fields
 
 -eddy
Bad move to have it auto-send when the user selects something different,
especially if there is a lot of content on the page. Better to use AJAX
if it really needs updating, but just alerting users to the issue is
good.

Tedd, what about having it reset if you then go back and select the
original option without submitting, i.e. you originally selected and
submitted on A, then selected B, then selected A again?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Dirty Button

2009-01-25 Thread tedd

At 7:02 PM + 1/25/09, Ashley Sheridan wrote:

Tedd, what about having it reset if you then go back and select the
original option without submitting, i.e. you originally selected and
submitted on A, then selected B, then selected A again?


That's a good idea.

Now I just have to figure out how to make it all-encompassing enough 
to handle one, or more, selection-control and compare current values 
with the values that were previously selected.


Oh, the holes we dig for ourselves.  :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] best practice wrt multi-lingual websites, gettext() etc.

2009-01-25 Thread Per Jessen
I am writing a small(ish) site which will eventually need to be
available in several different languages.  This needs to more or less
transparent to the user, so I am using Apaches content negotiation
features, which is working very well. 
The issues arise once I start looking at PHP and Javascript code. I use
JS for client side input (pre-)validation and increased usability, and
error messages and such will obviously need to be language-sensitive.
The same goes for the PHP code. 

With PHP, I've got gettext() for this sort of job, with javascript and
some DHTML, I don't seem to have many options.

One of my key concerns is - for the translation, I need to be able to
wrap everything up and ship it off to a translator, perhaps via elance
or similar.  

Does anyone have any best practice suggestions or comments in general?


/Per Jessen, Zürich


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



[PHP] [HEADSUP] New Google Summer of Code Mailinglist

2009-01-25 Thread Hannes Magnusson
Hello all, and sorry for the massive cross-posting :)

As of now we have a list dedicated to Google Summer Of Code[1] discussions.
It is our hope that everyone who are interested in PHP and GSOC
subscribe[2] to the list and participate in the discussions, or just
lurk and follow the fun.

Among other things, the goal for the list is to have a one-entry-point
for anyone wanting follow the work of the (to-be) GSOC students
working for php.net.
Students will be required to CC this list their (weekly? bi-weekly?)
status reports.
If you are a student and looking for a interesting project to work on,
feel free to subscribe and introduce yourself.

Have an idea for a GSOC project? Want to share your GSOC story? Think
you have what it takes to be a mentor? Want to comment on how PHP+GSOC
has been handled the past years? Improvement suggestions?
Sign up and let us know!

-Hannes

[1] g...@lists.php.net  http://news.php.net/php.gsoc
[2] By sending an email to gsoc-subscr...@lists.php.net

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



[PHP] Multiple queries in PHP

2009-01-25 Thread Ashley Sheridan
Hi all,

I've run into a bit of a problem. I put together a query using mysql
variables in the form set @m:= 0; with the select that uses it directly
after. For any wondering, the select was using it as an incremental
value which can't be hard coded, as the value will depend on the
ordering of the results of the query itself.

The problem seems to be that while phpMyAdmin would execute this double
query perfectly well, php using mysql_query() was having problems, as
apparently it can't actually run multiple queries.

Now the full query looks something like this:


mysql_query(SELECT @m:=0;);

$query = SELECT * FROM(
SELECT profiles.id, ROUND(AVG(rated.score)) AS `rating`,
COUNT(rated.score) AS `total`, @m:=...@m+1 AS rank FROM `rated` LEFT JOIN
`profiles` ON (profiles.id = rated.profile_id) GROUP BY rated.profile_id
ORDER BY rating DESC, total DESC) AS ranking WHERE ranking.id=$id;
$result = mysql_query($query);


which seems to be working OK so far, but does anyone know of any
potential pitfalls I might face when doing something like this?

Thanks,


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Multiple queries in PHP

2009-01-25 Thread Stuart
2009/1/25 Ashley Sheridan a...@ashleysheridan.co.uk:
 I've run into a bit of a problem. I put together a query using mysql
 variables in the form set @m:= 0; with the select that uses it directly
 after. For any wondering, the select was using it as an incremental
 value which can't be hard coded, as the value will depend on the
 ordering of the results of the query itself.

 The problem seems to be that while phpMyAdmin would execute this double
 query perfectly well, php using mysql_query() was having problems, as
 apparently it can't actually run multiple queries.

 Now the full query looks something like this:


 mysql_query(SELECT @m:=0;);

 $query = SELECT * FROM(
SELECT profiles.id, ROUND(AVG(rated.score)) AS `rating`,
 COUNT(rated.score) AS `total`, @m:=...@m+1 AS rank FROM `rated` LEFT JOIN
 `profiles` ON (profiles.id = rated.profile_id) GROUP BY rated.profile_id
 ORDER BY rating DESC, total DESC) AS ranking WHERE ranking.id=$id;
 $result = mysql_query($query);


 which seems to be working OK so far, but does anyone know of any
 potential pitfalls I might face when doing something like this?

It's a security feature to prevent SQL injection. AFAIK you'll have no
problems so long as all calls to mysql_query happen on the same DB
connection so you might want to start using the linkid parameter.

-Stuart

-- 
http://stut.net/

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



[PHP] Re: Multiple queries in PHP

2009-01-25 Thread Shawn McKenzie
Ashley Sheridan wrote:
 Hi all,
 
 I've run into a bit of a problem. I put together a query using mysql
 variables in the form set @m:= 0; with the select that uses it directly
 after. For any wondering, the select was using it as an incremental
 value which can't be hard coded, as the value will depend on the
 ordering of the results of the query itself.
 
 The problem seems to be that while phpMyAdmin would execute this double
 query perfectly well, php using mysql_query() was having problems, as
 apparently it can't actually run multiple queries.
 
 Now the full query looks something like this:
 
 
 mysql_query(SELECT @m:=0;);
 
 $query = SELECT * FROM(
   SELECT profiles.id, ROUND(AVG(rated.score)) AS `rating`,
 COUNT(rated.score) AS `total`, @m:=...@m+1 AS rank FROM `rated` LEFT JOIN
 `profiles` ON (profiles.id = rated.profile_id) GROUP BY rated.profile_id
 ORDER BY rating DESC, total DESC) AS ranking WHERE ranking.id=$id;
 $result = mysql_query($query);
 
 
 which seems to be working OK so far, but does anyone know of any
 potential pitfalls I might face when doing something like this?
 
 Thanks,
 
 
 Ash
 www.ashleysheridan.co.uk
 

Might try the mysqli extension.  mysqli_multi_query()

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: Multiple queries in PHP

2009-01-25 Thread Ashley Sheridan
On Sun, 2009-01-25 at 15:07 -0600, Shawn McKenzie wrote:
 Ashley Sheridan wrote:
  Hi all,
  
  I've run into a bit of a problem. I put together a query using mysql
  variables in the form set @m:= 0; with the select that uses it directly
  after. For any wondering, the select was using it as an incremental
  value which can't be hard coded, as the value will depend on the
  ordering of the results of the query itself.
  
  The problem seems to be that while phpMyAdmin would execute this double
  query perfectly well, php using mysql_query() was having problems, as
  apparently it can't actually run multiple queries.
  
  Now the full query looks something like this:
  
  
  mysql_query(SELECT @m:=0;);
  
  $query = SELECT * FROM(
  SELECT profiles.id, ROUND(AVG(rated.score)) AS `rating`,
  COUNT(rated.score) AS `total`, @m:=...@m+1 AS rank FROM `rated` LEFT JOIN
  `profiles` ON (profiles.id = rated.profile_id) GROUP BY rated.profile_id
  ORDER BY rating DESC, total DESC) AS ranking WHERE ranking.id=$id;
  $result = mysql_query($query);
  
  
  which seems to be working OK so far, but does anyone know of any
  potential pitfalls I might face when doing something like this?
  
  Thanks,
  
  
  Ash
  www.ashleysheridan.co.uk
  
 
 Might try the mysqli extension.  mysqli_multi_query()
 
 -- 
 Thanks!
 -Shawn
 http://www.spidean.com
 
Unfortunately, I think the server this is going on to doesn't have that
extension :(


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Dirty Button

2009-01-25 Thread Robert Cummings
On Sun, 2009-01-25 at 13:49 -0500, tedd wrote:
 At 1:18 PM -0500 1/25/09, tedd wrote:
 At 1:02 PM -0500 1/25/09, Robert Cummings wrote:
 Dirty button is all fine and dandy, but since you're using JavaScript to
 update the button's CSS (or colour), then why not update the information
 similarly so that the information is up to date?
 
 Cheers,
 Rob.
 
 Rob:
 
 Now I remember why I didn't do that.
 
 The demo I provided was a stripped down version of a problem I was 
 trying to solve where the user's selection was tied to a trip to the 
 server to pull data from a database.
 
 The trip to the database should be done only after the user selects 
 ALL the control values they are interested in.
 
 True, I could use AJAX to trigger a php slave script to get the data 
 from the dB and throw it back to the page in real time, but that 
 might be premature depending upon what the user really wanted to do.
 
 For example, if the user selected something from two, or more, 
 selection controls but didn't want to see the results until they were 
 finished thereby clicked the Submit button. Otherwise, it might 
 annoy them to have the data change with every change in the selection 
 controls. That's the problem I faced and thus the solution I came up 
 with was the Dirty Button.
 
 My madness makes sense to me now.

Queue the ajax requests so that no more than one per 2 or 3 seconds
occurs (if change has occurred) so they are not so frequent, then also
perform an on-demand update when submit is hit.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Paul M Foster
On Sun, Jan 25, 2009 at 02:40:08AM -0500, Christopher W wrote:

 Mr. Kubler,
 
 Thank you for the help.  I have to admit, I am still in over my head, I
 think.  Perhaps I should just stick to static pages...
 
 Anyway what I was attempting to do, in the full picture, was be able to just
 switch the text in the text area without actually changing pages.  For
 example, if the user clicks About Us (from the home page)the page doesn't
 change, just the text (in the area I designated for text).
 
 Since I have never used php before (but have read some online and in books)
 what I was trying was:
 
 if ($page == home) {echo $home_text;}
 elseif ($page == about) {echo $about_text;}
 ...
 else {echo $error_text;}
 
 My problem is that I can't figure out how to get the link-click to assign
 the value to the variable.  I didn't try any php for that end because I
 really didn't know where to begin.  Perhaps I am just going about this the
 wrong way but from the extremely little I have learned about php, I thought
 that I could do it this way easily.
 
 Thanks for the replies and the help.  I truly appreciate it.
 

In case this has yet to be answered to your satisfaction...

Your page will *have* to reload when the user presses the button, but
the majority of content can look the same, except for the content you
want to change.

Let's say you've named the button section and its value is home as
in: 

input type=text name=section value=home/

When the user presses the button, the form now shows the value of
section as home. PHP knows this has occurred. So you can make any
action occur by simply (in PHP):

if ($_POST['section'] == 'home') {
do_something();
}

In your case, you want a section of your HTML page to display something
else. So, wherever you want that content to be displayed in your HTML
page, do this:

?php
if ($_POST['section'] == 'home') {
echo a bunch of text for home stuff;
}
?

The ?php thingie tells Apache to interpret the next part as PHP, and
the ? part tells Apache that the PHP part is over. If you're using
GET instead of POST for the form then change $_POST above to $_GET.
Every item in a form yields a POST or GET variable which PHP can read,
just as it did above.

There are alternate ways to do this, but the above is probably the
simplest for you.

I recommend Programming PHP an O'Reilly book as a reference for the
language.

Paul


-- 
Paul M. Foster

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



Re: [PHP] Dirty Button

2009-01-25 Thread Micah Gersten
tedd wrote:
 At 7:02 PM + 1/25/09, Ashley Sheridan wrote:
 Tedd, what about having it reset if you then go back and select the
 original option without submitting, i.e. you originally selected and
 submitted on A, then selected B, then selected A again?

 That's a good idea.

 Now I just have to figure out how to make it all-encompassing enough
 to handle one, or more, selection-control and compare current values
 with the values that were previously selected.

 Oh, the holes we dig for ourselves.  :-)

 Cheers,

 tedd

What about an onChange javascript function that checks all the boxes
that need input.  Call it whenever any of the inputs change and in the
onSubmit for the form, check it again.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Paul M Foster
On Sun, Jan 25, 2009 at 02:29:50AM -0500, Christopher W wrote:

 Sorry, I am also new to the etiquette of these mail lists.
 
 Anyway what I was attempting to do, in the full picture, was be able to just
 switch the text in the text area without actually changing pages.  For
 example, if the user clicks About Us (from the home page) the page doesn't
 change, just the text (in the area I designated for text).
 
 Since I have never used php before (but have read some online and in books)
 what I was trying was:
 
 if ($page == home) {echo $home_text;}
 elseif ($page == about) {echo $about_text;}
 ...
 else {echo $error_text;}
 
 My problem is that I can't figure out how to get the link-click to assign
 the value to the variable.  I didn't try any php for that end because I
 really didn't know where to begin.
 
 Thanks for the replies and the help.  I truly appreciate it.

The reply I gave you earlier assumes you're doing this with a button,
not a link. If you're doing it with a link, it's slightly different. But
here's what you have to understand first: When you click on a link, you
load a different (or the same) page. Period. Web pages run on the HTTP
protocol, and one of the things about that protocol is that the server
knows virtually nothing about the context in which it's loading a page.
In other words, if you were on Page A and you go to Page B, the HTTP
protocol ensures that the server has *almost* no idea of what you did on
that page. There are some exceptions, two of which are GET and POST
variables. If you did something on a form in the page you came from,
then GET/POST variable will be visible to the server (and PHP) when you
get to the next page. If the method on your form is post, as in:

form action=index.php method=post

then it will see POST variable. If you used the GET method instead, it
will see GET variables.

So if you want to communicate something to the next page you go to, you
will need to do it using a GET variable. GET variables are visible in
the navigation bar above your browser, and POST variables aren't.

So let's assume you want content.php to show home stuff if the user
was in index.php and pressed the home button. Then for the link the
push, you can do this:

a href=content.php?section=homeHome/a

Note the ?section=home part on the end of the URL? That's a GET
variable named section and it contains the contents home. When you
construct the content.php page. Put in a variant section as I
explained in the last email, except make sure it tests for the GET
variable section, like:

if ($_GET['section'] == 'home') ...

If you've programmed in other languages, PHP is a little difficult to
grasp, just because it has to deal with the HTTP protocol, and you're
embedding PHP in HTML pages. Otherwise its syntax is almost completely
C-like.

HTH,

Paul
-- 
Paul M. Foster

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



Re: [PHP] Dirty Button

2009-01-25 Thread tedd

At 3:41 PM -0600 1/25/09, Micah Gersten wrote:

tedd wrote:

 At 7:02 PM + 1/25/09, Ashley Sheridan wrote:

 Tedd, what about having it reset if you then go back and select the
 original option without submitting, i.e. you originally selected and
 submitted on A, then selected B, then selected A again?


 That's a good idea.

 Now I just have to figure out how to make it all-encompassing enough
 to handle one, or more, selection-control and compare current values
 with the values that were previously selected.

 Oh, the holes we dig for ourselves.  :-)

 Cheers,

 tedd


What about an onChange javascript function that checks all the boxes
that need input.  Call it whenever any of the inputs change and in the
onSubmit for the form, check it again.


I currently use onClick for the select control and that works well 
enough. It's not the trigger that's the issue.


If I decide to do that, then I have to loop through all the tag ID's, 
get the current values, and check them against what was presented. 
This just requires some thinking and I'm about all thought-out for 
the moment -- the end of another 12 hour day.


Thanks for your input.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Petar Dzhambazov
Hey guys sorry to interrupt but, the problem is rather obvious if you try 
and put the img src='captcha.php' / - which is the captcha image it self - 
anywhere in the script you are effectively overwriting the session 
variable - since you are initializing the form file session in the very 
beginning of the form file, and then calling the captcha file which over 
writes the session file, but that does not automatically update in the form 
file so there you get the old value. If you make the check if the text is 
correct after the submit of the form, it should be correct. I hope I have 
made myself clear enough.




Petar

Stephen Alistoun stephenalist...@gmail.com написа в съобщението 
news:21651258.p...@talk.nabble.com...


Hey Ash,

Is I have but the Session Value is one before the Captha Image Value.

Regards,

Stephen
--
View this message in context: 
http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651258.html

Sent from the PHP - General mailing list archive at Nabble.com.




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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Petar Dzhambazov
Hey guys sorry to interrupt but, the problem is rather obvious if you try 
and put the img src='captcha.php' / - which is the captcha image it self - 
anywhere in the script you are effectively overwriting the session 
variable - since you are initializing the form file session in the very 
beginning of the form file, and then calling the captcha file which over 
writes the session file, but that does not automatically update in the form 
file so there you get the old value. If you make the check if the text is 
correct after the submit of the form, it should be correct. I hope I have 
made myself clear enough.




Petar

Stephen Alistoun stephenalist...@gmail.com написа в съобщението 
news:21651258.p...@talk.nabble.com...


Hey Ash,

Is I have but the Session Value is one before the Captha Image Value.

Regards,

Stephen
--
View this message in context: 
http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651258.html

Sent from the PHP - General mailing list archive at Nabble.com.




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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Kevin Waterson
 
  Sorry, I am also new to the etiquette of these mail lists.

Hope this will get you started,

http://www.phpro.org/tutorials/Introduction-to-PHP-templating.html

Kevin

http://phpro.org


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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Jim Lucas

Christopher W wrote:

At least I hope it is simple...

I am trying to get an HTML menu link to set a variable's value.  For 
example, when a user clicks the Home button on my page it would cause 
$page = home; or clicking the About Us button will set $page=about_us; 
etc.


I think this should be fairly simple but being completely new to php I just 
cannot seem to get it right.


Any help would be greatly appreciate.

Thank you in advance.


Christopher,

Rather then criticizing you, I would like to point you in the direction that you describe in your 
responses to the others that are.


So, it sounds to me like you do not want to reload/change pages just to change the content of the 
current page.


With PHP alone you cannot load new content without reloading the entire page, or involving one of 
the other methods listed below.


I would say that you have two avenues to get this done.

The first using a meld of AJAX  PHP
http://nodstrum.com/2007/02/27/ajaxcontentload/
http://www.dhtmlgoodies.com/scripts/ajax-dynamic-articles/ajax-dynamic-articles.html
http://www.dhtmlgoodies.com/scripts/ajax-dynamic-content/ajax-dynamic-content.html

The second is with Javascript and/or CSS
http://www.devarticles.com/c/a/HTML/Preloading-HTML-Content-with-CSS/
http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

Hope these help.

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] best practice wrt multi-lingual websites, gettext() etc.

2009-01-25 Thread Phpster
Dunno if it's a best practice, but I store all the translations in the  
db for easy manipulation and extraction to a file for others to  
translate. That obviously involves both import and export utilities.


At work we to the translation in real time thru a render page that  
combined  the data for the form as well as the labels and buttons.  
Personally I disagree with this approach and feel that caching out the  
page to either HTML or XML is quicker and cleaner. But that's just me.


A number of pup apps take the approach of storing the label  
translations in variables inside language folders ( phpmyadmin has  
this ). That is also not a bad approach but is slightly slower and I  
can't help but feeling that serving up a static page created by code  
is a better solution. It will be heavier on the management side, but  
my experience is that this mgmt activity drops off quickly after the  
first week or two of that form being in production.


Nth

Bastien

Sent from my iPod

On Jan 25, 2009, at 14:56, Per Jessen p...@computer.org wrote:


I am writing a small(ish) site which will eventually need to be
available in several different languages.  This needs to more or less
transparent to the user, so I am using Apaches content negotiation
features, which is working very well.
The issues arise once I start looking at PHP and Javascript code. I  
use

JS for client side input (pre-)validation and increased usability, and
error messages and such will obviously need to be language-sensitive.
The same goes for the PHP code.

With PHP, I've got gettext() for this sort of job, with javascript and
some DHTML, I don't seem to have many options.

One of my key concerns is - for the translation, I need to be able to
wrap everything up and ship it off to a translator, perhaps via elance
or similar.

Does anyone have any best practice suggestions or comments in general?


/Per Jessen, Zürich


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



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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Richard Lynch
You may or may not find this worth reading:
http://richardlynch.blogspot.com/2007/07/php-in-html.html

Bottom line is that what you are trying to do can't be done in PHP.

You'll have to resort to Javascript and DIV tags with display: none;
switching to display: block;


-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Richard Lynch
Configure your browser to prompt you for cookies.

That will make sure you are doing the session bit the way you think
you are.

Then add some error_log statements when you set or read the secret word.

You'll soon figure out exactly how/why your session has the OLD secret
word in it.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] best practice wrt multi-lingual websites, gettext() etc.

2009-01-25 Thread Richard Lynch
I can't help with the bits you are asking about, but I can give this
advice:

Don't rely solely on the Apache/browser content-negotiation, please.

This one time...

I was in Paris.

I was at an Internet Cafe.

I couldn't change browser settings.

Some sites that I knew were available in English showed me only
French, and no way to change it.

Despite my using a computer with a French keyboard, my French language
skills remained somewhere around the Bonjour. Parlez-vous Englias?
level.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] Multiple queries in PHP

2009-01-25 Thread Richard Lynch
PHP/MySQL and the various functionality such as @var are all
per-connection expressly so that you CAN do this type of stuff.

I'd be pretty shocked if you had any problems.

-- 
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch



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



Re: [PHP] New PHP User with a simple question

2009-01-25 Thread Micah Gersten
Paul M Foster wrote:
 snip
 In case this has yet to be answered to your satisfaction...

 Your page will *have* to reload when the user presses the button, but
 the majority of content can look the same, except for the content you
 want to change.
 /snip
   

This is absolutely not true.   You can make the button call a PHP script
with AJAX and just update the textbox.
Check out:
http://xajaxproject.org

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


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



Re: [PHP] best practice wrt multi-lingual websites, gettext() etc.

2009-01-25 Thread Per Jessen
Richard Lynch wrote:

 I can't help with the bits you are asking about, but I can give this
 advice:
 
 Don't rely solely on the Apache/browser content-negotiation, please.
 

Don't worry, the site already has a user-override option. 


/Per Jessen, Zürich


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