2

I'm new to PHP and I'm following the PHP tut on w3schools. I am using Eclipse's latest IDE version (3.6 I think). for my script helloDriver.php it functions fine when ran as a php script. it doesn't on my html file especially when I use a similar method to the example from w3schools: http://www.w3schools.com/PHP/php_forms.asp

This would be my code for helloDriver.php:

<html>
<body>
go
<?php
    echo "giga";
?>
power rangers
</body>
</html>

This is my code for homepage.html

<html>
<body>
Hey
<form action="helloDriver.php">
<input type="submit />
</body>
</html>

"Hey" and "go" both display so I know that the php file is being called but I don't know why the echo command doesn't.

Even before this I copied line by line with what the w3schools example was with the exception of welcome.php since that is helloDriver.php

How I access the html file is double clicking it since Eclipse doesn't have any options to run the program. Any ideas what I am doing wrong?

2
  • 1
    If you view source do you see the php call? I'm thinking your web server is not set up to interpret the php. Commented Mar 23, 2011 at 2:45
  • 2
    step one w3schools is rubbish Commented Mar 23, 2011 at 2:51

3 Answers 3

3

Where are these files hosted? I'm guessing your web server (e.g., Apache or IIS) isn't configured to run .php files through the PHP interpreter, but instead is serving them statically.

Sign up to request clarification or add additional context in comments.

1 Comment

That would be it. I have no server or anything. It is simpyl me double clicking the html file and seeing what shows
0

I'm having a really hard time working out what your question is.

Some problems with your HTML file are:

  • You're missing the closing </form> tag
  • You haven't closed the quotes on your submit button.

The complete markup should probably be more like

<form action="helloDriver.php">
    <input type="submit" />
</form>

Another thing that might be the problem, you need to access the PHP scripts through a web server. Have you installed something like XAMPP?

1 Comment

no i haven't. not sure what that is. as I said before. I am new to the extreme to PHP. I'll look into what what XAMPP is.
0

I ended up figuring it out. Thank you guys for help and thanks for suggesting XAMPP. Installed it from this link (googling XAMPP works just as well): http://www.apachefriends.org/en/xampp-windows.html#1173

It was straightforward and easy to set up. Set the destination to install on the C: drive. Also stumbled across this tut vid on how to set up a PHP project using PHP, XAMPP, and Eclipse: http://www.youtube.com/watch?v=hfHEmZXJLgw

I should be able to figure things through trial and error. Thanks again!

1 Comment

A piece of advise do not rely much on w3Schools tutorials. See this w3fools.com for some php tutorial read first the php manual here php.net/manual/en/index.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.