Re: [PHP] html forms and php
Philippe, I recommend using an ID, instead of the NAME attribute to refer to the various elements. This ought to solve your problem. David Philippe Reynolds wrote: Greetings all, Currently I have a form that has two lists that contain options. I use javacript to dynamically move options from one select list to another. All this works fine... this is the select: select name=trucklist size=12 style=width: 150px multiple option value=LT680LT680/option option value=LT685LT685/option option value=LT690LT690/option option value=LT695LT695/option option value=LT700LT700/option option value=LT705LT705/option /select Now I wish to post all the options from one list to another page. So I select all the options in that list and hit the submit button. Obviously, a select list, will return each value with the same name to the second web page. Therefore we can only capture the last option posted. To resolve this we have to create an array out of our select name: select name=trucklist[] size=12 style=width: 150px multiple I added the square brakets to the name...now when I select all the options on the list I can read all values individually. Here is problem...my javascripts have stopped working, I can't move options from one list to the next. Here is the javascript I use currently...I would like help in modifing it so that it may work while using the brakets on the name of the select: Thanks a bunch for the help!! Always appreciated First the two list that transmit the options back and forth: (javascript below) select name=trucklist size=12 style=width: 150px multiple option value=LT680LT680/option option value=LT685LT685/option option value=LT690LT690/option option value=LT695LT695/option option value=LT700LT700/option option value=LT705LT705/option /select /td td input type=button name=SelectAll value= All style=width: 100px; onClick=MoveAll(fleetForm.trucklist, fleetForm.reportinglist)br input type=button name=Select value= style=width: 100px; onClick=Move(fleetForm.trucklist, fleetForm.reportinglist)brbr input type=button name=Unselect value= style=width: 100px; onClick=Move(fleetForm.reportinglist, fleetForm.trucklist)br input type=button name=UnselectAll value= All style=width: 100px; onClick=MoveAll(fleetForm.reportinglist, fleetForm.trucklist) /td td select name=reportinglist[] size=12 style=width: 150px multiple here is the javascript: function Move(fromList, toList){ var tempArray = new Array(); var x = 0; //looping through source element to find selected options for (var i = 0; i fromList.length; i++) { if (fromList.options[i].selected) { //need to move this option to the 'to' list var selectionLen = toList.length++; toList.options[selectionLen].text = fromList.options[i].text; toList.options[selectionLen].value = fromList.options[i].value; } else { //storing options that stay to recreate selected trucks var tempValues = new Object(); tempValues.text = fromList.options[i].text; tempValues.value = fromList.options[i].value; tempArray[y] = tempValues; y++; } } //resetting length of 'from' list fromList.length = tempArray.length; //looping through temp array to recreate intial selection for (var i = 0; i tempArray.length; i++) { fromList.options[i].text = tempArray[i].text; fromList.options[i].value = tempArray[i].value; fromList.options[i].selected = false; } } function MoveAll(from, to){ selectAll(from); Move(from, to); } function selectAll(trucklist) { if (!hasTruck(trucklist)) { return; } for (var i=0; itrucklist.options.length; i++) trucklist.options[i].selected = true; } -- David Grant http://www.grant.org.uk/ http://pear.php.net/package/File_Ogg0.2.1 http://pear.php.net/package/File_XSPF 0.1.0 WANTED: Junior PHP Developer in Bristol, UK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html forms and php
On 31 Jan 2006, at 16:07, Philippe Reynolds wrote: To resolve this we have to create an array out of our select name: select name=trucklist[] size=12 style=width: 150px multiple I added the square brakets to the name...now when I select all the options on the list I can read all values individually. Here is problem...my javascripts have stopped working, I can't move options from one list to the next. Here is the javascript I use currently...I would like help in modifing it so that it may work while using the brakets on the name of the select: Keep the trucklist[] as the select list NAME. This will allow PHP to work. Add an ID to the select list: select id=trucklist name=trucklist[] size=12 style=width: 150px multiple Now modify your JavaScript to use this ID instead of the form element name when moving. function Move(fromListID, toListID) { fromList = document.getElementById(fromListID); toList = document.getElementById(toListID); etc etc You can now access the fromList select list in the usual way. Cheers, Rich -- http://www.corephp.co.uk Zend Certified Engineer PHP Development Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html forms and php
Awesome...that solved it!! Thanks a bunch to everyone who contributed!! Cheers Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] html forms and php
On 31 January 2006 16:08, Philippe Reynolds wrote: I added the square brakets to the name...now when I select all the options on the list I can read all values individually. Here is problem...my javascripts have stopped working, I can't move options from one list to the next. Here is the javascript I use currently...I would like help in modifing it so that it may work while using the brakets on the name of the select: Use the Javascript identity of x.y with x[y], thusly: input type=button name=SelectAll value= All style=width: 100px; onClick=MoveAll(fleetForm.trucklist, fleetForm.reportinglist)br onclick=MoveAll(fleetForm['trucklist[]'], fleetForm['reportinglist[]']) No need to mess about with the complications of DOM and getElementById -- it's much more backward compatible for older browsers, as well, since that identity has existed since day one of JavaScript. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html forms in php
I HATE Are you sure? prompts. If I wasn't sure, I wouldn't have clicked it in the first place. If you want to make your users happy, trust them when they say Delete, but make it easy to undo. Instead of deleting the records, just set the Delete flag and timestamp. Then when the odd user makes a mistake, just unset that flag. After a period of time, you can really delete the records that were marked a few days ago. Thanks for that comment Scott, it helps me a lot to see what I didn't. I've been developing with Are you sure? confirmation and it really makes things difficult to users and slow actions' time to be committed. Now, I've changed and all is more nice. Thanks again, feel this is a very good practice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html forms in php
Are you sure? and then a yes and no buttons to confirm the deletion or to cancel the command. Any thougts?? While some of the others here have answered your technical question, I'd like to state my opinion on usability. I HATE Are you sure? prompts. If I wasn't sure, I wouldn't have clicked it in the first place. If you want to make your users happy, trust them when they say Delete, but make it easy to undo. Instead of deleting the records, just set the Delete flag and timestamp. Then when the odd user makes a mistake, just unset that flag. After a period of time, you can really delete the records that were marked a few days ago. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] html forms in php
[snip] Are you sure? and then a yes and no buttons to confirm the deletion or to cancel the command. Any thougts?? [/snip] You can use JavaScript for this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] html forms in php
philippe, you can accomplish this by using a piece of javascript that fires off an alert, asking the user 'yes/no'. if the user selected yes, the app would do a submit to the page that would then take care of the mysql/db interaction... search on google for 'php onsubmit alert' etc... -bruce -Original Message- From: Philippe Reynolds [mailto:[EMAIL PROTECTED] Sent: Thursday, September 15, 2005 11:14 AM To: php-general@lists.php.net Subject: [PHP] html forms in php Good day all, I have a problem for you all.. I have a form that has has the ability to delete a lot of information from my MySQL database. I would like to create a bit of security, in case the user hits the button by accident. I would like to create an additionnal window that would appear that would ask: Are you sure? and then a yes and no buttons to confirm the deletion or to cancel the command. Any thougts?? Thanks for the assistance Phil -- 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] html forms in php
Good day all, I have a problem for you all.. I have a form that has has the ability to delete a lot of information from my MySQL database. I would like to create a bit of security, in case the user hits the button by accident. I would like to create an additionnal window that would appear that would ask: Are you sure? and then a yes and no buttons to confirm the deletion or to cancel the command. Any thougts?? Hi Phil, You can achieve this in several ways. One would be to use a JavaScript onClick event on the 'dangerous' button to pop up a dialog with your 'Are you sure?' prompt and the yes/no buttons. If the user clicks on the 'no' button, you use JavaScript to cancel the page submission. If they click on the 'yes' button, the page submits. This approach would mean assuming that your users have JavaScript enabled. A second approach would be to have an intermediary page between the page with the button, and the page that performs the actual delete. The intermediary page would be little more than another form with the yes/no buttons. Much warmth, Murray --- Lost in thought... http://www.planetthoughtful.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] html forms in php
This might help you. input type=submit name=DELETE onclick=return confirmDelete() script function confirmDelete() { var agree=confirm(WARNING! This will blah blah delete etc yada yada \n\rPress Cancel to go back, or OK to Continue.); if (agree) return true ; else return false ; } /script -Original Message- From: Murray @ PlanetThoughtful [mailto:[EMAIL PROTECTED] Sent: Thursday, September 15, 2005 12:32 PM To: 'Philippe Reynolds'; php-general@lists.php.net Subject: RE: [PHP] html forms in php Good day all, I have a problem for you all.. I have a form that has has the ability to delete a lot of information from my MySQL database. I would like to create a bit of security, in case the user hits the button by accident. I would like to create an additionnal window that would appear that would ask: Are you sure? and then a yes and no buttons to confirm the deletion or to cancel the command. Any thougts?? Hi Phil, You can achieve this in several ways. One would be to use a JavaScript onClick event on the 'dangerous' button to pop up a dialog with your 'Are you sure?' prompt and the yes/no buttons. If the user clicks on the 'no' button, you use JavaScript to cancel the page submission. If they click on the 'yes' button, the page submits. This approach would mean assuming that your users have JavaScript enabled. A second approach would be to have an intermediary page between the page with the button, and the page that performs the actual delete. The intermediary page would be little more than another form with the yes/no buttons. Much warmth, Murray --- Lost in thought... http://www.planetthoughtful.org -- 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] html forms in php
Here's some javascript I use for such instances: [CODE] if (myForm.hidWhich.value == delete) { var verify = prompt(You are about to delete this entry \n + \n \n + To delete this entry you must type this phrase in the prompt and click OK: \n \n + -- KILL ENTRY!); if (verify == KILL ENTRY!) { myForm.submit(); return(true); } else { alert(Error: Could not delete entry becuase you either canceled out or entered the wrong phrase! \n + Your entry WAS NOT deleted.); return(false); } } [/CODE] The user must click a button to delete the entry. This button calls as function onClick; within that function is the above code. It requires the user to enter an exact phrase. If the exact phrase is not entered, it is returned false and the form never submits. If the correct phrase is entered, it sumbits the form and I remove the entry from Postgresql. So far I have not had any users accidentally delete anything. The only problem is IE does not like the prompt() function -works perfect in FireFox. In IE it doesn't display the text in the prompt window, but if the correct phrase is entered it still works Philippe Reynolds wrote: Good day all, I have a problem for you all.. I have a form that has has the ability to delete a lot of information from my MySQL database. I would like to create a bit of security, in case the user hits the button by accident. I would like to create an additionnal window that would appear that would ask: Are you sure? and then a yes and no buttons to confirm the deletion or to cancel the command. Any thougts?? Thanks for the assistance Phil -- D. Aaron Germ Scarborough Library, Shepherd University (304) 876-5423 Well then what am I supposed to do with all my creative ideas- take a bath and wash myself with them? 'Cause that is what soap is for (Peter, Family Guy) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html hyperlink and PHP
You could have tried it in the time it took you to post... It's GET. On Thu, May 5, 2005 7:28 pm, Oscar Andersson said: If i do like this. a href=huvudsida.php?action=lista target=_self How does the webbrowser send this? With post or get or ..? Shall i get the action with $_POST or $_GET? ex. @$action = $_POST['action']; if(!$action) @$action = $_GET['action']; processRequest($action); If i do like this form action=huvudsida.php method=post INPUT TYPE=HIDDEN VALUE=lista NAME=action /form How do i get the action in my php page. I think it is with $action = $_POST['action']; but it doesent work. Tnx for any help mates -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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] html hyperlink and PHP
On 5/5/05, Oscar Andersson [EMAIL PROTECTED] wrote: If i do like this. a href=huvudsida.php?action=lista target=_self How does the webbrowser send this? With post or get or ..? get Shall i get the action with $_POST or $_GET? $_GET or $_REQUEST ex. @$action = $_POST['action']; if(!$action) @$action = $_GET['action']; processRequest($action); If i do like this form action=huvudsida.php method=post INPUT TYPE=HIDDEN VALUE=lista NAME=action /form How do i get the action in my php page. I think it is with $action = $_POST['action']; but it doesent work. Tnx for any help mates You can add something like this to see what is coming through when you post the form: echo 'pre'; print_r( $_REQUEST ); echo '/pre'; -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html hyperlink and PHP
Hi, On 5/6/05, Oscar Andersson [EMAIL PROTECTED] wrote: If i do like this. a href=huvudsida.php?action=lista target=_self if u do like above u might have to use $_GET['action'] How does the webbrowser send this? With post or get or ..? Shall i get the action with $_POST or $_GET? ex. @$action = $_POST['action']; if(!$action) @$action = $_GET['action']; processRequest($action); If i do like this form action=huvudsida.php method=post INPUT TYPE=HIDDEN VALUE=lista NAME=action if u use like above use $_POST['action'] /form How do i get the action in my php page. I think it is with $action = $_POST['action']; if u r not sure what to use, use $_REQUEST['action']; but it doesent work. Tnx for any help mates -- bala balachandar muruganantham blog lynx http://chandar.blogspot.com web http://www.chennaishopping.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML Frames and PHP Sessions
Nick Patsaros wrote: Are PHP sessions compatible with frames in HTML? I'm trying to pass a user name through a session and my individual frames aren't receiving the variable. It worked prior to migrating to frames so I don't think it's my PHP that is the problem. Is there a target function somehow or some way to pass it down from the _top frame to an individual frame or frames? Sessions work with frames. It has to be something else. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML tags inside PHP??
echo 'html title..'; cheers Binay - Original Message - From: SASSINC Internet Solutions - Arabic Department [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, January 17, 2004 3:31 PM Subject: [PHP] HTML tags inside PHP?? Hi all! How is everything? I'm want to insert some HTML tags inside the PHP page to echo them.. And then I will use MARKER to import them by VB program.. So now how to insert HTML tags to PHP? Waiting your replies.. Thanks alot for advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Html forms to php scripts
I have registered_globals on so this shouldn't matter, but: echo $_POST['ttt']; returns the same problem as simple echo $ttt; Here is my phpinfo(); http://psyche.govst.edu/test.php I'm in the process of upgrading to apache 2.0.45 and php 4.3.1, so maybe that will fix things as I have heard that 4.2.2 doesn't like apache2. Tim Van Zee ITS Network Specialist Governors State University -Original Message- From: Tim Burden [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 11:07 AM To: VanZee, Timothy Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Html forms to php scripts What version of Apache are you using? Can you point us to a phpinfo() file? - Original Message - From: Timothy Vanzee [EMAIL PROTECTED] Newsgroups: php.general To: [EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 11:31 AM Subject: FW: [PHP] Html forms to php scripts I have the following issue between my html forms and php scripts. Html file (input.html) looks like this: form action=input.php method=post input type=text name=ttt pinput type=submit name=submit value=Submit/p /form Php file (input.php) looks like this: ? echo $ttt; ? I can input text (i.e. superman) and then click submit. The resulting php page returns: supermanttt=superman It seems to me that it must be something in the php.ini file that needs to be changed, but I can't identify what exactly. Any help would be appreciated. php 4.2.2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Html forms to php scripts
Here are the results: Array ( [ttt] = javattt=java ) Array ( [ttt] = javattt=java ) Tim Van Zee ITS Network Specialist Governors State University [ snip ] Would be curiuos to see the the results of : echo pre; print_r($_REQUEST); echo/pre; echo pre; print_r($_POST); echo/pre; That might shed some light as to what is being sent and what isn't. -- Burhan Khalid phplist[at]meidomus[dot]com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Html forms to php scripts
I though we already covered that this was an PHP / Apache 2 bug?? Stop using Apache 2 with PHP. ---John Holmes... - Original Message - From: VanZee, Timothy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 04, 2003 11:01 AM Subject: RE: [PHP] Html forms to php scripts Here are the results: Array ( [ttt] = javattt=java ) Array ( [ttt] = javattt=java ) Tim Van Zee ITS Network Specialist Governors State University [ snip ] Would be curiuos to see the the results of : echo pre; print_r($_REQUEST); echo/pre; echo pre; print_r($_POST); echo/pre; That might shed some light as to what is being sent and what isn't. -- Burhan Khalid phplist[at]meidomus[dot]com -- 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] Html forms to php scripts
-Original Message- From: VanZee, Timothy [mailto:[EMAIL PROTECTED] Sent: 02 April 2003 17:31 Repost because no one replied originally. Are there any other lists that anyone knows of for php that could be more helpful? I'm quite disappointed in this one because I thought this was a fairly easy question for those who have been working with php for a while. I have the following issue between my html forms and php scripts. Html file (input.html) looks like this: form action=input.php method=post input type=text name=ttt pinput type=submit name=submit value=Submit/p /form Php file (input.php) looks like this: ? echo $ttt; ? I can input text (i.e. superman) and then click submit. The resulting php page returns: supermanttt=superman It seems to me that it must be something in the php.ini file that needs to be changed, but I can't identify what exactly. Any help would be appreciated. php 4.2.2 I'm pretty sure that this is an Apache 2 problem that's fixed in a later version of PHP and/or Apache. Try searching the bug database for more details. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Html forms to php scripts
What version of Apache are you using? Can you point us to a phpinfo() file? - Original Message - From: Timothy Vanzee [EMAIL PROTECTED] Newsgroups: php.general To: [EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 11:31 AM Subject: FW: [PHP] Html forms to php scripts Repost because no one replied originally. Are there any other lists that anyone knows of for php that could be more helpful? I'm quite disappointed in this one because I thought this was a fairly easy question for those who have been working with php for a while. I have the following issue between my html forms and php scripts. Html file (input.html) looks like this: form action=input.php method=post input type=text name=ttt pinput type=submit name=submit value=Submit/p /form Php file (input.php) looks like this: ? echo $ttt; ? I can input text (i.e. superman) and then click submit. The resulting php page returns: supermanttt=superman It seems to me that it must be something in the php.ini file that needs to be changed, but I can't identify what exactly. Any help would be appreciated. php 4.2.2 Tim Van Zee ITS Network Specialist Governors State University -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Html forms to php scripts
It's an Apache 2 / PHP bug. I think if you use $_POST['ttt'], you'll get the correct value, but I'm not sure. Try turning register globals off or using a stable version of Apache that works with PHP (the 1.3 series). ---John Holmes... - Original Message - From: VanZee, Timothy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 11:31 AM Subject: FW: [PHP] Html forms to php scripts Repost because no one replied originally. Are there any other lists that anyone knows of for php that could be more helpful? I'm quite disappointed in this one because I thought this was a fairly easy question for those who have been working with php for a while. I have the following issue between my html forms and php scripts. Html file (input.html) looks like this: form action=input.php method=post input type=text name=ttt pinput type=submit name=submit value=Submit/p /form Php file (input.php) looks like this: ? echo $ttt; ? I can input text (i.e. superman) and then click submit. The resulting php page returns: supermanttt=superman It seems to me that it must be something in the php.ini file that needs to be changed, but I can't identify what exactly. Any help would be appreciated. php 4.2.2 Tim Van Zee ITS Network Specialist Governors State University -- 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] Html forms to php scripts
Ford, Mike [LSS] wrote: -Original Message- From: VanZee, Timothy [mailto:[EMAIL PROTECTED] Sent: 02 April 2003 17:31 Repost because no one replied originally. Are there any other lists that anyone knows of for php that could be more helpful? I'm quite disappointed in this one because I thought this was a fairly easy question for those who have been working with php for a while. I have the following issue between my html forms and php scripts. Html file (input.html) looks like this: form action=input.php method=post input type=text name=ttt pinput type=submit name=submit value=Submit/p /form Php file (input.php) looks like this: ? echo $ttt; ? I can input text (i.e. superman) and then click submit. The resulting php page returns: supermanttt=superman It seems to me that it must be something in the php.ini file that needs to be changed, but I can't identify what exactly. Any help would be appreciated. php 4.2.2 registered_globals is off by default in your version of PHP (its in the release notes) so, try replacing your echo statement with echo $_POST['ttt']; and see if that helps. -- Burhan Khalid phplist[at]meidomus[dot]com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HTML if no PHP
Hi Bob, I want to display an HTML page if PHP can't load an include file or otherwise has an error or just doesn't work. How do I do this? Not sure you can, especially not for the just doesn't work scenario. FWIW, you can test for the existence of a file before including it: if (file_exists(file/to/be/included)) { include (file/to/be/included); } else { include (backup/plain/HTML/file); } but that doesn't cover all the bases you asked about. I'd certainly be interested to hear any solutions to this one :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML if no PHP
Quoting Bob Lockie [EMAIL PROTECTED]: ### ### I want to display an HTML page if PHP can't load an include file or ### otherwise has an error or just doesn't work. ### How do I do this? ### if (!$variable){print('your html stuff');} Kinda basic, but it might help. Cheers! VW ### ### -- ### ### Sent from Mozilla and GNU/Linux. ### Powered by an AMD processor. ### ### ### -- ### PHP General Mailing List (http://www.php.net/) ### To unsubscribe, visit: http://www.php.net/unsub.php ### ### -- Richard Whitney Transcend Development Producing the next phase of your internet presence. [EMAIL PROTECTED] http://xend.net 602-971-2791 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML if no PHP
if ( !@include ( myfile.php ) ) { // do this if file cannot be included ...code... ...code... } Bob Lockie wrote: I want to display an HTML page if PHP can't load an include file or otherwise has an error or just doesn't work. How do I do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML if no PHP
I want to display an HTML page if PHP can't load an include file or otherwise has an error or just doesn't work. How do I do this? include returns false on failure and here's a hack to demonstrate. Once you implement your own error handling, be sure to set error_reporting accordingly or supress with @. if (!include('foo.php')) { if (!include('static.html')) { print 'ut oh, this is serious.'; } } Be sure to read about PHP's error handling capabilities to do something more useful and/or create your own error handling functions/system. See also: http://www.php.net/trigger_error http://www.php.net/set_error_handler http://www.php.net/ref.errorfunc Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML if no PHP
1) Include file not found: if (file_exists($incfile)) include($incfile); else include ($error_html_file); 2) Error in file: global $php_errormsg; $php_errormsg = null; @include($incfile); $err = $php_errormsg; if ($err) echo The include file $incfile has an error: $err; The trick is to put an @ before the include which will hide the error (even if it's a critical one). However, in case of a critical error, your script will silently be aborted. Thus here's a solution to cature these cases: 3) Include and execute capturing critical errors: $hf = fopen($incfile, 'r'); if ($hf) { $buffer = fread($hf, filesize($incfile)); fclose($hf); } if ($buffer) { global $php_errormsg; $php_errormsg = null; @eval($buffer); $err = $php_errormsg; } The rest goes as above. The eval statement will gracefully handle any critical error that would bring your script to an immediate halt in case of @include. HTH :) - Original Message - From: Bob Lockie [EMAIL PROTECTED] To: php-general Mailing List [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 6:11 PM Subject: [PHP] HTML if no PHP I want to display an HTML page if PHP can't load an include file or otherwise has an error or just doesn't work. How do I do this? -- Sent from Mozilla and GNU/Linux. Powered by an AMD processor. -- 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] HTML if no PHP
3) Include and execute capturing critical errors: $hf = fopen($incfile, 'r'); if ($hf) { $buffer = fread($hf, filesize($incfile)); fclose($hf); } if ($buffer) { global $php_errormsg; $php_errormsg = null; @eval($buffer); $err = $php_errormsg; } The rest goes as above. The eval statement will gracefully handle any critical error that would bring your script to an immediate halt in case of @include. How about just using set_error_handler() and process the errors from there? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HTML page and php
There are several ways you can do this. The easiest way is to include the file like this: include(path_for_html_file); You can place this line wherever you need the html file included. See the include() function on php.net for more info. If, instead, you want to capture the html file and do something with it, you can use the file functions listed on php.net. It might seem a little difficult to grasp at first, but it will be very straightforward once you get used to using these functions. Just search for FileSystem on php.net and it will get you to the exact place you need to be to start learning about how to deal with files. Here is the direct link, just in case: http://www.php.net/manual/en/ref.filesystem.php. This site might also help you: http://www.devshed.com. Have fun... - Nilaab -Original Message- From: Martin Johansson [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 10:16 AM To: [EMAIL PROTECTED] Subject: [PHP] HTML page and php How do I get a html page into a string variable in php? Isnt there any function working like this: $homepage = getHtmlPage(c); /Newbie -- 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] html input and php (newbie)
Hi Anna, Your REGISTER_GLOBALS is most probably set to OFF (see php.ini file). Try using the special $_POST array created by PHP: if ($_POST['submit'] == click){ echo Hello, $_POST[UserName]; } If your form was using the GET method you would need the $_GET array. Regards, Daniel Kushner _ Need hosting? http://thehostingcompany.us -Original Message- From: Anna Gyor [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 24, 2002 3:31 PM To: [EMAIL PROTECTED] Subject: [PHP] html input and php (newbie) Hi, I just began to learn php and I have te following code. How can I get the input field value in the php script? Because my script doesn't work. $UserName is always an empty string. ?php if ($submit == click){ echo Hello, $UserName; } else{ ? htmlbody form method=post action=input.php3 Enter Your Name input type=text name=UserName/inputbr input type=submit name=submit value=click/input ? echo Hello, $UserName; ? /form /body/html ? } ? -- 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] html input and php (newbie)
Anna Gyor mailto:[EMAIL PROTECTED] scribbled; Hi, I just began to learn php and I have te following code. How can I get the input field value in the php script? Because my script doesn't work. $UserName is always an empty string. ?php if ($submit == click){ echo Hello, $UserName; } [...] Assuming register_globals=off, use $_POST['UserName'] instead -jesse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] html input and php (newbie)
What is of your PHP version? I guess of your directive register_globals = off in your php.ini, so your code would be run OK like this: ?php if ($_POST['submit'] ) { echo 'Hello'.$_POST['UserName']; } ? --jp At 21:31 24-09-2002 +0200, Anna Gyor wrote: Hi, I just began to learn php and I have te following code. How can I get the input field value in the php script? Because my script doesn't work. $UserName is always an empty string. ?php if ($submit == click){ echo Hello, $UserName; } else{ ? htmlbody form method=post action=input.php3 Enter Your Name input type=text name=UserName/inputbr input type=submit name=submit value=click/input ? echo Hello, $UserName; ? /form /body/html ? } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Juan Pablo Aqueveque [EMAIL PROTECTED] Ingeniero de Sistemas Departamento de Redes y Comunicaciones http://www.drc.uct.cl Universidad Católica de Temuco. Tel:(5645) 205 630 Fax:(5645) 205 628 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] html input and php (newbie) -- What I was asking with my thoughts on Search Engine
This what I was asking, I want someone to press submit then have the returns print out in one are of the table. So could I do this? ?php if ($submit == click){ echo $sql_result; } ? So instead of doing a search.html that calls on do_search.php like most books teach. I am wanting to do a search.php. Just print the information on that page. Chuck -Original Message- From: Jesse Cablek [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 24, 2002 3:39 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] html input and php (newbie) Anna Gyor mailto:[EMAIL PROTECTED] scribbled; Hi, I just began to learn php and I have te following code. How can I get the input field value in the php script? Because my script doesn't work. $UserName is always an empty string. ?php if ($submit == click){ echo Hello, $UserName; } [...] Assuming register_globals=off, use $_POST['UserName'] instead -jesse -- 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] HTML Checkboxes and PHP variables
If you name the form elements as arrays, then yeah, they are pretty much the same. input type=checkbox name=foo[] value=oneOne input type=checkbox name=foo[] value=twoTwo input type=checkbox name=foo[] value=threeThree When submitted, $foo will be an array containing the values that were checked. If a box was not checked, it won't have any value in the array. i.e. If you check One and Three, then you'll have a $foo array like this: $foo[0]='one'; $foo[1]='three'; ---John Holmes... - Original Message - From: Brad Harriger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 8:56 AM Subject: [PHP] HTML Checkboxes and PHP variables Are HTML Checkbox values handled the same way as Select Multiple tags? -- 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] HTML Checkboxes and PHP variables
I've been wrestling with the same issue. I had some code loop through and create an arbitrary number of checkbox inputs with the name 'foo[]' I then attempted to access the array using: foreach ($foo as $bar) { echo $bar; } but I got error messages telling me that $foo is not an array :-( I'm using Netscape 4.7 something on Red Hat 6.2 ... could this be an issue? I know Netscape can be pretty buggy and fussy at the best of times. Michael On Wed, 29 May 2002, 1LT John W. Holmes wrote: If you name the form elements as arrays, then yeah, they are pretty much the same. input type=checkbox name=foo[] value=oneOne input type=checkbox name=foo[] value=twoTwo input type=checkbox name=foo[] value=threeThree When submitted, $foo will be an array containing the values that were checked. If a box was not checked, it won't have any value in the array. i.e. If you check One and Three, then you'll have a $foo array like this: $foo[0]='one'; $foo[1]='three'; ---John Holmes... - Original Message - From: Brad Harriger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 8:56 AM Subject: [PHP] HTML Checkboxes and PHP variables Are HTML Checkbox values handled the same way as Select Multiple tags? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- n i n t i . c o m php-python-perl-mysql-postgresql Michael Hall [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML Checkboxes and PHP variables
What version of PHP are you using? Is register_globals on or off? Try $_GET['foo'] as the array name, instead of $foo, or $_POST['foo'], depending on the method of your form. ---John Holmes... - Original Message - From: Michael Hall [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Brad Harriger [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 7:39 PM Subject: Re: [PHP] HTML Checkboxes and PHP variables I've been wrestling with the same issue. I had some code loop through and create an arbitrary number of checkbox inputs with the name 'foo[]' I then attempted to access the array using: foreach ($foo as $bar) { echo $bar; } but I got error messages telling me that $foo is not an array :-( I'm using Netscape 4.7 something on Red Hat 6.2 ... could this be an issue? I know Netscape can be pretty buggy and fussy at the best of times. Michael On Wed, 29 May 2002, 1LT John W. Holmes wrote: If you name the form elements as arrays, then yeah, they are pretty much the same. input type=checkbox name=foo[] value=oneOne input type=checkbox name=foo[] value=twoTwo input type=checkbox name=foo[] value=threeThree When submitted, $foo will be an array containing the values that were checked. If a box was not checked, it won't have any value in the array. i.e. If you check One and Three, then you'll have a $foo array like this: $foo[0]='one'; $foo[1]='three'; ---John Holmes... - Original Message - From: Brad Harriger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 8:56 AM Subject: [PHP] HTML Checkboxes and PHP variables Are HTML Checkbox values handled the same way as Select Multiple tags? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- n i n t i . c o m php-python-perl-mysql-postgresql Michael Hall [EMAIL PROTECTED] -- 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] HTML link to php
Hmm, because the .php file that is referenced from the .html file is like: file://c:\myfile.php ? i mean maybe it's beeing accessed as if a normal file beeing browsed and not a php file that is beeing referenced via the web server.. "moud mohamed" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello world. Using QuickPHP. I have PHP4.03pl1 and Mysql 3.22.34 under WIndows 98 SE. The web server is Apache 1.3. I have a link (in an HTML page) to a php page. In this php page I make a dynamique list( select option like combo list) that pick information from a column table in a Mysql database. So, if i call the php page directlly from browser the list began full with information from database. However, if i accede to the php page from a link in the HTML page, the list stay empty (so i think the php script does not be executed). If someone please can help me about this. gratefuklly. __ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]