Php Not Showing up

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 8:25 pm    Post subject: Php Not Showing up Reply with quote

I am just starting to learn php, so Im not sure how to make this work. Im not sure if this is something to do with my server or not. Any ways, here is my problem.

I have this code for my html portion:
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

<form action="welcome.php" method="GET">
Enter your name: <input type="text" name="name" /><br>
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>

And I have this code for my php portion:
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
Welcome <?php echo $_GET["name"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
</body>
</html>


As you should know it should print something like this:
Welcome John.
You are 28 years old!

But this is what it actually prints:
Welcome .
You are years old!

Anyone know how to fix this problem?

By the way I used Post and Get
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 8:35 pm    Post subject: Reply with quote

It is your coding that is to fault I think.

Try this.

submit.php

Code:
<form name="form1" action="post.php" method="post">

<input type="text" size="30" name="name"><br>
<input type="text" size="30" name="age"><br>
<input type="submit" name="submit" value="Post Message">
</form>




view.php

Code:
<?php

if ($_POST['submit']) {

$name = $_POST['name'];
$age = $_POST['age'];

echo("Welcome ");
echo($name);
echo(". You are");
echo($age);
echo(" years old");

}

else{

echo("error");
}

?>


This code is from the top of my head but should work in theory,

Hope this helps.[/code]
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 8:37 pm    Post subject: Reply with quote

Now nothing shows up
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 8:39 pm    Post subject: Reply with quote

If you have MSN, add me and I will talk you through it, in the mean time I will make this script work.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 8:39 pm    Post subject: Reply with quote

ah, i know why, i forgot to change post.php to view.php in the submit form.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 8:40 pm    Post subject: Reply with quote

The code should work, I got it from http://www.w3schools.com
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 8:41 pm    Post subject: Reply with quote

Download these two files from my server http://www.abyssunderground.co.uk/thelittleguy.zip
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 8:44 pm    Post subject: Reply with quote

they didn't work
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 8:45 pm    Post subject: Reply with quote

In which case you need to turn on register_globals in your php.ini file.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 8:48 pm    Post subject: Reply with quote

What does that mean?

Sry im new to this
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 8:55 pm    Post subject: Reply with quote

OK, you need to go to where you installed php (probably c:/php) and look for a file called php.ini, search the file for register_globals and set it to be on. The two files you have should now work.

Hope thats clear enough.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 8:57 pm    Post subject: Reply with quote

Im using dreamweaver and that is the only thing that is installed for php will it still work?
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 9:10 pm    Post subject: Reply with quote

Well, in order to view PHP pages you need to have a webserver that will run it, Abyss, and PHP Source itself which you can download from www.php.net. You need to install it to abyss and run it like a normal HTTP server.

Follow the tutorial at www.trustabyss.com and you should be up and running in no time. If you need more help, post here.

Use the link http://www.php.net/get/php-5.0.4-Win32.zip/from/a/mirror to download PHP.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Thu Jun 30, 2005 9:29 pm    Post subject: Re: Php Not Showing up Reply with quote

Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
Welcome <?php echo $_GET['name']; ?>.<br />
You are <?php echo $_GET['age']; ?> years old!
</body>
</html>


For $_GET['name'] and $_GET['age'] you should be using the single quote ' not the double ". Also register_globals does not need to be on for this code. Enabling register globals can lead to potential security problems.

php.ini wrote:
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.

_________________
Olly
Back to top View user's profile Send private message
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Thu Jun 30, 2005 9:34 pm    Post subject: Reply with quote

That still doesn't work the single quote
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Jun 30, 2005 9:35 pm    Post subject: Reply with quote

Did you do what I said and download PHP? Or are you still using DreamWeaver? I'm pretty sure it doesnt support viewing PHP pages.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
The Little Guy
-


Joined: 30 Jun 2005
Posts: 20

PostPosted: Fri Jul 01, 2005 11:15 pm    Post subject: Reply with quote

I downloaded it and read the installation instructions, and it still doesn't work. Maybe i didn't install it correctly.
Back to top View user's profile Send private message
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Fri Jul 01, 2005 11:37 pm    Post subject: Reply with quote

Do you receive any error messages?
Are you loading the PHP page via Abyss?
_________________
Olly
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group