C3ris Posted December 5, 2013 Share Posted December 5, 2013 Hi As a newcomer to php i am trying to run the example scripts but i am not doing well up to now! Maybe a trivial question but is there a bit detailed guide cause even copypasting the code in a html and a php file in the same directory (htdocs/something) does not seem to work! I have installed xampp and apache which seem to be running ok, but i have some problems like the $_POST not taking any values from the html file, etc. i tried netbeans but for me it is a little bit complicated. Thanks in advance for any help! Link to comment Share on other sites More sharing options...
HartleySan Posted December 5, 2013 Share Posted December 5, 2013 Have you tried using XAMPP? Link to comment Share on other sites More sharing options...
C3ris Posted December 5, 2013 Author Share Posted December 5, 2013 Yes i did. At least that's what i think! I use xampp to start apache etc. Link to comment Share on other sites More sharing options...
HartleySan Posted December 5, 2013 Share Posted December 5, 2013 If you start Apache from XAMPP and then go to http://localhost/, what do you see? Link to comment Share on other sites More sharing options...
C3ris Posted December 6, 2013 Author Share Posted December 6, 2013 I see the xampp control panel Link to comment Share on other sites More sharing options...
Larry Posted December 6, 2013 Share Posted December 6, 2013 That's great. Now put a phpinfo() script (named phpinfo.php) in your web root directory and then go to http://localhost/phpinfo.php Link to comment Share on other sites More sharing options...
C3ris Posted December 6, 2013 Author Share Posted December 6, 2013 I created (netbeans) a new php project (i can not find how to create a simple php file/script), renamed it from index (by saving as ...) and placed it in the suggested by netbeans folder "PhpProject1", at C:\xampp\htdocs\PhpProject1. Maybe silly, but thats my level of programming skills . When i type the above url (in Chrome) i get Object not found!The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 localhostApache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.19 NOTE When i type localhost now, i get a directory listing! This is the project code <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <?php echo "put your code here"; ?> </body> </html> Link to comment Share on other sites More sharing options...
C3ris Posted December 6, 2013 Author Share Posted December 6, 2013 System Windows NT IDEAPAD 6.2 build 9200 (Unknown Windows version Home Premium Edition) i586 Build Date Aug 21 2013 01:07:08 Compiler MSVC9 (Visual C++ 2008) Architecture x86 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo" Server API Apache 2.0 Handler Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\xampp\php\php.ini Scan this dir for additional .ini files (none) Additional .ini files parsed (none) PHP API 20100412 PHP Extension 20100525 Zend Extension 220100525 Zend Extension Build API220100525,TS,VC9 PHP Extension Build API20100525,TS,VC9 Debug Build no Thread Safety enabled Zend Signal Handling disabled Zend Memory Manager enabled Zend Multibyte Support provided by mbstring IPv6 Support enabled DTrace Support disabled Registered PHP Streams php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls Registered Stream Filters convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*, bzip2.* Link to comment Share on other sites More sharing options...
C3ris Posted December 6, 2013 Author Share Posted December 6, 2013 I got it!! I put the above file at the root directory and i got "put your code here" which i echoed in the script! I am so happy! And now? Link to comment Share on other sites More sharing options...
HartleySan Posted December 6, 2013 Share Posted December 6, 2013 Well, if you're able to property execute PHP scripts, then you should probably structure the htdocs folder in a way that makes sense for you, and then start working through the book. Link to comment Share on other sites More sharing options...
C3ris Posted December 6, 2013 Author Share Posted December 6, 2013 I try the examples creating one html form and one php script and when i load the html form through a url the script is executed (sometimes!) but the POST or GET superglobals return no value (from the form input) they are just returned as strings! So i think there is no communication between the html and the php scipt! Or i am doing something wrong! (Neewbie you see!) Link to comment Share on other sites More sharing options...
HartleySan Posted December 6, 2013 Share Posted December 6, 2013 $_GET is only set when you pass parameters via the URL. $_POST is only set when you submit a form via POST. That make sense? Link to comment Share on other sites More sharing options...
Larry Posted December 6, 2013 Share Posted December 6, 2013 I suspect you're not loading the form through a URL. What is the URL you're using for the form page? Link to comment Share on other sites More sharing options...
C3ris Posted December 7, 2013 Author Share Posted December 7, 2013 OK, I put the two files at the htdocs directory (not in a separate folder) and everything worked out! I really thank you for your time, guys! My next question would be now how can i save the examples of the book each on its own directory (under htdocs) and test them? Do i have to tweak the actual code or the web server or what? PS i typed http://localhost/posting.html entered some text etc, and when i got the reply the URL was http://localhost/handle_post.php! PS2 I live in Greece so the time difference is quite much and i do not answer fast! Link to comment Share on other sites More sharing options...
C3ris Posted December 7, 2013 Author Share Posted December 7, 2013 Please disregard my last posting! I can run the scripts even from other directories i make! The main point was that i did not load the form through a URL, as Larry suspected (that's why he is the writer of books and we the readers Link to comment Share on other sites More sharing options...
HartleySan Posted December 7, 2013 Share Posted December 7, 2013 Glad you got it all working. You good to go now? Link to comment Share on other sites More sharing options...
C3ris Posted December 7, 2013 Author Share Posted December 7, 2013 Yes, thanks again! I think that this whole post could be deleted, i will be starting a new one if i run to any problem again! Link to comment Share on other sites More sharing options...
HartleySan Posted December 7, 2013 Share Posted December 7, 2013 No problem. Link to comment Share on other sites More sharing options...
Recommended Posts