• 0

PHP works locally but not on the remote server


Question

I'm currently learning PHP through a book (Beginning PHP4) and I've gotten to the point where I'm using PHP with with HTML forms to show simple things in the browser after submitting the form...

The examples have all been working fine locally on my machine with Apache2, but when uploaded to a server I'm testing them on (a server which hosts a site I work on with a few other people) it doesnt work correctly.

I know the code is right because it works perfectly on my PC, and I know the server supports PHP4 because the first few examples I uploaded worked fine too - it's just the form ones I'm having trouble with.

I have this in a file called text.html

<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD=GET ACTION="text.php">
Who is your favourite author?
<INPUT NAME="Author" TYPE="TEXT">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

And then this in a file called text.php

<HTML>
<HEAD></HEAD>
<BODY>
Your favourite author is:
<?php
echo $Author;
?>
</BODY>
</HTML>

Like I said it works fine on my PC, but when uploaded to the actual server, the text.php page just brings up "Your favourite author is:" when submitted from text.html.... no variable is showing up, no matter what is typed in the form.

It's probably the way PHP is set up on the server with the config file, right? If this is so - how would I go about finding the config file and which part would need to be changed? From what I've learned so far I'm guessing it may be the register_globals expression.... I remember having to enable that on my local machine before trying the examples.

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0

Use it like this:

<HTML>
<HEAD></HEAD>
<BODY>
Your favourite author is:
<?php
echo $_GET['Author'];
?>
</BODY>
</HTML>

You may want to read this

Link to comment
Share on other sites

  • 0
Use it like this:

<HTML>
<HEAD></HEAD>
<BODY>
Your favourite author is:
<?php
echo $_GET['Author'];
?>
</BODY>
</HTML>

You may want to read this

586275016[/snapback]

That's exactly how I used it, and it didnt work.

Link to comment
Share on other sites

  • 0

Also, on my PC i'm using the latest version from php.net - but I'm not sure what the version is on the server I'm testing things on. Either way it makes no difference since right now even on my PC I cant get it to work with register_globals turned off. Even with this:

echo $_GET['Author'];

Link to comment
Share on other sites

  • 0

^

No clue there.

On the server, upload a file that just contains

<? php_info() ?>

I believe that's the func. It'll tell you more than you ever wanted to know.

Link to comment
Share on other sites

  • 0

Yeah that's in the very first parts of the book, I've already done that and had a skim through but it doesnt help me with this issue apart from to see that register_globals is turned off.

Link to comment
Share on other sites

  • 0

I've gone through so many forums and they all say to do the same thing, even the forum for the book I'm reading says it too - but it does not work for me. I dont get it - I have the latest version of Apache2 and PHP, I've got the code exactly right and it just will not work.

Why!?

Link to comment
Share on other sites

  • 0

I'm an idiot.

I'm sorry you guys lol - It was all working fine, I was just loading the html/php outside of the Apache server - so the PHP wasnt even being parsed! It works great now.

Can't believe I forgot about that!

Thanks for all your help

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.