Sm00rf9000
Sm00rf9000

Reputation: 541

Testing my php scripts and forms

I have two html forms and two php scripts. The first one is a form which is supposed to submit a users email to a .txt file, and the other is a Stripe payment form which uses php code to charge the customer.

Now my problem is that there are some issues with the two php scripts, that I can't figure out how to fix, because I am not really sure how to test the scripts. Normally when testing the html scripts I would just open the html files in my browser, but that doesn't work on my php scripts as the site just shows what is written in the scripts when called/submitted.

So my question is how do I test my scripts, without having to use a hosting account and can I even test it like this?

Upvotes: 0

Views: 85

Answers (3)

orestiss
orestiss

Reputation: 2283

You probably have to install a web server locally with php enabled. Since php is a server side language it needs a server to run on, in order to send you back the html, after execution. If you need to see the result on a browser.

http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29.

Or run your script from terminal (you must have php installed) if you don't need to see the result in the browser and just want to run your script.

$ php myscript.php

Upvotes: 1

user169600
user169600

Reputation:

Depending on your version of PHP there's a webserver builtin right into PHP:

http://php.net/manual/en/features.commandline.webserver.php

Upvotes: 1

HeadCode
HeadCode

Reputation: 2828

You need to run a web server on your local computer to test it out. I would suggest looking into something called Vagrant, which allows you to fairly easily create virtual machines on your computer in which you can install anything you like without fear of messing up anything else. If you go here you can even find a "box" to create a virtual machine that already has apache and php installed.

Upvotes: 1

Related Questions