Re: [PHP] Coding Web search engine in PHP
On 6 August 2012 19:54, Ansry User 01 yrsna.res...@gmail.com wrote: We are trying to code a very simple and customized search engine for internal purposes. Please suggest if the PHP is the way to go or suggest the alternatives?? It would be great if you can lead us to the links which would give us a start!! Thanks try solr. http://lucene.apache.org/solr/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Web search engine in PHP
On 06/08/12 15:24, Ansry User 01 wrote: We are trying to code a very simple and customized search engine for internal purposes. Please suggest if the PHP is the way to go or suggest the alternatives?? It would be great if you can lead us to the links which would give us a start!! Thanks This is a very vague question, it really depends. Some recommendations off the top of my head: http://lucene.apache.org/solr/ http://sphinxsearch.com/ Gibbs -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Web search engine in PHP
On Mon, Aug 6, 2012 at 8:24 PM, Ansry User 01 yrsna.res...@gmail.comwrote: We are trying to code a very simple and customized search engine for internal purposes. Please suggest if the PHP is the way to go or suggest the alternatives?? It would be great if you can lead us to the links which would give us a start!! Thanks Solr with Nutch will do it. One is search server and other is crawler. You need both. Google these terms you'll get to the right direction. -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] Coding Web search engine in PHP
On Aug 6, 2012 7:33 AM, shiplu shiplu@gmail.com wrote: Solr with Nutch will do it. Where *do* come up with those names :)
Re: [PHP] Coding Web search engine in PHP
Where *do* come up with those names :) Sorry I couldn't understand the meaning of your sentence. May be this is due to cultural difference. Anyway, Solr is a search engine. Nutch is a crawler. Both can be integrated. Then one can send query to solr server from php using api. See http://wiki.apache.org/solr/SolPHP -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] Coding Web search engine in PHP
On Mon, Aug 6, 2012 at 1:15 PM, shiplu shiplu@gmail.com wrote: Where *do* come up with those names :) Sorry I couldn't understand the meaning of your sentence. May be this is due to cultural difference. Anyway, Solr is a search engine. Nutch is a crawler. Both can be integrated. Then one can send query to solr server from php using api. See http://wiki.apache.org/solr/SolPHP She was just giggling about the silly-sounding names for high-quality products. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Web search engine in PHP
On Mon, Aug 6, 2012 at 11:22 PM, Daniel Brown danbr...@php.net wrote: On Mon, Aug 6, 2012 at 1:15 PM, shiplu shiplu@gmail.com wrote: Where *do* come up with those names :) Sorry I couldn't understand the meaning of your sentence. May be this is due to cultural difference. Anyway, Solr is a search engine. Nutch is a crawler. Both can be integrated. Then one can send query to solr server from php using api. See http://wiki.apache.org/solr/SolPHP She was just giggling about the silly-sounding names for high-quality products. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ Thanks Daniel for clearing. I am pretty bad in English. :( -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] Coding Web search engine in PHP
On Mon, Aug 6, 2012 at 1:42 PM, shiplu shiplu@gmail.com wrote: Thanks Daniel for clearing. I am pretty bad in English. :( Don't sell yourself short. Your English seems fine to me --- better than many native-speakers. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to write a PHP coding to list out all files and directories aslinks to them?
On 4/14/2011 6:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ OK, maybe not the most elegant ... but it works for my purposes ... and it was my first attempt at these directory functions. You can navigate up and down the directory hierarchy. It flags files older than 1 year for potential cleanup. Hope it gives you some ideas and a place to start... Mitch #! /usr/bin/php4 html head titleDiskspace Analyzer/title ?php foreach ($_REQUEST as $key=$value){ $$key = $value; } ? /head body form name=form1 method=POST action=?php $PHP_SELF ? p align=centerfont color=#FF size=+2Enter Directory Name Here/font/p p align=center input name=dName type=text id=dName value=?php $dName ? size=50 maxlength=256 input type=submit name=Submit value=Submit /p /form br ?php if (isset($dName) is_dir($dName)){ print(hr\n); print(font size=\+2\strong$dName Directory Information/strong/fontbrnbsp;\n); print(font color=\yellow\strongHighlighted/strong/font files are older than 1 year and candidates for cleanupbrnbsp;\n); print(table border=\1\ bordercolor=\gray\ cellspacing=\0\ cellpadding=\5\\n); print(th bgcolor=\black\font color=\white\File Name/font/thth bgcolor=\black\font color=\white\File Size/font/thth bgcolor=\black\font color=\white\File Date/font/th\n); $d = @dir(trim($dName)); while ($entry = @$d-read()){ $total++; $fileExt = explode(., $entry); if(is_dir($d-path . / . $entry)){ if($fileExt[0] ==){ $fileExt[1] = SysDirectories; } else { $fileExt[1] = Directories; } $dirSize = filesize($d-path . / . $entry); $totaldirSize += $dirSize; $dirList[$entry] = $dirSize; } else { $fileExt[1] = Files; $fileStats = @stat($d-path . / . $entry); $fileSize = $fileStats[7]; $totalSize += $fileSize; $currDate = getdate(); $fdDay = date(z, $fileStats[10]); $fdYear = date(Y, $fileStats[10]); $ckDay = $currDate[yday]; $ckYear = ($currDate[year] - 1); if (($fdYear $ckYear) || (($fdYear == $ckYear) ($fdDay = $ckDay))){ $highlight = yellow; $totalSavings += $fileStats[7]; } else { $highlight = white; } print(\ttr\n); print(\t\ttd bgcolor=\$highlight\$entry/tdtd bgcolor=\$highlight\ align=\right\$fileSize/tdtd align=\right\ bgcolor=\$highlight\); printf(%s, date(m/d/Y, $fileStats[10])); print(/td\n); print(\t/tr\n); } $fileTypes[$fileExt[1]]++; } print(\ttr\n); print(\t\ttd bgcolor=\gray\strongTotal Bytes in Files/strong/tdtd align=\right\ bgcolor=\gray\strong$totalSize/strong/tdtd align=\right\ bgcolor=\gray\); if ($totalSavings 0){ print(strongPotential Savings: $totalSavings/strong); } print(/td\n); print(\t/tr\n); print(/tablebrnbsp;\n); if(count($dirList) 1){ ksort($dirList); print(table border=\1\ bordercolor=\gray\ cellspacing=\0\ cellpadding=\5\\n); print(th bgcolor=\black\font color=\white\Directories/font/th\n); foreach ($dirList as $key=$value){ print(\ttr\n); if ($key == .){ print(\t\ttd$key nbsp;(Current)/td\n); } elseif ($key == ..){ $truncPoint = strrpos($dName, /); $parentDir = substr($dName, 0, $truncPoint); if ($parentDir == ){ $parentDir = /; } print(\t\ttda href=\ . $PHP_SELF . ?dName= . $parentDir . Submit=Submit\$key/a (Parent)/td\n); } else { print(\t\ttda href
[PHP] Re: How to write a PHP coding to list out all files and directories aslinks to them?
On 04/14/2011 06:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ I prefer glob(). Give it a shot and ask for help on code that you have tried. -- 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: How to write a PHP coding to list out all files and directories aslinks to them?
On Sat, 2011-04-16 at 15:02 -0500, Shawn McKenzie wrote: On 04/14/2011 06:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ I prefer glob(). Give it a shot and ask for help on code that you have tried. -- Thanks! -Shawn http://www.spidean.com There is a setting of Apache that will do this automatically for directories that have no index, I don't remember exactly what it is right now, but a quick Google should yield results -- Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] How to write a PHP coding to list out all files and directories as links to them?
How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/
[PHP] Re: How to write a PHP coding to list out all files and directories as links to them?
Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ Start with http://php.net/manual/en/function.opendir.php for a basic method. Alternatively you can use the SPL DirectoryIterator class http://php.net/manual/en/class.directoryiterator.php http://php.net is your first resource for php Cheers -- David Robley Hm..what's this red button fo:=/07NO CARRIER Today is Setting Orange, the 32nd day of Discord in the YOLD 3177. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
2009/1/30 Tom obeli...@comcast.net Shawn McKenzie nos...@mckenzies.net wrote in message news:47.36.08436.e8b80...@pb1.pair.com... Tom wrote: Clancy clanc...@cybec.com.au wrote in message news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com... On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net (Tom) wrote: .. Also make sure there aren't line returns or any nonsense like that in the to subjects. Look up email header injection. Your script might become quite popular at advertising p3n1s pills otherwise. :) Thanks I'll check it out. I tried including the above code but I still can't seem to get it to work. Must be missing something. Thanks, David Powers books PHP for Dreamweaver xxx (Friends of Ed) give very clear instructions on installing PHP and implementing the essential items such as this. Thanks I'll check it out. I am no Coder and don't have a lot of time to devote to these things, to busy running a business, but I do enjoy learning how things work which is why I have taken this on. Website is just for informational display as they don't produce much in the way of mortgage originations. I was hoping to get something along the lines of the actually coding needed to pull this off. I have spent every available moment over the last three months on this website (which is my first) with nothing more than an online beginners course in CS3 CSS. I have appreciated everyones feedbackl. If anyone has coding I can cut and paste with just a few adjustments on my end that would be great. Thanks, Tom You have the code. You just need to create a contact.php file and put the email specific PHP in it and then modify your form to have method=post action=contact.php. -- Thanks! -Shawn http://www.spidean.com The following link shows my PHP configurations. http://www.richlandmtg.com/test.php Are there any that should be set differently? I noticed the system is Linux. You should never let a php_info() file be accesibly to the public! Security concerns! And your problem has nothing to do with your php configuration or if your server is linux or windows or...
Re: [PHP] Coding for email response forms
Shawn McKenzie nos...@mckenzies.net wrote in message news:47.36.08436.e8b80...@pb1.pair.com... Tom wrote: Clancy clanc...@cybec.com.au wrote in message news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com... On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net (Tom) wrote: .. Also make sure there aren't line returns or any nonsense like that in the to subjects. Look up email header injection. Your script might become quite popular at advertising p3n1s pills otherwise. :) Thanks I'll check it out. I tried including the above code but I still can't seem to get it to work. Must be missing something. Thanks, David Powers books PHP for Dreamweaver xxx (Friends of Ed) give very clear instructions on installing PHP and implementing the essential items such as this. Thanks I'll check it out. I am no Coder and don't have a lot of time to devote to these things, to busy running a business, but I do enjoy learning how things work which is why I have taken this on. Website is just for informational display as they don't produce much in the way of mortgage originations. I was hoping to get something along the lines of the actually coding needed to pull this off. I have spent every available moment over the last three months on this website (which is my first) with nothing more than an online beginners course in CS3 CSS. I have appreciated everyones feedbackl. If anyone has coding I can cut and paste with just a few adjustments on my end that would be great. Thanks, Tom You have the code. You just need to create a contact.php file and put the email specific PHP in it and then modify your form to have method=post action=contact.php. -- Thanks! -Shawn http://www.spidean.com The following link shows my PHP configurations. http://www.richlandmtg.com/test.php Are there any that should be set differently? I noticed the system is Linux. T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Clancy clanc...@cybec.com.au wrote in message news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com... On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net (Tom) wrote: .. Also make sure there aren't line returns or any nonsense like that in the to subjects. Look up email header injection. Your script might become quite popular at advertising p3n1s pills otherwise. :) Thanks I'll check it out. I tried including the above code but I still can't seem to get it to work. Must be missing something. Thanks, David Powers books PHP for Dreamweaver xxx (Friends of Ed) give very clear instructions on installing PHP and implementing the essential items such as this. Thanks I'll check it out. I am no Coder and don't have a lot of time to devote to these things, to busy running a business, but I do enjoy learning how things work which is why I have taken this on. Website is just for informational display as they don't produce much in the way of mortgage originations. I was hoping to get something along the lines of the actually coding needed to pull this off. I have spent every available moment over the last three months on this website (which is my first) with nothing more than an online beginners course in CS3 CSS. I have appreciated everyones feedbackl. If anyone has coding I can cut and paste with just a few adjustments on my end that would be great. Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Tom wrote: Clancy clanc...@cybec.com.au wrote in message news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com... On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net (Tom) wrote: .. Also make sure there aren't line returns or any nonsense like that in the to subjects. Look up email header injection. Your script might become quite popular at advertising p3n1s pills otherwise. :) Thanks I'll check it out. I tried including the above code but I still can't seem to get it to work. Must be missing something. Thanks, David Powers books PHP for Dreamweaver xxx (Friends of Ed) give very clear instructions on installing PHP and implementing the essential items such as this. Thanks I'll check it out. I am no Coder and don't have a lot of time to devote to these things, to busy running a business, but I do enjoy learning how things work which is why I have taken this on. Website is just for informational display as they don't produce much in the way of mortgage originations. I was hoping to get something along the lines of the actually coding needed to pull this off. I have spent every available moment over the last three months on this website (which is my first) with nothing more than an online beginners course in CS3 CSS. I have appreciated everyones feedbackl. If anyone has coding I can cut and paste with just a few adjustments on my end that would be great. Thanks, Tom You have the code. You just need to create a contact.php file and put the email specific PHP in it and then modify your form to have method=post action=contact.php. -- 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] Coding for email response forms
Edmund Hertle edmund.her...@student.kit.edu wrote in message news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com... 2009/1/26 Tom obeli...@comcast.net Shawn McKenzie sh...@mckenzies.net wrote in message news:497e3ab9.2060...@mckenzies.net... Shawn McKenzie wrote: Tom Scott wrote: - Original Message - From: Shawn McKenzie nos...@mckenzies.net Newsgroups: php.general To: php-general@lists.php.net Sent: Monday, January 26, 2009 3:52 PM Subject: Re: [PHP] Coding for email response forms Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com. .. On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } -- Thanks! -Shawn http://www.spidean.com Ok. I have the validation part. http://www.richlandmtg.com/index-5.html still working on the Send button. T Please reply all so this stays on the list. 1. In the source for your link I see that the JS is doing some validation. 2. You have method=get in your form. This will work, but you'll have to change the PHP code to use $_GET instead of $_POST vars. Or change to method=post in the form. 3. If you want to keep the .html extension for the page, then you'll probably need to send the post to another script with a .php extension. Normally a file with a .html extension won't execute the PHP code. Thanks! -Shawn I was just looking at that. Someone told me to use GET instead of POST. Since JS is validating is it as easy replacing GET with POST ? Nothing else needed? Is it better to remove the JS and just code using PHP as you showed before? if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) Thanks, Tom Yes, I think it is better to just use PHP code and post is the better method (in this case) because with get all your fields and values will show up in the url -eddy I don't seem to be getting he hang of this. Sounds so simple but Can someone check this out and tell me where exactly I'm messing up? http://www.richlandmtg.com/Contact_Us.html I removed the JS validation. Is the following code ok? a href=# onClick=document.getElementById('form').reset()clear/aimg alt= src=images/ch_more_red.gif style=margin:1px 0 0 3px; vertical-align:text-bottom/bb style=margin-left:17px;a href=# onClick=document.getElementById('form').submit()send/a I posted the PHP info at the top of the page before the html tag. Should it be after html? Sorry please bear with me, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Coding for email response forms
-Original Message- From: Tom [mailto:obeli...@comcast.net] Sent: Tuesday, January 27, 2009 9:58 AM To: php-general@lists.php.net Subject: Re: [PHP] Coding for email response forms Edmund Hertle edmund.her...@student.kit.edu wrote in message news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com... 2009/1/26 Tom obeli...@comcast.net Shawn McKenzie sh...@mckenzies.net wrote in message news:497e3ab9.2060...@mckenzies.net... Shawn McKenzie wrote: Tom Scott wrote: - Original Message - From: Shawn McKenzie nos...@mckenzies.net Newsgroups: php.general To: php-general@lists.php.net Sent: Monday, January 26, 2009 3:52 PM Subject: Re: [PHP] Coding for email response forms Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com. .. On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } Ok. I have the validation part. http://www.richlandmtg.com/index-5.html still working on the Send button. Please reply all so this stays on the list. 1. In the source for your link I see that the JS is doing some validation. 2. You have method=get in your form. This will work, but you'll have to change the PHP code to use $_GET instead of $_POST vars. Or change to method=post in the form. 3. If you want to keep the .html extension for the page, then you'll probably need to send the post to another script with a .php extension. Normally a file with a .html extension won't execute the PHP code. I was just looking at that. Someone told me to use GET instead of POST. Since JS is validating is it as easy replacing GET with POST ? Nothing else needed? Is it better to remove the JS and just code using PHP as you showed before? if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) Yes, I think it is better to just use PHP code and post is the better method (in this case) because with get all your fields and values will show up in the url I don't seem to be getting he hang of this. Sounds so simple but Can someone check this out and tell me where exactly I'm messing up? http://www.richlandmtg.com/Contact_Us.html I removed the JS validation. Is the following code ok? a href=# onClick=document.getElementById('form').reset()clear/aimg alt= src=images/ch_more_red.gif style=margin:1px 0 0 3px; vertical-align:text-bottom/bb style=margin-left:17px;a href=# onClick=document.getElementById('form').submit()send/a I posted the PHP info at the top of the page before the html tag. Should it be after html? Tom, I don't think you're getting it... by the time the form is displayed on the user's browser, PHP has wiped its hands clean of the whole ordeal. PHP is used on the server ONLY. Javascript is used on the client ONLY. PHP can take an HTTP request (when the browser REQUESTs a URL) and then perform certain actions based on any number of conditions
Re: [PHP] Coding for email response forms
Tom wrote: Edmund Hertle edmund.her...@student.kit.edu wrote in message news:f7ed91b20901261644y125f71aer3e0b70735c949...@mail.gmail.com... 2009/1/26 Tom obeli...@comcast.net Shawn McKenzie sh...@mckenzies.net wrote in message news:497e3ab9.2060...@mckenzies.net... Shawn McKenzie wrote: Tom Scott wrote: - Original Message - From: Shawn McKenzie nos...@mckenzies.net Newsgroups: php.general To: php-general@lists.php.net Sent: Monday, January 26, 2009 3:52 PM Subject: Re: [PHP] Coding for email response forms Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com. .. On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } -- Thanks! -Shawn http://www.spidean.com Ok. I have the validation part. http://www.richlandmtg.com/index-5.html still working on the Send button. T Please reply all so this stays on the list. 1. In the source for your link I see that the JS is doing some validation. 2. You have method=get in your form. This will work, but you'll have to change the PHP code to use $_GET instead of $_POST vars. Or change to method=post in the form. 3. If you want to keep the .html extension for the page, then you'll probably need to send the post to another script with a .php extension. Normally a file with a .html extension won't execute the PHP code. Thanks! -Shawn I was just looking at that. Someone told me to use GET instead of POST. Since JS is validating is it as easy replacing GET with POST ? Nothing else needed? Is it better to remove the JS and just code using PHP as you showed before? if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) Thanks, Tom Yes, I think it is better to just use PHP code and post is the better method (in this case) because with get all your fields and values will show up in the url -eddy I don't seem to be getting he hang of this. Sounds so simple but Can someone check this out and tell me where exactly I'm messing up? http://www.richlandmtg.com/Contact_Us.html I removed the JS validation. Is the following code ok? a href=# onClick=document.getElementById('form').reset()clear/aimg alt= src=images/ch_more_red.gif style=margin:1px 0 0 3px; vertical-align:text-bottom/bb style=margin-left:17px;a href=# onClick=document.getElementById('form').submit()send/a I posted the PHP info at the top of the page before the html tag. Should it be after html? Sorry please bear with me, Tom Re-read point #3 from my last email. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding for email response forms
I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Any input is greatly appreciated. Tom tr td style=width:100%; height:100%; background:#EDEDED class=deep1 c3form action= id=formtable style=margin:30px 0 0 34px; tr td style=height:37px;font size=4Contact Form/font/td /tr tr tdpbHave a Question?.br /bspan class=p1Please include Name, Email address and a short message when replying. Your questions will be answered shortly./spanbr /p pimg src=images/1287-660.jpg alt=Call Richland Mortgage Today width=150 height=98/p/td /tr trtdimg alt= src=images/spacer.gif width=1 height=11/td/tr trtdName:/td/tr trtdinput name=Name type=text id=Name maxlength=38/td/tr trtdE-mail:/td/tr trtdinput name=Email type=text id=Email maxlength=38/td/tr trtdMessage:/td/tr trtdtextarea name=Message cols=2 rows=2 id=Message/textarea/td/tr trtdb style=margin-left:95px;a href=# onClick=document.getElementById('form').reset()clear/aimg alt= src=images/ch_more_red.gif style=margin:1px 0 0 3px; vertical-align:text-bottom/bb style=margin-left:17px;a href=# onClick=document.getElementById('form').submit()send/aimg alt= src=images/ch_more_red.gif style=margin:1px 0 0 3px; vertical-align:text-bottom/b/td /tr /table/form/td /tr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- 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] Coding for email response forms
Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? That's a good start, however you should use $_POST['realname'] etc. since they are coming from a post operation. $realname only exists if register_globals is on, which is evil. Also, you would probably do this before your form so that you can say Thanks for your feedback. and then exit or redirect and not display the form again. -- 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] Coding for email response forms
On Mon, Jan 26, 2009 at 16:34, Tom obeli...@comcast.net wrote: Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? For processing once it reaches the server, yes - almost exactly. A few recommended changes though: * Change ? to ?php for compatibility across servers with different PHP configurations. * Change your if() to if($_POST['realname']) * DO NOT rely on register_globals - it's insecure and will soon be phased-out of PHP. Instead, using your code: $realname = strip_tags($_POST['realname']); * Use explicit headers with mail(). For example: $headers = From: y...@example.com\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; mail($sendto,$subject,$message,$headers); * Do something (exit, header(Location: otherpage.html) redirect, etc.) so that the form doesn't reappear. Then, either include that code at the top of the file in which your HTML resides, or place it in it's own file (for example: formproc.php) and change your form tag to: form method=POST action=formproc.php name=formName id=formName NB: My original responses that this wasn't PHP-related was based on your original message, saying that your submit button wasn't working, and then including HTML and JavaScript code only. It didn't appear as though it had anything to do with PHP. Getting a good answer is best-achieved by asking a well-formed question. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } -- 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] Coding for email response forms
Daniel Brown danbr...@php.net wrote in message news:ab5568160901261347h1dab427bo29a1313494cd...@mail.gmail.com... On Mon, Jan 26, 2009 at 16:34, Tom obeli...@comcast.net wrote: Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? For processing once it reaches the server, yes - almost exactly. A few recommended changes though: * Change ? to ?php for compatibility across servers with different PHP configurations. * Change your if() to if($_POST['realname']) * DO NOT rely on register_globals - it's insecure and will soon be phased-out of PHP. Instead, using your code: $realname = strip_tags($_POST['realname']); * Use explicit headers with mail(). For example: $headers = From: y...@example.com\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; mail($sendto,$subject,$message,$headers); * Do something (exit, header(Location: otherpage.html) redirect, etc.) so that the form doesn't reappear. Then, either include that code at the top of the file in which your HTML resides, or place it in it's own file (for example: formproc.php) and change your form tag to: form method=POST action=formproc.php name=formName id=formName NB: My original responses that this wasn't PHP-related was based on your original message, saying that your submit button wasn't working, and then including HTML and JavaScript code only. It didn't appear as though it had anything to do with PHP. Getting a good answer is best-achieved by asking a well-formed question. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! Us newbies don't always phrase the questions right but you Shawn answered my question. Just have to try it out now. Thanks T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Shawn McKenzie wrote: Tom Scott wrote: - Original Message - From: Shawn McKenzie nos...@mckenzies.net Newsgroups: php.general To: php-general@lists.php.net Sent: Monday, January 26, 2009 3:52 PM Subject: Re: [PHP] Coding for email response forms Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } -- Thanks! -Shawn http://www.spidean.com Ok. I have the validation part. http://www.richlandmtg.com/index-5.html still working on the Send button. T Please reply all so this stays on the list. 1. In the source for your link I see that the JS is doing some validation. 2. You have method=get in your form. This will work, but you'll have to change the PHP code to use $_GET instead of $_POST vars. Or change to method=post in the form. 3. If you want to keep the .html extension for the page, then you'll probably need to send the post to another script with a .php extension. Normally a file with a .html extension won't execute the PHP code. Thanks! -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Shawn McKenzie sh...@mckenzies.net wrote in message news:497e3ab9.2060...@mckenzies.net... Shawn McKenzie wrote: Tom Scott wrote: - Original Message - From: Shawn McKenzie nos...@mckenzies.net Newsgroups: php.general To: php-general@lists.php.net Sent: Monday, January 26, 2009 3:52 PM Subject: Re: [PHP] Coding for email response forms Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com... On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } -- Thanks! -Shawn http://www.spidean.com Ok. I have the validation part. http://www.richlandmtg.com/index-5.html still working on the Send button. T Please reply all so this stays on the list. 1. In the source for your link I see that the JS is doing some validation. 2. You have method=get in your form. This will work, but you'll have to change the PHP code to use $_GET instead of $_POST vars. Or change to method=post in the form. 3. If you want to keep the .html extension for the page, then you'll probably need to send the post to another script with a .php extension. Normally a file with a .html extension won't execute the PHP code. Thanks! -Shawn I was just looking at that. Someone told me to use GET instead of POST. Since JS is validating is it as easy replacing GET with POST ? Nothing else needed? Is it better to remove the JS and just code using PHP as you showed before? if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
On Mon, Jan 26, 2009 at 4:47 PM, Daniel Brown danbr...@php.net wrote: On Mon, Jan 26, 2009 at 16:34, Tom obeli...@comcast.net wrote: Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? For processing once it reaches the server, yes - almost exactly. A few recommended changes though: * Change ? to ?php for compatibility across servers with different PHP configurations. * Change your if() to if($_POST['realname']) * DO NOT rely on register_globals - it's insecure and will soon be phased-out of PHP. Instead, using your code: $realname = strip_tags($_POST['realname']); * Use explicit headers with mail(). For example: $headers = From: y...@example.com\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; mail($sendto,$subject,$message,$headers); * Do something (exit, header(Location: otherpage.html) redirect, etc.) so that the form doesn't reappear. Then, either include that code at the top of the file in which your HTML resides, or place it in it's own file (for example: formproc.php) and change your form tag to: form method=POST action=formproc.php name=formName id=formName NB: My original responses that this wasn't PHP-related was based on your original message, saying that your submit button wasn't working, and then including HTML and JavaScript code only. It didn't appear as though it had anything to do with PHP. Getting a good answer is best-achieved by asking a well-formed question. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Also make sure there aren't line returns or any nonsense like that in the to subjects. Look up email header injection. Your script might become quite popular at advertising p3n1s pills otherwise. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
Eric Butera eric.but...@gmail.com wrote in message news:6a8639eb0901261509s1008e1b1j89c2a8f63669e...@mail.gmail.com... On Mon, Jan 26, 2009 at 4:47 PM, Daniel Brown danbr...@php.net wrote: On Mon, Jan 26, 2009 at 16:34, Tom obeli...@comcast.net wrote: Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? For processing once it reaches the server, yes - almost exactly. A few recommended changes though: * Change ? to ?php for compatibility across servers with different PHP configurations. * Change your if() to if($_POST['realname']) * DO NOT rely on register_globals - it's insecure and will soon be phased-out of PHP. Instead, using your code: $realname = strip_tags($_POST['realname']); * Use explicit headers with mail(). For example: $headers = From: y...@example.com\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; mail($sendto,$subject,$message,$headers); * Do something (exit, header(Location: otherpage.html) redirect, etc.) so that the form doesn't reappear. Then, either include that code at the top of the file in which your HTML resides, or place it in it's own file (for example: formproc.php) and change your form tag to: form method=POST action=formproc.php name=formName id=formName NB: My original responses that this wasn't PHP-related was based on your original message, saying that your submit button wasn't working, and then including HTML and JavaScript code only. It didn't appear as though it had anything to do with PHP. Getting a good answer is best-achieved by asking a well-formed question. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Also make sure there aren't line returns or any nonsense like that in the to subjects. Look up email header injection. Your script might become quite popular at advertising p3n1s pills otherwise. :) Thanks I'll check it out. I tried including the above code but I still can't seem to get it to work. Must be missing something. Thanks, T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding for email response forms
2009/1/26 Tom obeli...@comcast.net Shawn McKenzie sh...@mckenzies.net wrote in message news:497e3ab9.2060...@mckenzies.net... Shawn McKenzie wrote: Tom Scott wrote: - Original Message - From: Shawn McKenzie nos...@mckenzies.net Newsgroups: php.general To: php-general@lists.php.net Sent: Monday, January 26, 2009 3:52 PM Subject: Re: [PHP] Coding for email response forms Tom wrote: Shawn McKenzie wrote in message news:a0.87.62571.3d92e...@pb1.pair.com... Tom wrote: My Hosting site said that I needed to include the PHP otherwise the form won't work. I need to know where to include my email info to get this set up don't I? What do you suggest? T Daniel Brown danbr...@php.net wrote in message news:ab5568160901261259p6d6442a4ya5ea4134025e5...@mail.gmail.com. .. On Mon, Jan 26, 2009 at 15:57, Tom obeli...@comcast.net wrote: I am a new user of PHP, and am using Dreamweaver CS3 for the webpages. The following page has my form but the submit button is not working properly. http://www.richlandmtg.com/contacts.html What code is needed and where does it get placed in the page.? I thought CS3 took care of this. Tom, This issue has nothing at all to do with PHP. This is all client side (JavaScript and HTML). -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! What you have now is a form that when submitted sends the data to itself. So you either need to include some php in this file to gather up the data and email it when submitted, or submit to another file that does that. -- Thanks! -Shawn http://www.spidean.com Shawn, So would that look something like this: ? if ($_SERVER['REQUEST_METHOD'] == POST) { // Just to be safe, I strip out HTML tags $realname = strip_tags($realname); $email = strip_tags($email); $feedback = strip_tags($feedback); // set the variables // replace $...@mysite.com with your email $sendto = $...@mysite.com; $subject = Sending Email Feedback From My Website; $message = $realname, $email\n\n$feedback; // send the email mail($sendto, $subject, $message); } ? Oh, you should also think about some other things, such as validation. Is realname only alpha characters? Is email in the form of a real email address? At a bare minimum, are they not empty: if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) { echo 'You must complete all required fields!'; // show form again } -- Thanks! -Shawn http://www.spidean.com Ok. I have the validation part. http://www.richlandmtg.com/index-5.html still working on the Send button. T Please reply all so this stays on the list. 1. In the source for your link I see that the JS is doing some validation. 2. You have method=get in your form. This will work, but you'll have to change the PHP code to use $_GET instead of $_POST vars. Or change to method=post in the form. 3. If you want to keep the .html extension for the page, then you'll probably need to send the post to another script with a .php extension. Normally a file with a .html extension won't execute the PHP code. Thanks! -Shawn I was just looking at that. Someone told me to use GET instead of POST. Since JS is validating is it as easy replacing GET with POST ? Nothing else needed? Is it better to remove the JS and just code using PHP as you showed before? if (empty($_POST['email']) || empty($_POST['realname']) || empty($_POST['feedback'])) Thanks, Tom Yes, I think it is better to just use PHP code and post is the better method (in this case) because with get all your fields and values will show up in the url -eddy
[PHP] coding MySQL error traps [WAS: mysql if empty]
$sql = SELECT Client FROM booked WHERE Name = 'larry'; $result = mysql_query($sql) OR die('[MYSQL ERROR] - ['.mysql_errno().']br /'.mysql_error()); while ( list($client) = mysql_fetch_row($result) ) { echo {$client}br /\n; } I agree with this logic overall. The above is of course just oversimplified demo code, but I'd like to mention a few details I would change before putting this into practice. The syntax $result = mysql_query($sql) OR die(); is nicely compact but obfuscates the program logic. PHP is not actually ORing two values, it's halting execution halfway through the statement if mysql_query() returns true. This constitutes a hack because it depends entirely on the way the parser processes code rather than on explicit elements of the language. To help keep legacy code from crashing with PHP version X I'd break this into two statements: run the query, then act on the result. The parser won't care, and your code will be more easily readable by us humans. Displaying mysql_error() is great for the developer but in a public application will expose the names of tables and fields to the public who shouldn't really see your wires and pipes. mysql_error() doesn't usually contain the entire query and doesn't always contain the segment of the query that actually caused the error, so I always add the full query to the error message to save time in debugging. Finally, die()ing on a mysql error is pretty harsh; a friendlier application would return the error state to parent layers, translate the error into advice a non-technical user can deal with, and display it in a way that doesn't crash the page. Rather than trying to remember to go through the code later fixing these bits, I suggest adopting a convention early on that suits both development and publication, such as: ___ define('bDebug', true); ... $bResult = mysql_query($sql); if (!$bResult) return ReportSQLError('checking user name', mysql_errno(), mysql_error(), $sql); ... function ReportSQLError($context, $errno, $errorMsg, $sql) { if (bDebug) { die(MYSQL ERROR $errno $context:hr /\n$errorMsghr /\n$sql); } else { return $generate_friendly_error_message; } } ___ Regards, Paul __ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] coding MySQL error traps [WAS: mysql if empty]
Paul Novitski wrote: $sql = SELECT Client FROM booked WHERE Name = 'larry'; $result = mysql_query($sql) OR die('[MYSQL ERROR] - ['.mysql_errno().']br /'.mysql_error()); while ( list($client) = mysql_fetch_row($result) ) { echo {$client}br /\n; } I agree with this logic overall. The above is of course just oversimplified demo code, but I'd like to mention a few details I would change before putting this into practice. The syntax $result = mysql_query($sql) OR die(); is nicely compact but obfuscates the program logic. PHP is not actually ORing two values, it's halting execution halfway through the statement if mysql_query() returns true. This constitutes a hack because it depends entirely on the way the parser processes code rather than on explicit elements of the language. To help keep legacy code from crashing with PHP version X I'd break this into two statements: run the query, then act on the result. The parser won't care, and your code will be more easily readable by us humans. Displaying mysql_error() is great for the developer but in a public application will expose the names of tables and fields to the public who shouldn't really see your wires and pipes. mysql_error() doesn't usually contain the entire query and doesn't always contain the segment of the query that actually caused the error, so I always add the full query to the error message to save time in debugging. Finally, die()ing on a mysql error is pretty harsh; a friendlier application would return the error state to parent layers, translate the error into advice a non-technical user can deal with, and display it in a way that doesn't crash the page. Rather than trying to remember to go through the code later fixing these bits, I suggest adopting a convention early on that suits both development and publication, such as: ___ define('bDebug', true); ... $bResult = mysql_query($sql); if (!$bResult) return ReportSQLError('checking user name', mysql_errno(), mysql_error(), $sql); ... function ReportSQLError($context, $errno, $errorMsg, $sql) { if (bDebug) { die(MYSQL ERROR $errno $context:hr /\n$errorMsghr /\n$sql); } else { return $generate_friendly_error_message; } } ___ Regards, Paul __ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com Yes, this was intended to only show the OP a very simple way to get done what they were wanting to do. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] coding MySQL error traps [WAS: mysql if empty]
On Tue, April 10, 2007 1:08 pm, Paul Novitski wrote: mysql_query() returns true. This constitutes a hack because it depends entirely on the way the parser processes code rather than on explicit elements of the language. The order of execution and boolean short-circuit is a Documented Feature. This is no more a hack than relying on: if ($foo || $bar){ } to do the right thing. That said, or die... is a shorthand for you should replace this with REAL error handling, so you're right, only for the wrong reasons. :-) define('bDebug', true); ... $bResult = mysql_query($sql); if (!$bResult) return ReportSQLError('checking user name', mysql_errno(), mysql_error(), $sql); ... function ReportSQLError($context, $errno, $errorMsg, $sql) { if (bDebug) { die(MYSQL ERROR $errno $context:hr /\n$errorMsghr /\n$sql); } else { return $generate_friendly_error_message; } } Personally, I wouldn't use this bDebug stuff... It's too easy for a logic error in bDebug/non-bDebug to slip through QA, and have the application working differently on the Production server from the dev server. This is particularly true if you don't have a test suite with 100% (or close) code coverage. Better to do something like: $whatever = mysql_query($query, $connection); if (!$whatever){ $messages[] = Something went wrong. Nice user error message here.; error_log(mysql_error($connection)); error_log($query); } $messages can be dumped out en masse in the presentation layer in a suitable div. Some would argue that things could go very wrong and fill up your log files... Well, yeah, if you're so inept and dis-organized as to not have a process in place to detect and deal with a problem that it happens enough to fill up your log files, then, yes, it could be a problem... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
Sorry for troubling all again. I am trying to use the Pear DB_ldap for the above scripts. Does any one have any sample code for ldap_connect () ldap_search etc. http://php.net/ldap_connect http://php.net/ldap_search Both pages have examples. If you have a specific problem then post it. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
On 1/23/07, Chris [EMAIL PROTECTED] wrote: Sorry for troubling all again. I am trying to use the Pear DB_ldap for the above scripts. Does any one have any sample code for ldap_connect () ldap_search etc. http://php.net/ldap_connect http://php.net/ldap_search Both pages have examples. If you have a specific problem then post it. -- Postgresql php tutorials http://www.designmagick.com/ Thanx for replying Chris. I am in process to modify my existing php scripts to a more neater/compact code. In current scripts certain code ( ldap_connect , ldap_bind , if connet error show error page etc ) is repeated many times. This makes the scripts very bulky and even small changes that need to be done are very difficult to implement. That's why I am looking for some thing with a ready functions for the above which I can use. I believe PEAR DB_ldap has it. But very little documentation is avaliable. So I was searching for any sample scripts. - My current script: user edit page ?php require 'validate.php' // included on every page to check logged in user. bind to ldap else error.. show a form to user to edit user details. post to update script. disconnect ldap. ? on update ?php validate user bind to ldap else . check if any changes need to be done to the user .( compare before after values in the POST variables ) create the array for modfiy do ldap_modify in case error shout , else tell all is ok. ldap_disconnect. ? The problem is, for separate edit pages I have written separate update pages. Any new object to edit needs a new edit page a relevent update page. I believe if I can use functions this can be reduced to just one update page with fewer edit pages. Very sorry for this long mail. Thanx Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
On 1/18/07, Ramdas [EMAIL PROTECTED] wrote: On 1/17/07, Jochem Maas [EMAIL PROTECTED] wrote: Ramdas wrote: Hi Group, A very newbie question. Might be discussed earlier, please forgive. Are so much of a noob that STFW is not within your capabilities? (just thought I'd ask, given that you admit to realising the info *might* be out there already) I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the recommended to use the $_SESSION superglobal instead and stuff values directly into (after having called session_start()) instead of using session_register() et al. user's login passwd . Each time the user hits the page these vars you only need to store *whether* they are logged in - and set that value when you actually handle a login attempt (obviously storing their username could be handy) I don't see any reason to store the passwd and validate against ldap on every request ... in fact I believe that storing the pwd in such a way is essentially less secure. are checked with the existing values in the LDAP (this is done by validate.php). Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. that question is about as vague as 'how long is a chinaman?' (the answer to that question being 'yes he is') here are some very vague ideas/functions: an include file ... === 8 = ?php function sessionCheck() { if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) { /* show login page then .. */ exit; } } function doLogin($username, $passwd) { $_SESSION['loggedin'] = false; if (/* given $username+$passwd check outs in ldap*/) $_SESSION['loggedin'] = true; return $_SESSION['loggedin']; } ? an 'init' include file === 8 = ?php require 'your-include-file.php'; // see above session_start(); if (isset($_POST['uname'], $_POST['pwd'])) { doLogin($_POST['uname'], $_POST['pwd']); } sessionCheck(); ? any other file (other than the login 'page') === 8 = ?php require 'your-init-file.php'; // we are logged in - it's magic // do some shit // the end, congrats go get laid :-) ? Thanx for the all responses. Regards Ram Hi all, Sorry for troubling all again. I am trying to use the Pear DB_ldap for the above scripts. Does any one have any sample code for ldap_connect () ldap_search etc. Thanx once again. Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
On 1/17/07, Jochem Maas [EMAIL PROTECTED] wrote: Ramdas wrote: Hi Group, A very newbie question. Might be discussed earlier, please forgive. Are so much of a noob that STFW is not within your capabilities? (just thought I'd ask, given that you admit to realising the info *might* be out there already) I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the recommended to use the $_SESSION superglobal instead and stuff values directly into (after having called session_start()) instead of using session_register() et al. user's login passwd . Each time the user hits the page these vars you only need to store *whether* they are logged in - and set that value when you actually handle a login attempt (obviously storing their username could be handy) I don't see any reason to store the passwd and validate against ldap on every request ... in fact I believe that storing the pwd in such a way is essentially less secure. are checked with the existing values in the LDAP (this is done by validate.php). Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. that question is about as vague as 'how long is a chinaman?' (the answer to that question being 'yes he is') here are some very vague ideas/functions: an include file ... === 8 = ?php function sessionCheck() { if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) { /* show login page then .. */ exit; } } function doLogin($username, $passwd) { $_SESSION['loggedin'] = false; if (/* given $username+$passwd check outs in ldap*/) $_SESSION['loggedin'] = true; return $_SESSION['loggedin']; } ? an 'init' include file === 8 = ?php require 'your-include-file.php'; // see above session_start(); if (isset($_POST['uname'], $_POST['pwd'])) { doLogin($_POST['uname'], $_POST['pwd']); } sessionCheck(); ? any other file (other than the login 'page') === 8 = ?php require 'your-init-file.php'; // we are logged in - it's magic // do some shit // the end, congrats go get laid :-) ? Thanx for the all responses. Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Php coding help - Newbie question
Hi Group, A very newbie question. Might be discussed earlier, please forgive. I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the user's login passwd . Each time the user hits the page these vars are checked with the existing values in the LDAP (this is done by validate.php). Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. Many thanx in advance. Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
Ramdas wrote: Hi Group, A very newbie question. Might be discussed earlier, please forgive. I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { Change the previous lines to this and then move it to the bottom of the file called validate.php Since you include that on each page, it will then be executed and upon failure, stop the script and display a connection error if ( $connect = ldap_connect(ldapserver) === FALSE ) { //display error message and die(); die(Internal problem, please try back later.); } bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the user's login passwd . Each time the user hits the page these vars are checked with the existing values in the LDAP (this is done by validate.php). I would be using the Super Globals for this: $_SESSION, and don't store the password, just the username and something the say that he/she has already authenticated and is valid. Jim Lucas Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. Many thanx in advance. Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
Ramdas wrote: Hi Group, A very newbie question. Might be discussed earlier, please forgive. Are so much of a noob that STFW is not within your capabilities? (just thought I'd ask, given that you admit to realising the info *might* be out there already) I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the recommended to use the $_SESSION superglobal instead and stuff values directly into (after having called session_start()) instead of using session_register() et al. user's login passwd . Each time the user hits the page these vars you only need to store *whether* they are logged in - and set that value when you actually handle a login attempt (obviously storing their username could be handy) I don't see any reason to store the passwd and validate against ldap on every request ... in fact I believe that storing the pwd in such a way is essentially less secure. are checked with the existing values in the LDAP (this is done by validate.php). Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. that question is about as vague as 'how long is a chinaman?' (the answer to that question being 'yes he is') here are some very vague ideas/functions: an include file ... === 8 = ?php function sessionCheck() { if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) { /* show login page then .. */ exit; } } function doLogin($username, $passwd) { $_SESSION['loggedin'] = false; if (/* given $username+$passwd check outs in ldap*/) $_SESSION['loggedin'] = true; return $_SESSION['loggedin']; } ? an 'init' include file === 8 = ?php require 'your-include-file.php'; // see above session_start(); if (isset($_POST['uname'], $_POST['pwd'])) { doLogin($_POST['uname'], $_POST['pwd']); } sessionCheck(); ? any other file (other than the login 'page') === 8 = ?php require 'your-init-file.php'; // we are logged in - it's magic // do some shit // the end, congrats go get laid :-) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Standards Document
At 7:14 PM -0500 11/21/06, Robert Cummings wrote: On Tue, 2006-11-21 at 16:19 -0500, tedd wrote: It seems that every time I ask a security question, I find that I'm currently practicing the answers to avoid the pit-falls. Except that one time when his site got defaced... that was news ;) ;) Cheers, Rob. Rob: Good point, but that was a problem my host had and not something that was my fault. It seems that everyone who hosted with that company had every file that even contained the word index replaced. I keep a redirect index in every folder, so I had well over 200 indexes to replace -- joy, joy. Since then, that host has not answered any of my emails, but I can't complain too much because I use very inexpensive hosts for my test sites. You see, I'm at the other end of the spectrum than you guys. You can afford high-priced host, but I can't -- you probably can't guess as to how cheap I can buy hosting -- it's unbelievable. However, when it comes to providing a client with a host, that's a different matter and it's their cost,not mine -- for I can (and do) work with much less. 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] Coding Standards Document
On Wed, 2006-11-22 at 10:31 -0500, tedd wrote: At 7:14 PM -0500 11/21/06, Robert Cummings wrote: On Tue, 2006-11-21 at 16:19 -0500, tedd wrote: It seems that every time I ask a security question, I find that I'm currently practicing the answers to avoid the pit-falls. Except that one time when his site got defaced... that was news ;) ;) Cheers, Rob. Rob: Good point, Just some friendly ribbing :D but that was a problem my host had and not something that was my fault. It seems that everyone who hosted with that company had every file that even contained the word index replaced. I keep a redirect index in every folder, so I had well over 200 indexes to replace -- joy, joy. That took 10 seconds to replace right? If it took you an afternoon you might be maintaining things wrong... but then I guess it depend son whether your host gives you SSH access or just ftp. I would never go with an ftp only host. If for some ungodly reason I did, you can be sure I'd have an expect script to migrate the whole site hands free :) Since then, that host has not answered any of my emails, but I can't complain too much because I use very inexpensive hosts for my test sites. You see, I'm at the other end of the spectrum than you guys. You can afford high-priced host, but I can't -- you probably can't guess as to how cheap I can buy hosting -- it's unbelievable. Ummm, I'm no millionaire... yet... I host my InterJinn site from home. If you ever wondered why it's so slow, it's not the code... it's this crud 75k/s upload DSL with terrible latency. However, when it comes to providing a client with a host, that's a different matter and it's their cost,not mine -- for I can (and do) work with much less. I hear ya :) I have kids, if I don't need it, I don't buy it. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Standards Document
On Wednesday 22 November 2006 16:31, tedd wrote: At 7:14 PM -0500 11/21/06, Robert Cummings wrote: On Tue, 2006-11-21 at 16:19 -0500, tedd wrote: It seems that every time I ask a security question, I find that I'm currently practicing the answers to avoid the pit-falls. Except that one time when his site got defaced... that was news ;) ;) Cheers, Rob. Rob: Good point, but that was a problem my host had and not something that was my fault. It seems that everyone who hosted with that company had every file that even contained the word index replaced. I keep a redirect index in every folder, so I had well over 200 indexes to replace -- joy, joy. Since then, that host has not answered any of my emails, but I can't complain too much because I use very inexpensive hosts for my test sites. You see, I'm at the other end of the spectrum than you guys. You can afford high-priced host, but I can't -- you probably can't guess as to how cheap I can buy hosting -- it's unbelievable. Everyone can setup a cheapass old pentium to use as a testhost. These crappy hostings sites never put in any finecrafted unix tools nor any ssh support. Anyway, point is: Its free However, when it comes to providing a client with a host, that's a different matter and it's their cost,not mine -- for I can (and do) work with much less. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding...
I am pretty new with PHP, but what I've learned in the last 3 weeks is pretty good I think so far! What I'm looking to do is create a login script, and have people being able to login. Now, I have pulled scripts from sites, and everything is working okay. But the problem I have with pulling scripts from other sites, is that the mysql databases are all different. How can I import from one database into the other, so basically all the databases are merged into one main? I also know that each PHP file has to be re-done and look for the new database name, for instance if it was user_name, and the default (Main) database is username .. That I Have to rename all the php files that have user_name to simply username. If anyone is willing to help out with the project I'm working on with another programmer? Hopefully being very cost effective .. or free :) :) Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding...
I'd pick up a book Web Database Applications with PHP and MySQL, otherwise known as the Platypus Book, and use that. That will teach you a lot about logins, sessions, as well as using MySQL and PHP together. As far as the database name goes, that has nothing to do with the PHP file name. Jeff wrote: I am pretty new with PHP, but what I've learned in the last 3 weeks is pretty good I think so far! What I'm looking to do is create a login script, and have people being able to login. Now, I have pulled scripts from sites, and everything is working okay. But the problem I have with pulling scripts from other sites, is that the mysql databases are all different. How can I import from one database into the other, so basically all the databases are merged into one main? I also know that each PHP file has to be re-done and look for the new database name, for instance if it was user_name, and the default (Main) database is username .. That I Have to rename all the php files that have user_name to simply username. If anyone is willing to help out with the project I'm working on with another programmer? Hopefully being very cost effective .. or free :) :) Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding...
There are a lot of good books to go by. I suggest getting one that incorporates both PHP MySQL, not just php. On 11/18/06, Jeff [EMAIL PROTECTED] wrote: I am pretty new with PHP, but what I've learned in the last 3 weeks is pretty good I think so far! What I'm looking to do is create a login script, and have people being able to login. Now, I have pulled scripts from sites, and everything is working okay. But the problem I have with pulling scripts from other sites, is that the mysql databases are all different. How can I import from one database into the other, so basically all the databases are merged into one main? I also know that each PHP file has to be re-done and look for the new database name, for instance if it was user_name, and the default (Main) database is username .. That I Have to rename all the php files that have user_name to simply username. If anyone is willing to help out with the project I'm working on with another programmer? Hopefully being very cost effective .. or free :) :) Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- ** The content of this e-mail message and any attachments are confidential and may be legally privileged, intended solely for the addressee. If you are not the intended recipient, be advised that any use, dissemination, distribution, or copying of this e-mail is strictly prohibited. If you receive this message in error, please notify the sender immediately by reply email and destroy the message and its attachments. *
Re: [PHP] Coding Style Question...
At 10:23 AM +0800 10/3/06, Glenn Richmond wrote: I'll probably get strong opposition for these comments, but in my opinion, there's nothing worse than mixing two different lanuages in a single file, not to mention mixing functional code with layout code. Glenn. Glenn: I agree with the concepts of unobtrusive code and the separation of content, presentation, and behavior. However, I find it very difficult not to mix languages -- for example, trying to generate dynamic html from php/mysql without mixing all three languages is difficult, if not impossible. Plus, when php can generate html, css, javascript, and content -- it's not possible (by definition) to create language-pure code under those conditions. Also, sometimes mixing languages is preferable (with regard to readability) than trying to develop a scheme to separate them. And lastly, what constitutes separation? Is an include(), or date(), or any php function from within a html, or css, file acceptable? If not, what's the cost in readability or lines of additional code to obtain the same functionality? I don't know about others, but the language line is blurred for me. I still believe in the concepts separation of content, presentation, and behavior, but php transcends the other languages in a different manner and provides the glue to hold them together and make them a cohesive functional solution. In my mind, the concept of separation does not fall clearly along language boundaries. While this is not meant to demean php, I see php not only as a stand-alone language, but as an addition to html, css, and javascript, which can enhance their functionality. Clearly each of those languages can do more with php than without it. That's my perspective. 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] Coding Style Question...
On Mon, October 2, 2006 7:32 pm, Tony Di Croce wrote: I am relatively new to PHP... I have about 1.5 years of light PHP work under my belt... Over the past year or so my PHP coding style has evolved significantly and I'm curious as to how experienced programmers write PHP... Basically, here is what I have evolved to: 1) ALL php code is at the top of the file. 2) ALL html code is in a here document at the bottom. 3) php code is run before 1 character is outputed (and hence, no headers are sent, leaving redirects open for possibilities) 4) I almost always following my require_once directives with a session_start() at the top of the file. 5) Often, my forms submit to the PHP page that generated them but do so with a hidden posted variable. If that variable is set, then I process the form submission. I think the most important part of all this is #1 #2... I think I am using PHP a little like template engine this way... It seems to me that I most often see code snippets that try to intertwine HTML and PHP, but in my experience, except for trivial examples, this doesn't work so good... What do you think? I do the same, but will mingle HTML/PHP for layout/formatting or User Interface logic. And I don't bother with a heredoc, since I find it easier to edit HTML with the occasional ?php echo $foo? in it. E.g., a popup menu of the years from current to 10 years into the future for the credit card expiration is not exactly complex back-end business logic. A simple 'for' loop in my HTML to do that is vastly superior to the solution of templates that require hours of back-tracking through 7 PHP/template/HTML/whatever files to sort out what the heck is going on here... And, yes, I *did* once waste hours to find out how they were generating a 10-year popup for the credit card expiration... Which they had HARD-CODED the 'start' year in their business logic!!! Sheesh! Back-tracking that through the files turned a 5-minute task into hours wasted. And folks wonder why I think PHP *is* a template language and you shouldn't use another one on top of it... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding Style Question...
I am relatively new to PHP... I have about 1.5 years of light PHP work under my belt... Over the past year or so my PHP coding style has evolved significantly and I'm curious as to how experienced programmers write PHP... Basically, here is what I have evolved to: 1) ALL php code is at the top of the file. 2) ALL html code is in a here document at the bottom. 3) php code is run before 1 character is outputed (and hence, no headers are sent, leaving redirects open for possibilities) 4) I almost always following my require_once directives with a session_start() at the top of the file. 5) Often, my forms submit to the PHP page that generated them but do so with a hidden posted variable. If that variable is set, then I process the form submission. I think the most important part of all this is #1 #2... I think I am using PHP a little like template engine this way... It seems to me that I most often see code snippets that try to intertwine HTML and PHP, but in my experience, except for trivial examples, this doesn't work so good... What do you think? -- Publish technical articles @ skilledwords.com and get 100% of the ad-revenue! http://www.skilledwords.com
RE: [PHP] Coding Style Question...
[snip] What do you think? [/snip] I think I'd like an ice cold beer. I code PHP like I code C++, heavily commented with code designed to fit the needs of the application. There is a thing in PEAR concerning style (you can Google it pretty easily) and you will as many styles as you do PHP developers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Style Question...
Hi Tony, Sounds like a good start. I have to admit that one that I prefer is that HTML code should be completely separated from PHP via the use of a templating engine of some sort (I'm a fan of XTemplate). I'll probably get strong opposition for these comments, but in my opinion, there's nothing worse than mixing two different lanuages in a single file, not to mention mixing functional code with layout code. Glenn. Tony Di Croce wrote: I am relatively new to PHP... I have about 1.5 years of light PHP work under my belt... Over the past year or so my PHP coding style has evolved significantly and I'm curious as to how experienced programmers write PHP... Basically, here is what I have evolved to: 1) ALL php code is at the top of the file. 2) ALL html code is in a here document at the bottom. 3) php code is run before 1 character is outputed (and hence, no headers are sent, leaving redirects open for possibilities) 4) I almost always following my require_once directives with a session_start() at the top of the file. 5) Often, my forms submit to the PHP page that generated them but do so with a hidden posted variable. If that variable is set, then I process the form submission. I think the most important part of all this is #1 #2... I think I am using PHP a little like template engine this way... It seems to me that I most often see code snippets that try to intertwine HTML and PHP, but in my experience, except for trivial examples, this doesn't work so good... What do you think? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Style Question...
On Monday 02 October 2006 19:32, Tony Di Croce wrote: I am relatively new to PHP... I have about 1.5 years of light PHP work under my belt... Over the past year or so my PHP coding style has evolved significantly and I'm curious as to how experienced programmers write PHP... Basically, here is what I have evolved to: 1) ALL php code is at the top of the file. 2) ALL html code is in a here document at the bottom. 3) php code is run before 1 character is outputed (and hence, no headers are sent, leaving redirects open for possibilities) 4) I almost always following my require_once directives with a session_start() at the top of the file. 5) Often, my forms submit to the PHP page that generated them but do so with a hidden posted variable. If that variable is set, then I process the form submission. I think the most important part of all this is #1 #2... I think I am using PHP a little like template engine this way... It seems to me that I most often see code snippets that try to intertwine HTML and PHP, but in my experience, except for trivial examples, this doesn't work so good... What do you think? Good habits to form, overall. Most examples and tutorials are trivial, which is why they do the intermingling thing. To be fair, that was one of PHP's original strengths over its competition in the early days (vis, Perl and C), because it made doing simple stuff simple. You didn't need to dynamically build the whole page if you only wanted a small bit to be dynamic. Of course, once you get into anything interesting, you frequently DO want the whole page dynamic or else templated. In my case, I tend to use php-based templates and theme functions, a style borrowed from Drupal. To wit, I have a function like this (off the cuff, not tested): function call_template($template, $args) { extract($args); ob_start(); include($template); $output = ob_get_contents(); ob_end_clean(); return $output; } $template is then the name of a mostly-HTML .php file where I can use PHP for display (mostly just echoing), making it easy to separate logic and presentation and build the page piecemeal. It also means that I have all the power of PHP for my template engine. Then I also have functions like theme_table($header=array(), $rows=array(), $caption='', $attrib=array()) {} or theme_unorderedlist($items=array()) {} So that I can just pass logical data structures and get back fully semantically useful HTML. (Eg, theme_table automatically puts in even/odd classes on tr tags for me.) Again, credit here goes to the Drupal CMS, which uses a much more developed and refined version of this concept. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding Practice: Use global $var or pass in by refernce
I was wondering what the general rule on using the global driective versus passing in a variable by reference, why you should or shouldn't, etc. e.g. function () { global $db; $res = $db-query( SQL); } or function ( $db ) { $res = $db-query( SQL); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
- Original Message - From: Mark Steudel [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Friday, March 03, 2006 7:46 PM Subject: [PHP] Coding Practice: Use global $var or pass in by refernce I was wondering what the general rule on using the global driective versus passing in a variable by reference, why you should or shouldn't, etc. e.g. function () { global $db; $res = $db-query( SQL); } or function ( $db ) { $res = $db-query( SQL); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! /G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
Hi Gustav! Gustav Wiberg wrote: My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class: class DB {...} And a lot of classes which want to use the DB class: class Foo { function saveChangesInDb() {...} } class Bar { function saveChangesInDb() {...} } - You can use a global $db = new DB... and pass it to every class/methode, - you can make $db global in each methode, - you can create a new instance (new DB) in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or - use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?). So what's the way you'd recommend and why? best regards Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
I would go for: - you can create a new instance (new DB) in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or This way the code keeps well organized and about the use of only one connection I wouldn't worry too much since usually one thread/process is created per script called, so if this is a multiuser application you end up with several connections anyway, besides I think PHP reuses the connections when possible so the performance of your application does not seem affected at all. I use it, works perfectly with big databases and several users. Regards. Andreas Korthaus wrote: Hi Gustav! Gustav Wiberg wrote: My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class: class DB {...} And a lot of classes which want to use the DB class: class Foo { function saveChangesInDb() {...} } class Bar { function saveChangesInDb() {...} } - You can use a global $db = new DB... and pass it to every class/methode, - you can make $db global in each methode, - you can create a new instance (new DB) in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or - use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?). So what's the way you'd recommend and why? best regards Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
- Original Message - From: Andreas Korthaus [EMAIL PROTECTED] To: php-general@lists.php.net; Gustav Wiberg [EMAIL PROTECTED] Sent: Friday, March 03, 2006 8:53 PM Subject: Re: [PHP] Coding Practice: Use global $var or pass in by refernce Hi Gustav! Gustav Wiberg wrote: My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class: class DB {...} And a lot of classes which want to use the DB class: class Foo { function saveChangesInDb() {...} } class Bar { function saveChangesInDb() {...} } - You can use a global $db = new DB... and pass it to every class/methode, - you can make $db global in each methode, - you can create a new instance (new DB) in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or - use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?). So what's the way you'd recommend and why? best regards Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi Andreas! I don't have that much experience with classes, but wouldn't it work to: 1. make a connection to the db like $db = open db, and then pass around this variable? 2. Extend the DB - class, so the saveChangesInDb() - function in the Foo-class would be an extension from the DB-class ? (I think this works to extend a class in PHP right?) 3 . Use already existing classes for db...http://www.phpclasses.org/ PHP Scripts / Databases I hope this'll help! /G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
On Fri, 2006-03-03 at 14:53, Andreas Korthaus wrote: - use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?). I use a global configuration to register database connection params. InterJinn uses something like the following: $GLOBALS['interJinn']['databases'] = array ( 'carnageWeb' = array ( 'type' = 'mysql', 'host' = 'wocmud.org', 'user' = 'me', 'password' = 'noyou', 'db' = 'carnage_web' ), 'carnage' = array ( 'host' = 'wocmud.org', 'user' = 'me', 'password' = 'notyouagain', 'db' = 'carnage' ), 'carnageForum' = array ( 'host' = 'wocmud.org', 'user' = 'me', 'password' = 'notyouyetagain', 'db' = 'carnage_forum' ), 'default' = 'carnageWeb', ); This is consumed by the database manager which is a singleton/factory that uses connection pooling. ?php $mDb = $this-getServiceRef( 'dbManager' ); $db = $mDb-getConnectionRef(); $db-query( 'blah blah blah' ); $db2 = $mDb-getConnectionRef(); $db2-query( 'bleh bleh bleh' ); $db3 = $mDb-getConnectionRef( 'carnageForum' ); $db3-query( 'bleh bleh bleh' ); $db-free(); $db2-free(); $db3-free(); ? In this way all database connections are named such that if something changes in the future, whether it be the name of the database, the type of database server, the port, whatever, my code shouldn't need to change -- only the configuration. Additionally since I retrieve from a pool, I only ever use as many connections as I need at a time. Be that 1 or 3 or 5. Additionally I know that when I retrieve a second database instance it's not going to clobber the query from the first request. I advocate use of the $GLOBALS array for configuration information that remains static and only when the purpose is clearly defined and well named such that you can be very sure that you won't run into naming conflicts in the near future. This is why I use an interJinn sub array within the globals to segregate InterJinn specific configuration vars. I'd advocate using constants but they don't support arrays, or at least not as far back as I maintain compatibility. Why the PHP guys didn't foresee constant array values is anyone's guess *lol*. You'll also notice I retrieve the factory/singleton by means of named service. This avoids most of that interface/inheritance bullshit that Java gets mired in (and PHP5 has embraced *hahah*). As long as the expected methods exist then any class can be dropped in as a replacement via the service registry, whether it extends, implements, burps, or farts the original class -- or not :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
So what's the way [using Globals] you'd recommend and why? best regards Andreas Andreas: I have to agree with Gustav on this -- I very seldom use Globals. I might use one for debugging, but not for finished code. Their use simply creates problems in porting code, keeping things modular, and maintenance. Perhaps I'm fortunate, but I usually find a way around using Globals. And since I've been coding in PHP, I've never been forced to use them. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
Andreas Korthaus wrote: Hi Gustav! Gustav Wiberg wrote: My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class: class DB {...} And a lot of classes which want to use the DB class: class Foo { function saveChangesInDb() {...} } class Bar { function saveChangesInDb() {...} } - You can use a global $db = new DB... and pass it to every class/methode, - you can make $db global in each methode, - you can create a new instance (new DB) in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or - use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?). So what's the way you'd recommend and why? IMHO, the only way a global variable would have sense is in an environment where you can be assured there's a DBClass $db instance, and that it would never ever be a $db var that's not a DBClass instance nor will $db ever be missing. So, can you guarantee this at the present and to the end of times? :) I think it would be better to create an instance of $db whatever the script you need it, and pass it to every class-constructor as a byref-parameter; i.e. $db = new DBClass(); ··· $class1 = new Class1($db); ··· $class2 = new Class2($db); Now, if you insist on using global vars, then maybe, just maybe, it would be better to let that byref-param be optional, and check in the constructor for a global DBClass instance $db if no DBClass instance was given, but then again the problem would be pretty much the same. Try not to rely on global vars, bear in mind that global vars almost always give too little info and do not reflect themselves on the function prototype --well, if you have a smart IDE/editor that understand PHPDoc comments (or something like that) and you do document their existance, it might not be that bad, but still try to avoid them. -- Atentamente, J. Rafael Salazar Magaña Innox - Innovación Inteligente Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE http://www.innox.com.mx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Practice: Use global $var or pass in by refernce
On Fri, 2006-03-03 at 16:19 -0500, tedd wrote: Perhaps I'm fortunate, but I usually find a way around using Globals. And since I've been coding in PHP, I've never been forced to use them. Just my 2c... In our framework, I use globals as well, although I do tend to agree with Tedd regarding workarounds rather... :) Something like so: I create a global to hold the db object (in my case MDB2 or PEAR DB) and then use a loadclass function to get the dbconfig from another module. This creates a nice way to easily pick it up wherever its needed. I then use the factory method to instantiate the db abstraction layer and pass it, through my engine class to an object class where I further abstract the db functions through a central db class. All of the modules in the system that have database derived classes extend my dbTable class, thereby keeping everything centralised. In dbTable class, I evaluate if the db object exists, and if it *really* doesn't, I create it through the engine. This makes for lazy evaluation of the db object, so that it works kinda on demand, rather than on every request. Using this method, I can also use a global error callback method to handle _all_ database errors gracefully, using PEAR_Error. I do think that there may be a slight performance hit doing it this way, but in an app with over 180 000 lines of code (so far) I find it works just fine... --Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Improving my PHP coding
Though my applications run in a high profile environment (national class action lawsuits e.g. Enron, Microsoft, etc.), my coding style is ages old, and even then, primitive. If there is anyone who has the time to help me bring my coding up to 2005 standards, off line, I would appreciate it. With appreciation -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
On 07/12/2004, at 6:50 AM, Al wrote: Jason Wong wrote: On Monday 06 December 2004 14:19, Rory Browne wrote: If I'm not mistaken Al wanted to return something if the thing failed, without having to put it inside an if_block. I'm watching this with curiosity, because return is a language construct, and not a function, or anything that has a value. You can have: ... OR $error = Oh dear; But the say I see it, eventually, somewhere in your code you need to test for it. Essentially you're just moving the test somewhere else. Essentially, I'm creating warning reports for my users, not code errors. The users can then email the warnings to our webmaster. That's totally the wrong approach. Dumping errors to the screen and asking the end user to create an email for the webmaster is just a fantasy. 99% of users will walk away and never return. It's bad user experience, and it's a crisis point that you're handling badly. A better plan would be to hide all the errors from the user, log them to and error log, automatically email the webmaster, and present a simple something went wrong, sorry, we're working on it to the user. They don't need to know anything about mysql, tables, databases, etc -- the WEBMASTER does, but not the user. --- Justin French, Indent.com.au [EMAIL PROTECTED] Web Application Development Graphic Design -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
Al wrote: I've searched the PHP manual and can't find an answer for this question I'd like to use the OR DIE construct; but instead of DIE I'd like to use RETURN FOO. I haven't found a way to do it. $string= file_get_contents($filename) OR die(Could not read file); $db_link= mysql_connect($host, $user, $pw) OR die(Could not connect: . mysql_error()); Seems like it would be nice to not have to test first, e.g., if(is_readable($filename)){ } You may want to use: or http://php.net/exit or http://php.net/return I will not guarantee that either will work, much less do what you want, which I don't really understand in the first place. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
Jason Wong wrote: On Monday 06 December 2004 14:19, Rory Browne wrote: If I'm not mistaken Al wanted to return something if the thing failed, without having to put it inside an if_block. I'm watching this with curiosity, because return is a language construct, and not a function, or anything that has a value. You can have: ... OR $error = Oh dear; But the say I see it, eventually, somewhere in your code you need to test for it. Essentially you're just moving the test somewhere else. Essentially, I'm creating warning reports for my users, not code errors. The users can then email the warnings to our webmaster. Here's what I ended up with: @$host_link= mysql_connect($host, $user, $pw) OR $values['msg']= $values['msg'] . Could not connect to mySQL host ; if($host_link){ $db_link= mysql_select_db($db, $host_link) OR $values['msg']= $values['msg'] . Could not connect to mySQL DB: $db; } if($host_link AND $db_link){ $result = mysql_db_query($db,select count(*) from $table) OR $values['msg']= $values['msg'] . Could not connect to mySQL Table: $table; } if($host_link AND $db_link AND $result){ $values['num_records'] = ($result0) ? mysql_result($result,0,0) : 0; }//end if return $values; //tech notes and db table stuff The calling page echoes $values['msg'] in nice red text. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
Al wrote: Essentially, I'm creating warning reports for my users, not code errors. The users can then email the warnings to our webmaster. Jason Wong wrote: On Monday 06 December 2004 14:19, Rory Browne wrote: $result = mysql_db_query($db,select count(*) from $table) OR $values['msg']= $values['msg'] . Could not connect to mySQL Table: $table; //tech notes and db table stuff The calling page echoes $values['msg'] in nice red text. Here's what's wrong with this plan: #1. You are exposing the fact that you use MySQL to users. So malicous users don't need to figure out that you are using MySQL: They can just start trying all the MySQL things to break into your server. As a general rule, you do not want users to know what software/version you are running. While this does fall into the security by obscurity category, which is generally not good there are compelling arguments for making it harder for the bad guys to figure out what software you are using. #2. They won't. Oh, sorry. The USERS will *NOT* email your message to the webmaster. Oh, some will. Most, however, will email your webmaster with oh-so-usefull messages like. I was on your website, and I got an error message, and it's broken. HELP! Put the details you need to debug your software in a place where you webmaster can read them, no matter what the user does to mangle, shorten, or otherwise ruin the message. http://php.net/error_log is good for this. #3. It's just Bad Form to tell users a bunch of crap they don't understand, don't care about, and can only be puzzled by. The message the users see should be more like: Website down for maintenance. Please try again later. The error messages you need to FIX the site are in the Apache log (or your own logfile) where they belong. There might be some exceptions to all this -- If you have only one or two admin people, whom you trust to actually copy paste the error messages and send them to you, displaying them on those admin screens is not so bad. That user is probably your client who already knows what software is in use (or can find out easily) and isn't likely to sabotage their own site, and can maybe be trained to do the right thing... OTOH, logging to a file and giving them a message they understand (Something broke. Call Rich and tell him what you were doing.) is probably better anyway. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
Richard Lynch wrote: Al wrote: Essentially, I'm creating warning reports for my users, not code errors. The users can then email the warnings to our webmaster. Jason Wong wrote: On Monday 06 December 2004 14:19, Rory Browne wrote: $result = mysql_db_query($db,select count(*) from $table) OR $values['msg']= $values['msg'] . Could not connect to mySQL Table: $table; //tech notes and db table stuff The calling page echoes $values['msg'] in nice red text. Here's what's wrong with this plan: #1. You are exposing the fact that you use MySQL to users. So malicous users don't need to figure out that you are using MySQL: They can just start trying all the MySQL things to break into your server. As a general rule, you do not want users to know what software/version you are running. While this does fall into the security by obscurity category, which is generally not good there are compelling arguments for making it harder for the bad guys to figure out what software you are using. #2. They won't. Oh, sorry. The USERS will *NOT* email your message to the webmaster. Oh, some will. Most, however, will email your webmaster with oh-so-usefull messages like. I was on your website, and I got an error message, and it's broken. HELP! Put the details you need to debug your software in a place where you webmaster can read them, no matter what the user does to mangle, shorten, or otherwise ruin the message. http://php.net/error_log is good for this. #3. It's just Bad Form to tell users a bunch of crap they don't understand, don't care about, and can only be puzzled by. The message the users see should be more like: Website down for maintenance. Please try again later. The error messages you need to FIX the site are in the Apache log (or your own logfile) where they belong. There might be some exceptions to all this -- If you have only one or two admin people, whom you trust to actually copy paste the error messages and send them to you, displaying them on those admin screens is not so bad. That user is probably your client who already knows what software is in use (or can find out easily) and isn't likely to sabotage their own site, and can maybe be trained to do the right thing... OTOH, logging to a file and giving them a message they understand (Something broke. Call Rich and tell him what you were doing.) is probably better anyway. I greatly appreciate your taking an interest in my question. I didn't explain all the details since I was trying to keep my message short. My users are not public. They are a few selected individuals who only have access via an Apache authentication dialog. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding Question
I've searched the PHP manual and can't find an answer for this question I'd like to use the OR DIE construct; but instead of DIE I'd like to use RETURN FOO. I haven't found a way to do it. $string= file_get_contents($filename) OR die(Could not read file); $db_link= mysql_connect($host, $user, $pw) OR die(Could not connect: . mysql_error()); Seems like it would be nice to not have to test first, e.g., if(is_readable($filename)){ } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
snip $db_link= mysql_connect($host, $user, $pw) OR die(Could not connect: . mysql_error()); /snip try: $db_link= mysql_connect($host, $user, $pw); if (!$db_link){ // do whatever if there is something wrong } maybe try something like that with the file_get_contents also? Respectfully, Ligaya Turmelle --- Life is a game... so have fun. --- www.PHPCommunity.org Open Source, Open Community Visit for more information or to join the movement Al wrote: I've searched the PHP manual and can't find an answer for this question I'd like to use the OR DIE construct; but instead of DIE I'd like to use RETURN FOO. I haven't found a way to do it. $string= file_get_contents($filename) OR die(Could not read file); $db_link= mysql_connect($host, $user, $pw) OR die(Could not connect: . mysql_error()); Seems like it would be nice to not have to test first, e.g., if(is_readable($filename)){ } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
If I'm not mistaken Al wanted to return something if the thing failed, without having to put it inside an if_block. I'm watching this with curiosity, because return is a language construct, and not a function, or anything that has a value. I could probably have said that better sober, and not at 06:16am, but hopefully you get my drift. On Mon, 06 Dec 2004 09:11:26 +1000, Ligaya Turmelle [EMAIL PROTECTED] wrote: snip $db_link= mysql_connect($host, $user, $pw) OR die(Could not connect: . mysql_error()); /snip try: $db_link= mysql_connect($host, $user, $pw); if (!$db_link){ // do whatever if there is something wrong } maybe try something like that with the file_get_contents also? Respectfully, Ligaya Turmelle --- Life is a game... so have fun. --- www.PHPCommunity.org Open Source, Open Community Visit for more information or to join the movement Al wrote: I've searched the PHP manual and can't find an answer for this question I'd like to use the OR DIE construct; but instead of DIE I'd like to use RETURN FOO. I haven't found a way to do it. $string= file_get_contents($filename) OR die(Could not read file); $db_link= mysql_connect($host, $user, $pw) OR die(Could not connect: . mysql_error()); Seems like it would be nice to not have to test first, e.g., if(is_readable($filename)){ } Thanks -- 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] Coding Question
On Monday 06 December 2004 14:19, Rory Browne wrote: If I'm not mistaken Al wanted to return something if the thing failed, without having to put it inside an if_block. I'm watching this with curiosity, because return is a language construct, and not a function, or anything that has a value. You can have: ... OR $error = Oh dear; But the say I see it, eventually, somewhere in your code you need to test for it. Essentially you're just moving the test somewhere else. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* There's a whole WORLD in a mud puddle! -- Doug Clifford */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Blues - Parse Error
Hello Yusuf, ? Class fl_SQL { var $server; var $user; var $pass; var $connection; var $db; var $query; var $record; var $tlist; } The bracket is wrong. Your class only has properties but no methods. Function fl_SQL($server, $user, $pass, $db = NULL) { $this-server = $server; $this-user = $user; $this-pass = $pass; $this-db = $db; } Function doconnect($db = $this-db){ $this-db = $db Missing ; $this-connection = mysql_connect($this-server, $this-user, $this-pass); if (!$this-connect) die (Could not connect to server!); $this-connect??? Do you mean $this-connection? mysql_select_db($this-db,$this-connection) or die (Could not connect to database!); } Function doquery($query, $db = $this-db){ $this-db = $db Missing ; $this-connect($this-db); Do you mean $this-doconnect? $this-query = $query mysql_query($this-query,$this-connect) And again: Do you mean $this-connection? } } Their is the right bracket for the class definition. ? Also your default-values for the method-parameters have to be constant. So ... try it like in your constructor. And check it with an if-statement. And also ... check the names of your properties and methods. It looks like there is a big mess. So long, Oliver -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding Blues - Parse Error
Hello. I am writing some code, but though everything seems ok, I get the same error: parse error, unexpected T_VARIABLE on line 23 . Here is the code: ? Class fl_SQL { var $server; var $user; var $pass; var $connection; var $db; var $query; var $record; var $tlist; } Function fl_SQL($server, $user, $pass, $db = NULL) { $this-server = $server; $this-user = $user; $this-pass = $pass; $this-db = $db; } Function doconnect($db = $this-db){ $this-db = $db $this-connection = mysql_connect($this-server, $this-user, $this-pass); if (!$this-connect) die (Could not connect to server!); mysql_select_db($this-db,$this-connection) or die (Could not connect to database!); } Function doquery($query, $db = $this-db){ $this-db = $db $this-connect($this-db); $this-query = $query mysql_query($this-query,$this-connect) } } ? Can anyone please help me? Thanking you in anticipation, Yusuf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Coding Blues - Parse Error
Hi, You don't have a ; at the end of the line. You have $this-db = $db and you should have $db;. -Dan Joseph -Original Message- From: Yusuf [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 15, 2004 11:19 PM To: [EMAIL PROTECTED] Subject: [PHP] Coding Blues - Parse Error Hello. I am writing some code, but though everything seems ok, I get the same error: parse error, unexpected T_VARIABLE on line 23 . Here is the code: ? Class fl_SQL { var $server; var $user; var $pass; var $connection; var $db; var $query; var $record; var $tlist; } Function fl_SQL($server, $user, $pass, $db = NULL) { $this-server = $server; $this-user = $user; $this-pass = $pass; $this-db = $db; } Function doconnect($db = $this-db){ $this-db = $db $this-connection = mysql_connect($this-server, $this-user, $this-pass); if (!$this-connect) die (Could not connect to server!); mysql_select_db($this-db,$this-connection) or die (Could not connect to database!); } Function doquery($query, $db = $this-db){ $this-db = $db $this-connect($this-db); $this-query = $query mysql_query($this-query,$this-connect) } } ? Can anyone please help me? Thanking you in anticipation, Yusuf -- 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] Coding Blues - Parse Error
Dan Joseph wrote: You don't have a ; at the end of the line. You have $this-db = $db and you should have $db;. Also, this: Function doquery($query, $db = $this-db){ is causing your error. The default value must be a constant expression, not a variable, function, method, etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php coding software
Oliver John V. Tibi wrote: in addition to brad's post, does anyone know of coding software that supports team development environments and/or a versioning server for windows? I use Zend Studio wich provides CVS integration. But I'm sure you will find some others with CVS support. If not, I will recommend you to get WinCVS wich provides a nice and easy-to-use CVS interface. (And you can get CVSnt for a Windows based CVS server). Regards. Jordi Canals -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php coding software
Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o
Re: [PHP] php coding software
On Mon, 2 Aug 2004 09:26:18 -0500, Brad Ciszewski [EMAIL PROTECTED] wrote: Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o I have never tried it but there is dreamweaver extensions: http://www.interaktonline.com/products/PHAkt/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php coding software
Brad Ciszewski wrote: Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o quote from Newbie Guide For example: One of the repeatedly discussed question in the list is Best PHP editor. Everyone has his/her favourite editor. You can get all the opinions by going through the list archives. If you want a chosen list try this link : http://www.thelinuxconsultancy.co.uk/phpeditors/ /quote -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php coding software
php expert editor VERY nice look it up at http://www.ankord.com/ $35 though but worth it. On Mon, 2 Aug 2004 09:26:18 -0500, Brad Ciszewski [EMAIL PROTECTED] wrote: Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php coding software
Brad Ciszewski wrote: Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o Sorry, but you're wrong. Dreamweaver DOES have MySQL support and can connect to MySQL databases to help coding your scripts. BTW, I use Zend Studio, and If I'm not wrong, they have a personal edition for free. Regards. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php coding software
Jordi Canals wrote: Brad Ciszewski wrote: Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o Sorry, but you're wrong. Dreamweaver DOES have MySQL support and can connect to MySQL databases to help coding your scripts. Yes. PHP and MySQL is supported in DWMX, no extensions required. FTPEdit and HTMLKit are both free editors for Windows Quanta and Bluefish are excellent on GNU/Linux -- Chris Martin Web Developer Open Source Web Standards Advocate http://www.chriscodes.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php coding software
Brad I use HTML-Kit for HTML, ASP, Java, CSS, PHP and MySQL. Free too :) -- - Michael Mason Arras People www.arraspeople.co.uk - Brad Ciszewski [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: php coding software
For what it's worth, I use HTML-Kit as well. Feature I like best is the ability to seamlessly edit content of remote sites and local (folder based) sites. Warren Vail -Original Message- From: Harlequin [mailto:[EMAIL PROTECTED] Sent: Monday, August 02, 2004 5:15 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: php coding software Brad I use HTML-Kit for HTML, ASP, Java, CSS, PHP and MySQL. Free too :) -- - Michael Mason Arras People www.arraspeople.co.uk - Brad Ciszewski [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Does anyone know any good software for PHP/mysql coding? I currently use DreamWeaver MX, however it doesn't have much PHP support, and no MySQL support. I just want an easy program to script in, and upload on to my webserver. Please help! :o -- 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
[PHP] Re: php coding software
in addition to brad's post, does anyone know of coding software that supports team development environments and/or a versioning server for windows? TIA! -- Running 'ojtibi' on '127.0.0.1' (BATCH_OPTIMISTIC mode). Live free() or die(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding Advice
Hello, I am writing an app and right now im working on code that will display x number of items on one page, and if there is overflow, provide a link to the next. The url coming into the page looks something like: projects.php?action=viewcompleted=nostart=0 My code so far, i just took the $_SERVER['REQUEST_URI'] and added start=newstart to the end. The problem is, i will eventually get a string thats very long, ebcause start keeps appending onto the end. What is the easiest way to preserve projects.php?action=viewcompleted=no and be able to add start=somenumber to the end? Thanks for your assistance. -- Aaron Axelsen aim: aaak2 email: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Advice
I am writing an app and right now im working on code that will display x number of items on one page, and if there is overflow, provide a link to the next. The url coming into the page looks something like: projects.php?action=viewcompleted=nostart=0 My code so far, i just took the $_SERVER['REQUEST_URI'] and added start=newstart to the end. The problem is, i will eventually get a string thats very long, ebcause start keeps appending onto the end. What is the easiest way to preserve projects.php?action=viewcompleted=no and be able to add start=somenumber to the end? if you only need to pass 2 other variables, why not just build the query string from scratch each time? you could always do a string replacement on start=whatever instead of just appending it to the end each time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding productivity benchmarks?
I've been searching around for productivity benchmarks for PHP programming. The only references I can find for it are in for-pay publications. I've ended up becoming a PHP developer more out of happenstance than anything. I've been doing it for a couple of years now, but... I don't really know how 'good' I am at it. The place I work has always had extremely unreasonable expectations for worker productivity, and I'm trying to fight that. I've recently been called into another job interview, and part of the interview is a coding assignment. Some of the documentation suggests that this assignment should take about 40 minutes. A rough overview of the 'assignment' - a simple Document Management System - is: * new user registration and existing user login * admin-level user management * document upload and download * review and suggestion * a conditional matrix of 5 document conditions vs 3 user levels * 6 input forms * 2 listing layouts with fix sorting * conditional access to changing document conditions based on user levels It took me about 4 hours to completely satisfy and debug the assignment specs with an OK interface. This was with plenty of code copy/modification from other web apps I've done before, or other online resources. I ended up spending nearly 4 more hours futzing around with the interface to get something really nice. So, am I just a pretender? Are there people out there that can really bust out a basic DMS in 40 minutes? If anyone does have some basic PHP programmer productivity benchmarks, or knows where I can get ahold of them, I'd sure appreciate it. This issue of productivity expectations has really gotten under my skin, and I need to know whether or not I should be doing this for a living. Thanks, -Derrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding productivity benchmarks?
Hello Derrick, Monday, June 7, 2004, 3:51:20 PM, you wrote: Df So, am I just a pretender? Are there people out there that can really Df bust out a basic DMS in 40 minutes? I would say that there probably are - but you'd have to question how robust and well designed their system would be after those 40 minutes are up. Assuming you weren't allowed to use any external help by way of PEAR/Smarty/ADOdb/etc then I would have said that building a friendly system that met all of those criteria in 4 hours is nothing to be ashamed of. I'm sorry I don't have any benchmarks for you, but I'd love to know how anyone could ever create an accurate benchmark for something as subjective as this anyway. Having worked with PHP for years and interviewed many people, I would have to say what you were required to do was quite un-usual and ill thought-out. If they had given you 40 mins to write a document telling how you would approach the system - that would have been more like it. This reminded me of an incident where a company local to me was holding interviews and getting the applicants to actually work on sites they needed finishing off (basic html stuff) as part of the interview! Never gave them the job of course, just got them to finish the projects. Needless to say, they aren't trading any longer :) Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding productivity benchmarks?
Nothing in the specs you listed mentioned anything about a pretty, intuitive GUI interface. Drop a nice interface requirement and that cuts your time considerably. Forget trying to design an event driven interface and drop back on the old mainframe menu driven interface with one option per screen. Then you just need to design some generic code that spits out some fields with labels and a continue/save or cancel button. Tests like these are usually looking more for coding talent and technique (i.e. code reuse, object orientation, readability, MVC, etc.) rather than interface design talent. They're most likely trying to separate the web front end people from the back end people. On Jun 7, 2004, at 10:51 AM, Derrick fogle wrote: I've been searching around for productivity benchmarks for PHP programming. The only references I can find for it are in for-pay publications. I've ended up becoming a PHP developer more out of happenstance than anything. I've been doing it for a couple of years now, but... I don't really know how 'good' I am at it. The place I work has always had extremely unreasonable expectations for worker productivity, and I'm trying to fight that. I've recently been called into another job interview, and part of the interview is a coding assignment. Some of the documentation suggests that this assignment should take about 40 minutes. A rough overview of the 'assignment' - a simple Document Management System - is: * new user registration and existing user login * admin-level user management * document upload and download * review and suggestion * a conditional matrix of 5 document conditions vs 3 user levels * 6 input forms * 2 listing layouts with fix sorting * conditional access to changing document conditions based on user levels It took me about 4 hours to completely satisfy and debug the assignment specs with an OK interface. This was with plenty of code copy/modification from other web apps I've done before, or other online resources. I ended up spending nearly 4 more hours futzing around with the interface to get something really nice. So, am I just a pretender? Are there people out there that can really bust out a basic DMS in 40 minutes? If anyone does have some basic PHP programmer productivity benchmarks, or knows where I can get ahold of them, I'd sure appreciate it. This issue of productivity expectations has really gotten under my skin, and I need to know whether or not I should be doing this for a living. Thanks, -Derrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Coding productivity benchmarks?
hey, I just did all of that and it took me 1 hour and 35 mins, but I edited the code that i had already made from site before. It didn't take my anywhere near 4 hours, but there is no way i could do it in 40 mins. From: Derrick fogle [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: [PHP] Coding productivity benchmarks? Date: Mon, 7 Jun 2004 09:51:20 -0500 I've been searching around for productivity benchmarks for PHP programming. The only references I can find for it are in for-pay publications. I've ended up becoming a PHP developer more out of happenstance than anything. I've been doing it for a couple of years now, but... I don't really know how 'good' I am at it. The place I work has always had extremely unreasonable expectations for worker productivity, and I'm trying to fight that. I've recently been called into another job interview, and part of the interview is a coding assignment. Some of the documentation suggests that this assignment should take about 40 minutes. A rough overview of the 'assignment' - a simple Document Management System - is: * new user registration and existing user login * admin-level user management * document upload and download * review and suggestion * a conditional matrix of 5 document conditions vs 3 user levels * 6 input forms * 2 listing layouts with fix sorting * conditional access to changing document conditions based on user levels It took me about 4 hours to completely satisfy and debug the assignment specs with an OK interface. This was with plenty of code copy/modification from other web apps I've done before, or other online resources. I ended up spending nearly 4 more hours futzing around with the interface to get something really nice. So, am I just a pretender? Are there people out there that can really bust out a basic DMS in 40 minutes? If anyone does have some basic PHP programmer productivity benchmarks, or knows where I can get ahold of them, I'd sure appreciate it. This issue of productivity expectations has really gotten under my skin, and I need to know whether or not I should be doing this for a living. Thanks, -Derrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ MSN Toolbar provides one-click access to Hotmail from any Web page FREE download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding productivity benchmarks?
On Jun 7, 2004, at 11:39 AM, Tyler Replogle wrote: I just did all of that and it took me 1 hour and 35 mins Just for grins and giggles, why don't I post the exact assignment specs? FYI, I've never really had to deal with file uploads and downloads before. It probably took me to an hour to research PHP file upload/download/MySQL storage, and get that part working. I could do it much faster next time ;-) As for the layout issue, I suppose that's my big 'weak point' as a developer. The templates I started from have a basic interface structure already, so I went ahead and developed the code and the basic interface together. That took extra time beyond just puking out the bare minimum. I've spent so many years doing database development for customers that I view the real functionality of an application by how the interface looks and acts more than how the underlying code is written. I just can't see the forest for the trees, and I can't see a functional web app without an interface that matches the workflow. Anyway, here's the actual assignment specs: XXX Company is publishing an on-line journal and needs to provide a system for electronic manuscript management with the following features: 1. All submitted documents should be able to be uploaded and downloaded in word format. 2.There should be 3 user roles: Author, Reviewer and Editor 3.There should be a way for a new user to register as either one of the 3 roles. During registration, the new user should be able to enter first and last name, e-mail address and what kind of user he wishes to be (author, reviewer or editor). 4.When a user logs in to the system, he should be presented with a screen, depending on what role he has in the system. a.As an editor, the user should be able to delete a user, change registration information of any user, view the status of each submitted article, view reviewer suggestions, accept or decline an article for publication, or assign it to a reviewer for review. b.As a reviewer, the user should be able to download a submitted article to review and recommend the article for publication or not. c.As an author, the user should be able to submit a file. 5.An article can have one of these states: a.Submitted (after submission) b.In review (after reviewers are assigned) c.Accepted (if accepted by the editor) d.Declined (if declined by the editor) 6. A typical workflow should consist of the following states: a.An author submits an article. The article status becomes submitted. The editor may view the article (by downloading it) or assign it to a reviewer. b.An editor assigns an article to a reviewer. The article status becomes in review. The reviewer may now download the article and he may also suggest accepting it or declining it. c.A reviewer makes a suggestion. The article status remains in review. The editor may now view the suggestion of the reviewer and he may also accept or decline the article. d.An editor accepts or declines an article. The article status becomes accepted or declined accordingly. Thanks, -Derrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
On 02/06/2004, at 3:00 AM, Justin Patrin wrote: And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing when you put it after. IMHO it's just not necessary as ALL blocks should have braces, even those that are one-line. If you always use the braces, you can looks for indenting as the open of the block and the end-brace (and un-indenting) as the close of the block. I used to be a big fan of both versions, but honestly, I didn't care, as long as an app was consistent, so that one could become comfortable with it over time. The reality is that good editors like BBEdit can help match braces, highlight code blocks, etc. But recently, I've changed my tactic to whatever helps the code be as readable and clear as possible... $file = 'a'; if(file_exists($file)) { include($file); } $file = 'b'; if(file_exists($file)) { include($file); } $file = 'c'; if(file_exists($file)) { include($file); } else { include('x'); } $file = 'd'; if(file_exists($file)) { include($file); } else { include('x'); } $file = 'e'; if(file_exists($file)) { include($file); } is a lot clearer,line-efficient and faster to comprehend than... $file = 'a'; if (file_exists($file)) { include($file); } $file = 'b'; if (file_exists($file)) { include($file); } $file = 'c'; if (file_exists($file)) { include($file); } else { include('x'); } $file = 'd'; if (file_exists($file)) { include($file); } else { include('x'); } $file = 'e'; if (file_exists($file)) { include($file); } Of course, looping through an array of file names would be even clearer, but you get my point :) --- Justin French http://indent.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
On 31-May-2004 Travis Low wrote: I have to say I like everything about the PEAR coding standards except for the KR bracing style. I much prefer: if( foo ) { blah; } Icky. So ... Vee-Eye or Eighty Megs and Constantly Swapping ? ;- -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Travis Low wrote: I have to say I like everything about the PEAR coding standards except for the KR bracing style. I much prefer: if( foo ) { blah; } to if( foo ) { blah; } The latter form (KR) conserves vertical space, but I find it a lot harder to follow. Harder to move blocks of code around too. I'm sure plenty of people disagree, so of course this is IMHO. And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing when you put it after. IMHO it's just not necessary as ALL blocks should have braces, even those that are one-line. If you always use the braces, you can looks for indenting as the open of the block and the end-brace (and un-indenting) as the close of the block. cheers, Travis Michael Nolan wrote: charles kline wrote: Hi all, I was having a conversation with a friend and talking about coding standards in the open source community (focusing on PHP). I seem to remember there being a document out there that sort of laid it out pretty well. Anyone know where I might find a copy? PEAR has a page in their documentation about coding standards: http://pear.php.net/manual/en/standards.php HTH, Mike -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Justin Patrin wrote: Travis Low wrote: [I hate KR indenting] And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing... Arrggghh...TABS. Don't even get me started on tabs... cheers, Travis -- Travis Low mailto:[EMAIL PROTECTED] http://www.dawnstar.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php