Question

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 
Was it helpful?

Solution

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. :-)

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top