0

I just started learning PHP and I tried looking for answers, but couldn't find any.

When i type in

<?php echo '<p>Order processed.

embedded into HTML, it works fine, but when I put

<?php echo '<p>Order processed.</p>' ?>

it always has the closing tag '?> shown in the browser. Is there something I missed?
When I run it through localhost/file_name in my browser, it works fine, but I would prefer just opening the php file from my desktop. Also, when I write:

<?php
	echo "<p>Order processed at ";
	echo date('H:i, jS F Y');
	echo "</p>";
      ?>

it seemingly ignores all the semicolons and treats echo and everything else as HTML.


What can I do to fix it?

Edited by blee93: n/a

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by mikulucky
0

You need to open it in a browser via the localhost server. This is what processes the code. Just opening it up as a random file from anywhere will not work.

0

I put the files into the Apache htdocs directory, but when I click "Submit Order" on the .html file to access the processorder.php file, it does not work. Only when I run the .php file separately writing localhost/processorder.php does it work. Did I do something wrong when configuring PHP/Apache?

0

It depends on the address of the html file in the address bar of the browser. If it's a local filepath like:

file:///C:/xampp/htdocs/index.html

Then using that to link to a php probably won't work.
If you open it as:

http://localhost/index.html

Then I can't see why the form won't work.

Show your form code.

Edited by diafol: n/a

0

It might be your apache configuration, sometimes PHP is not enabled. Within the httpd.conf file there is a sections called modules, find the line for loading the PHP module, and remove the '#' at the beginning. Save the file, and restart the web server. This should solve it.

However we need more detail, if you could try this.

  • Open your form in a web browser.
  • click view source
  • in the form attributes, where it would state the name of the php file, click it from the source still
  • Tell us what happens, does it work then or fail?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.