Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] design questions and specifics


[SOLVED] design questions and specifics

Reply
  #1 (permalink)  
Old 03-06-08, 02:13 PM
FredSmith FredSmith is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] design questions and specifics

general q:
i am new to php and need some coding philosophy to follow. Is it better to have lots of little scripts that call each other, or one big script that uses a bunch of include files for smaller functions or is there something better yet? I am missing the general sense of how general coding should go.

specific q:
what does the "?" do in this segment:

echo"$_SERVER[PHP_SELF]?action=some_fn...
Reply With Quote
  #2 (permalink)  
Old 03-06-08, 03:28 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
It's best to make groups of useful functions that you will use again in one file, and include the file as needed. as for the ? in that code, it is there simply to make a link with the GET method
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #3 (permalink)  
Old 03-06-08, 03:51 PM
FredSmith FredSmith is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for that. Are hyperlinks more popular as navigation tools than using the html submit button? When should each be used?
Reply With Quote
  #4 (permalink)  
Old 03-06-08, 03:54 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Submit buttons for submitting data in forms, and hyperlinks for linking to other pages
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #5 (permalink)  
Old 03-06-08, 04:00 PM
FredSmith FredSmith is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
ok. let's see if I got it. use buttons when there is information to be sent, and use links when no info required?
Reply With Quote
  #6 (permalink)  
Old 03-06-08, 04:05 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Yes basically. If you want a user to submit information, you use submit buttons generally. the only real reason you would need to use hyperlinks with the ? is if you have a page with different options depending on a paramater, for example if your hyperlinks had the following values

page.php?p=1
page.php?p=2
page.php?p=3

depending on which of the three were clicked, your page called 'page.php' could determine which page to show, i.e. page 1, 2 or 3

Hope that clears it up

Jay
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #7 (permalink)  
Old 03-06-08, 04:16 PM
FredSmith FredSmith is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
ok, that makes sense.
thanks Jay.

1.) What is the best way to send great gobs of seemingly unrelated data to the next "page"? Arrays?
2.) javascript like: history.go(-1), which returns to the previous page, is this server-side? Is this only going to work if the client has java? or this part of php even though it's really java?

Fred
Reply With Quote
  #8 (permalink)  
Old 03-06-08, 04:23 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
1) If you dont want the data seen whatsoever by the user, you can store them in session variables. They are all server side, so none of it gets transferred to the client browser, but is remembered by the server for the whole of the users visit (as long as the session doesn't expire)

2) history.go(-1) is not server side, as it runs on the clients browser. therefore, client side. it has absolutely nothing to do with either the server or php, and will work without them

Jay
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #9 (permalink)  
Old 03-06-08, 04:33 PM
FredSmith FredSmith is offline
Newbie Coder
 
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
i appreciate your quick responses.

so, mouse over, blur and other similar javascripts must also be client side too? and actually depend on the user's browser's make, version and wheather they have java enabled?

what is recommended, use embedded javascript in php, or use a php solution?
Reply With Quote
  #10 (permalink)  
Old 03-06-08, 04:49 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, all javascript is client side. it is not on the server whatsoever. PHP is server side, therefore it is processed before it ever reaches the client. for example, if you have the php code

PHP Code:

<?php

echo "Example text";

?>
the server will take that script, parse it and insert the result where the <?php and ?> are between. if you look at the source code for your page it will only show Example text. No other part of the script is displayed or sent to the browser

for a more indepth explaination of what exactly happens serverside or client side, I suggest you look at the manuals for the different scripting languages
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:38 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.