Eclipse Neon php XDebug form action=post in WordPress - php

Objective: debug a php script triggered from an HTML form with action=POST from within a WordPress Page.
What works: I can initiate a debugging session for index.php. This results in the web page displaying in the browser view. I can then click on any links on the page, which in turn triggers a new call to index.php. I can step through the WordPress code with no problems, set breakpoints and so on.
The apache server is on my workstation, localhost, running Ubuntu Linux.
In one page there is a form. When I click the submit button, I get a message in the browser view saying:
Unable to load page
Problem occurred while loading the URL file:///xyz.php
Error opening file: No such file or directory
It seemed to me that Eclipse is looking for the php file at the workstation root directory instead of the server root. So I put a symbolic link at the root level to the php script to see if Eclipse would find it.
Now when I click on the link I get a File Dialogue asking me do I want to download the php script.
It seems there must be a wrong setting somewhere but I am at a loss. As it stands I can only debug code that is triggered by a GET, not a POST.
If I run the script in Eclipse without debugging, I can post the data and the post script executes. It is only with the debugger that I get the file not found error, so it seems to be in the debugging config:
Server Name: Nip.yt
Base URL: http://nip.yt (127.0.0.1 - works fine in browser)
Document Root: /home/peter/Documents/localhost/html/nip
Path Mapping
Path on Server: /home/peter/Documents/localhost/html/nip
Path in Workspace: /nip
I have tried replacing Path on Server with / with identical results.
Any and all advice appreciated.
EDIT:
I am now using php5.6 with Zend Debugger, but exactly the same thing happens.

Hanging his head rather sheepishly, he says...
I solved the problem. I just put the full URL in the
Doh...
Why didn't I think of that sooner???

Related

Debug PHP code from input passed in a html form with xdebug and NetBeans 8.2

I have set up XDebug extension to debug PHP code from within NetBeans IDE (ver. 8.2). Debugging is working fine when I set a breakpoint and run the script in debug mode.
Now I have a HTML5 code which includes a form with 4 user inputs and a submint button which passes them all to my PHP code. However I am having difficulties in debugging the PHP with the inputs passed from the HTML page. I tried to set a breakpoint in the called PHP code, but after pressing the submit button I cannot reach the breakpoint, although the debug session seems always "in progress".
I am running Ubuntu 16.04, Apache2 web server, PHP 7, and Firefox browser.
I found a solution in an old post the NetBeans Forum.
My setup was:
index.html contains the form
code.php processes it
The solution was to change the extension of the index from .html to .php. Then in the Project settings under Run Configuration, I set up the new index.php file as the "Index File". Finally, setting a breakpoint in the code.php, made it stops in debug mode after the form in index.php was submitted.
Hope this could be of help for anybody.

Getting a 404 Error for index.php when trying to access it externally

After extensive search, double checking install, reinstalling, troubleshooting, I don't know where to turn next.
Background:
I'm trying to get a wiki working using MediaWiki.
I have PHP Manager installed for IIS 7.
I have a MySQL server installed on the same machine.
PHP version is 5.6.5 and installed at C:\PHP.
The main issue:
Locally I can view the index.php file, but not externally.
I get a generic page can't be displayed error if linking to the /w/ directory.
Depending on the browser I'll get two results when linking to w/index.php:
page can't be displayed
IIS 404.0 Error.
Depending on the browser I'll get two results linking to w/index.php?title=Main_Page;
IIS 404.0 Error
unformatted page content
The error:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002
Requested URL: http://localhost:80/w/index.php?title=Main_Page
Physical Path: C:\inetpub\wwwroot\w\index.php
Logon Method: Anonymous
Logon User: Anonymous
Troubleshooting done:
No errors shown by PHP Manager.
Switched PHP versions (no effect).
Externally tested other PHP forms running inside HTML (works fine).
Checked permissions on all folders (fine).
Edited Feature Permissions under Handler Mappings to allow executable (no change).
Changed PHP_via_FastCGI's access restriction to execute (no change).
Checked to make sure PHP Handling Mapping was set to *.php (it is).
Checked Default Document settings and index.php. Externally tested index.html in w/ (works both by direct link to file and link to folder).
Externally tried tested /w/index.html with PHP "Hello World" inside it (blank page).
What am I doing wrong? Everything works perfectly fine run locally on the server.
As Christpher says, localhost is a wrong in an URL to be contacted from outside: if that's what you see, you forgot to set $wgServer correctly.

Using Brackets for PHP files

I currently have wampserver running and I'm trying to do live preview of a php file using Brackets.io. However when I click live preview I'm getting
Project settings for: Getting Started
Live preview base URL: ______________
I'm following this tutorial on running PHP scripts.
My php file is in C:/wamp/wwww/php_proj1/php1.php so I've been trying to put this in my "Base URL"
http://localhost/php_proj1/php1.php
However everytime when I type that and enter it, it just asks me for the "Live Preview Base URL" again and nothing happens. I also tried putting the URL in my 'File->Project settings' and that also didn't work. I'm just running a basic php script that echos some words.
It works when I manually type
http://localhost/php_proj1/php1.php
in my Chrome URL but not when I use Bracets live preview.
What am I missing or doing wrong? Do I need to config anything in my wampserver? I've just started learning php and using wampserver so I'm not entirely sure what I'm doing wrong.
Thanks!
EDIT: I'm following these 2 tutorials on doing this and it's just not working for me.
tutorial 1 and tutorial 2
EDIT2: Found my mistake.. I did not do File->Open Folder to open the folder that I was working on... Thanks to everyone that helped me with this, I will definitely not make this mistake again. sigh
The Live Preview Base Url should be set to the same url that you would use to launch your project in a browser.
So if you have a project in C:/wamp/wwww/php_proj1/ you would launch that project in a browser by entering http://localhost/php_proj1/php1.php therefore that is what Brackets is expecting to be entered into the Base Url field minus the actual script file name.
Remember the DocumentRoot of localhost is pointing to the folder C:/wamp/www/
So enter
http://localhost/php_proj1/
into the dialog that requests the Base Url.
Assuming you are editing the file php1.php at the time you clicked the Live Preview icon that is the script that will be run in the browser.
Oh and of course you have to have WAMPServer and therefore Apache up and running when you do this as it is running the code through Apache so that the PHP code can be interpreted.
Found my mistake. I did not do File->Open Folder to open the folder that I was working on...
Try the same thing but with a simple HTML file.
Try launching your project with PHP's built-in server. Open a terminal/cmd window and go to the folder php_proj1. Now execute php -S localhost:8000. Now set your Live preview path to http://localhost:8000/. If this one does work, then there may be a problem with Wamp.
Now remember that no matter what, you're not supposed to contain a file in the Live Preview path, but only a folder path. When you contain it, you get to this URL: http://server/file.php/file.php (double) and that's not exactly what you want...
If none of these work - there may be a problem with either your computer, Brackets, Chrome, or both. Try to reinstall them (Brackets first).
My two cents, is the name of the project php_proj1 ? If not you'll have to use http://localhost/ as your base URL.
Also (When you are using Brackets) check the content of the Chrome Network tab. F12 Developer Tools -> Network -> Filter -> Documents
Try to investigate the URLs, probably that'll give you some insight

How to configure FlashDevelop to debug in web browser?

I'm following directions to set up a debugging in FlashDevelop in web browser. I'm getting confused on 'Configure your project' step. It says:
Open the Project properties and change the "Test Movie" option to
"Open Document...". Click on the button which should appear,
and enter bin/index.html (path to html page, relative to project root)
in the prompt.
What is the bin/index.html file? Is it where my SWF is loaded? I currently have a SWF that loads from a PHP page. So I pointed it to my PHP project's index.php page build project. After build I get a generic Windows message that Windows cannot open the file with that extension.
Is it possible for me to debug my SWF from my PHP page which loads it?
I don't have experience directly with what you're talking about, but I guess you have to point to a PHP file which is running in a webserver. Otherwise it can't be interpreted and run.
If you are running locally, you can use xampp, put your things in htdocs, and use localhost url to reference the file: http://localhost/projectname/index.php

Call to PHP prints source, doesn't run when called from another file

I have a quick question that I can't figure out. I've tried searching Google and following examples, but I can't find anything.
I have an HTML form that I'm trying to process with a PHP file, but when I submit the form, it merely prints the source of the PHP file, it doesn't execute it. If I run the PHP file by itself (not indirectly through the HTML button), it works fine.
HTML form header:
<form id="registrationform" name="registrationform" method="post" action="processregistration.php">
Submit button:
<button type="submit" value="Submit" >Create</button>
The PHP form is just <?php print "Hello"; /?
Again, it runs fine if I just run the PHP file, but prints the PHP file (doesn't run) when it gets called through the HTML form.
Any help is appreciated.
edit-Running locally through Coda
edit-Here is the output that I'm getting:
Output when the PHP is called through an HTML action:
</php
print "Hello";
?>
Output when I run the PHP directly through Coda:
Hello
I had the same problem and just fixed it on my coda version 1.7.4
I installed MAMP on my mac and set up the apache path under MAMP preferences to the folder where my sites are located;
/Users/yourUserName/Sites
this points MAMP's 'http://localhost:8888' address to your sites folder, if you paste that on your browser you'll now see your sites folder's content in the browser.
then, all you do is point the local site's connection settings to the site you are testing;
I was going to post an image, but I'm new to the site and wasn't allowed.
Under my site's preferences i set up the addresses as follows;
Root URL : 'http://localhost:8888/yourSiteRootFolder/'
Local URL : 'http://localhost:8888/yourSiteRootFolder/'
Remote Root : /yourSiteRootFolder/
Local Root : /Users/amartinez/Sites/yourSiteRootFolder/
I hope this is related to the problem you're having and helps you fix it.
Line #19 from Coda 1.6 Release notes:
Coda no longer tries to locally
preview a remote PHP file while
editing/previewing
Listed under "Improvement" - doubt they brought it back for the 1.7 release.
I'm running Apache2/PHP5 10.5.8 OS X (no problem reproducing your issue with Coda)
Even when running my form.html and post.php files from /Library/WebServer/Documents folder.
My sample files work fine in the Apache env....I just needed to run them through Coda to "break" them. :-)
Are you sure the html file and the php script are on a server with php support enabled?
I've never used Coda, but you need to be running it through a server (e.g. Apache + PHP). You cannot just open the file itself within Windows.
Try looking at xampp as a quick server for testing.
If it works properly, you should be viewing the PHP file on something like http://localhost/test.php instead of file:///something/test.php.
This may be because you don't have PHP installed on your server. I would check to make sure that your hosting package included PHP, pre installed.
Here are some resources to get you started with that, if not installed:
http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml
http://www.php.net/manual/en/install.php
http://www.w3schools.com/PHP/php_install.asp
Edit: actually, I think I may have found it.
If you look at the starting PHP tag, you have a slash instead of a ?. If that's in your script, just change that to <?php. But it may not be, it could be that's just question format-ing.

Categories