Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to run a php script which is the forr action in an html document. The HTML code i have is as follows

<html><head><title>Using PHP</title></head>
<body>
<form action="form.php" method="post">
IP ADDRESS:<input type="text" name="IP"><input type="submit"><form>
</body></html>

I am using Ubuntu Server 12.04 LTS so i have saved this file to /var/www . The php script that i have titled form.php, which is also in /var/www is as follows

<?php
echo "Todd"
?>

When i paste http://10.0.0.98 into my browser, i get the form and when i click on submit, it downloads something which cannot be opened. I would want to view the script results on the browser. I do not know where i am going wrong, still very much new to PHP.

share|improve this question

closed as off-topic by don.joey, Radu Rădeanu, jokerdino Sep 2 '13 at 14:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – don.joey, Radu Rădeanu, jokerdino
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Have you tried: localhost/your_html_form or localhost/form.php. in your browser. What does it give. –  Saurav Kumar Sep 2 '13 at 7:56

1 Answer 1

up vote 0 down vote accepted

Your question is better suited to another StackExchange forum like StackOverflow, since it is about general Web programming that is not specific to Ubuntu per se.

That said, I see one flaw in your html in that you don't have a proper closing </form> tag. It would also be standard practice to have the form encoding included in the <form> tag as well, such as enctype="multipart/form-data" And since your PHP page is not really reading any of the input of the form, the PHP page should function if you simply enter http://10.0.0.98/form.php in your browser.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.