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

2009-01-26 Thread Carlos Medina

tedd schrieb:

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



Tedd:
Ok boss. Thank you. I will do.

--
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-26 Thread Paul M Foster
On Mon, Jan 26, 2009 at 12:03:20AM -0600, Micah Gersten wrote:

 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
 

Please show me how *without Javascript* and *only with PHP* you can
change the content on a page interactively as the user described
*without* reloading the whole page. Xajax contains Javascript, which is
how it manages this feat.

For Pete's sake people, this is a *new* PHP user who wanted a *simple*
solution to a relatively simple webpage problem. He's not looking for a
Javascript solution, or a framework solution, or an OOP solution. He's
not necessarily looking for a bulletproof, high security solution. He's
a *new* PHP user. He just wants to figure out how to do this simple
thing. Give him a *simple* answer. If you have to give him provisos
about security, OOP, or Javascript afterward, fine.

Paul

-- 
Paul M. Foster

-- 
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-26 Thread Bastien Koert
On Mon, Jan 26, 2009 at 9:25 AM, Paul M Foster pa...@quillandmouse.comwrote:

 On Mon, Jan 26, 2009 at 12:03:20AM -0600, Micah Gersten wrote:

  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
 

 Please show me how *without Javascript* and *only with PHP* you can
 change the content on a page interactively as the user described
 *without* reloading the whole page. Xajax contains Javascript, which is
 how it manages this feat.

 For Pete's sake people, this is a *new* PHP user who wanted a *simple*
 solution to a relatively simple webpage problem. He's not looking for a
 Javascript solution, or a framework solution, or an OOP solution. He's
 not necessarily looking for a bulletproof, high security solution. He's
 a *new* PHP user. He just wants to figure out how to do this simple
 thing. Give him a *simple* answer. If you have to give him provisos
 about security, OOP, or Javascript afterward, fine.

 Paul

 --
 Paul M. Foster

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


The only real way then to avoid a page refresh with just PHP / HTML (for the
links) would be to use (i)frames and load the new content into the frame

-- 

Bastien

Cat, the other other white meat


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

2009-01-26 Thread Jim Lucas
Bastien Koert wrote:
 On Mon, Jan 26, 2009 at 9:25 AM, Paul M Foster pa...@quillandmouse.comwrote:
 
 On Mon, Jan 26, 2009 at 12:03:20AM -0600, Micah Gersten wrote:

 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

 Please show me how *without Javascript* and *only with PHP* you can
 change the content on a page interactively as the user described
 *without* reloading the whole page. Xajax contains Javascript, which is
 how it manages this feat.

 For Pete's sake people, this is a *new* PHP user who wanted a *simple*
 solution to a relatively simple webpage problem. He's not looking for a
 Javascript solution, or a framework solution, or an OOP solution. He's
 not necessarily looking for a bulletproof, high security solution. He's
 a *new* PHP user. He just wants to figure out how to do this simple
 thing. Give him a *simple* answer. If you have to give him provisos
 about security, OOP, or Javascript afterward, fine.

 Paul

 --
 Paul M. Foster

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


 The only real way then to avoid a page refresh with just PHP / HTML (for the
 links) would be to use (i)frames and load the new content into the frame
 

Buy hey, that ability was here long before PHP was ever around, so that would 
not work either...  :P

-- 
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] New PHP User with a simple question

2009-01-26 Thread Micah Gersten
Paul M Foster wrote:
 On Mon, Jan 26, 2009 at 12:03:20AM -0600, Micah Gersten wrote:

   
 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

 

 Please show me how *without Javascript* and *only with PHP* you can
 change the content on a page interactively as the user described
 *without* reloading the whole page. Xajax contains Javascript, which is
 how it manages this feat.

 For Pete's sake people, this is a *new* PHP user who wanted a *simple*
 solution to a relatively simple webpage problem. He's not looking for a
 Javascript solution, or a framework solution, or an OOP solution. He's
 not necessarily looking for a bulletproof, high security solution. He's
 a *new* PHP user. He just wants to figure out how to do this simple
 thing. Give him a *simple* answer. If you have to give him provisos
 about security, OOP, or Javascript afterward, fine.

 Paul

   

I'm not saying that he should use it.  I'm saying that *YOUR *claim was
false.  You should watch what you say.  You said you *HAVE* to reload
which is not true.  I said nothing about without JavaScript.  I agree
that he shouldn't necessarily use that.  That's why I snipped his stuff
out and just quoted you.

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






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

2009-01-26 Thread Paul M Foster
On Mon, Jan 26, 2009 at 12:53:55PM -0600, Micah Gersten wrote:

 Paul M Foster wrote:

snip

 
  Please show me how *without Javascript* and *only with PHP* you can
  change the content on a page interactively as the user described
  *without* reloading the whole page. Xajax contains Javascript, which is
  how it manages this feat.
 
  For Pete's sake people, this is a *new* PHP user who wanted a *simple*
  solution to a relatively simple webpage problem. He's not looking for a
  Javascript solution, or a framework solution, or an OOP solution. He's
  not necessarily looking for a bulletproof, high security solution. He's
  a *new* PHP user. He just wants to figure out how to do this simple
  thing. Give him a *simple* answer. If you have to give him provisos
  about security, OOP, or Javascript afterward, fine.
 
  Paul
 
 
 
 I'm not saying that he should use it.  I'm saying that *YOUR *claim was
 false.  You should watch what you say.  You said you *HAVE* to reload
 which is not true.  I said nothing about without JavaScript.  I agree
 that he shouldn't necessarily use that.  That's why I snipped his stuff
 out and just quoted you.

Since he asked the question on a *PHP* list, I assumed he wanted a *PHP*
solution, not a Javascript one. I also assumed that the OP was not a
Javascript programmer, since as a Javascript programmer, the solution
should have been obvious in Javascript. Ergo, my statements were in the
context of a *PHP* solution to his question.

Moreover, his question indicated that he didn't understand some basic
fundamentals of the PHP execution model. Throwing a framework or
Javascript solution at him would have been like putting a 14 year old
behind the wheel of a Ferrari.

But fair warning to all list members and future newbies who post here:
If you ask for a solution on *this* list, and you give indications that
you're not familiar with how PHP works with HTTP and HTML, then I will
give you a PHP-based solution, and avoid Javascript, Java, C, Perl,
Python, Ruby, Ruby on Rails, .NET, C++, C#, ECMAScript, Algol, PL/1,
assembler, APL, Fortran, COBOL, frameworks and other assorted odds and
ends which *might* do what you want, but aren't what you asked for.

(Of course, I might give you a LISP/Scheme solution, though. ;-)


Paul
-- 
Paul M. Foster

-- 
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-26 Thread Christopher W
Kevin,

Your link, with some modifications to fit my site layout, worked just as I 
was hoping for.

Thank you very much.

-- 

Kevin Waterson ke...@phpro.org wrote in message 
news:20090126092451.7aab63ff.ke...@phpro.org...

  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-26 Thread Micah Gersten
Paul M Foster wrote:
 On Mon, Jan 26, 2009 at 12:53:55PM -0600, Micah Gersten wrote:

   
 Paul M Foster wrote:
 

 snip

   
 Please show me how *without Javascript* and *only with PHP* you can
 change the content on a page interactively as the user described
 *without* reloading the whole page. Xajax contains Javascript, which is
 how it manages this feat.

 For Pete's sake people, this is a *new* PHP user who wanted a *simple*
 solution to a relatively simple webpage problem. He's not looking for a
 Javascript solution, or a framework solution, or an OOP solution. He's
 not necessarily looking for a bulletproof, high security solution. He's
 a *new* PHP user. He just wants to figure out how to do this simple
 thing. Give him a *simple* answer. If you have to give him provisos
 about security, OOP, or Javascript afterward, fine.

 Paul


   
 I'm not saying that he should use it.  I'm saying that *YOUR *claim was
 false.  You should watch what you say.  You said you *HAVE* to reload
 which is not true.  I said nothing about without JavaScript.  I agree
 that he shouldn't necessarily use that.  That's why I snipped his stuff
 out and just quoted you.
 

 Since he asked the question on a *PHP* list, I assumed he wanted a *PHP*
 solution, not a Javascript one. I also assumed that the OP was not a
 Javascript programmer, since as a Javascript programmer, the solution
 should have been obvious in Javascript. Ergo, my statements were in the
 context of a *PHP* solution to his question.

 Moreover, his question indicated that he didn't understand some basic
 fundamentals of the PHP execution model. Throwing a framework or
 Javascript solution at him would have been like putting a 14 year old
 behind the wheel of a Ferrari.

 But fair warning to all list members and future newbies who post here:
 If you ask for a solution on *this* list, and you give indications that
 you're not familiar with how PHP works with HTTP and HTML, then I will
 give you a PHP-based solution, and avoid Javascript, Java, C, Perl,
 Python, Ruby, Ruby on Rails, .NET, C++, C#, ECMAScript, Algol, PL/1,
 assembler, APL, Fortran, COBOL, frameworks and other assorted odds and
 ends which *might* do what you want, but aren't what you asked for.

 (Of course, I might give you a LISP/Scheme solution, though. ;-)


 Paul
   
It's fine if you want to give a pure PHP solution, but please don't make
false statements when doing so.  Keep in mind that there are archives
and someone reading them might think something is impossible when it in
reality is very simple.

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



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



[PHP] New PHP User with a simple question

2009-01-24 Thread Christopher W
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.
-- 




-- 
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-24 Thread Michael Kubler

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 fairly simple but being 

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

2009-01-24 Thread Lars Torben Wilson
2009/1/24 Christopher W cwei...@adelphia.net:
 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.

Hi there,

A good way to increase your chance of getting a useful response is to
post the smallest example you can which clearly illustrates the
problem you're having. In this case, you say you're not able to get
this to work, but we could waste quite a bit of time trying to guess
what you've tried and what didn't work.

In the simplest case, you could make your menu items look something
like this: a href=target.html?page=homeHome/a and then use $page
= $_GET['page'] in your script, but I wouldn't recommend it since now
you have user data floating around in your script and it will later
become a pain in the butt to sanitize for security. For a learning
script it'll be fine though.


Torben

-- 
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-24 Thread Christopher W
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.

-- 

Lars Torben Wilson larstor...@gmail.com wrote in message 
news:36d4833b0901242313r435860b3q7f3f4f0eea621...@mail.gmail.com...
 2009/1/24 Christopher W cwei...@adelphia.net:
 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.

 Hi there,

 A good way to increase your chance of getting a useful response is to
 post the smallest example you can which clearly illustrates the
 problem you're having. In this case, you say you're not able to get
 this to work, but we could waste quite a bit of time trying to guess
 what you've tried and what didn't work.

 In the simplest case, you could make your menu items look something
 like this: a href=target.html?page=homeHome/a and then use $page
 = $_GET['page'] in your script, but I wouldn't recommend it since now
 you have user data floating around in your script and it will later
 become a pain in the butt to sanitize for security. For a learning
 script it'll be fine though.


 Torben 



-- 
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-24 Thread Christopher W
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.


-- 

Michael Kubler greyphoenixproducti...@gmail.com wrote in message 
news:497c0275.80...@gmail.com...
 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