View previous topic :: View next topic |
Author |
Message |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Thu Jun 30, 2005 8:25 pm Post subject: Php Not Showing up |
|
|
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 |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 8:35 pm Post subject: |
|
|
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 |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Thu Jun 30, 2005 8:37 pm Post subject: |
|
|
Now nothing shows up |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 8:39 pm Post subject: |
|
|
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 |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 8:39 pm Post subject: |
|
|
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 |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
|
Back to top |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Thu Jun 30, 2005 8:44 pm Post subject: |
|
|
they didn't work |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 8:45 pm Post subject: |
|
|
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 |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Thu Jun 30, 2005 8:48 pm Post subject: |
|
|
What does that mean?
Sry im new to this |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 8:55 pm Post subject: |
|
|
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 |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Thu Jun 30, 2005 8:57 pm Post subject: |
|
|
Im using dreamweaver and that is the only thing that is installed for php will it still work? |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 9:10 pm Post subject: |
|
|
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 |
|
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Thu Jun 30, 2005 9:29 pm Post subject: Re: Php Not Showing up |
|
|
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 |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Thu Jun 30, 2005 9:34 pm Post subject: |
|
|
That still doesn't work the single quote |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jun 30, 2005 9:35 pm Post subject: |
|
|
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 |
|
 |
The Little Guy -
Joined: 30 Jun 2005 Posts: 20
|
Posted: Fri Jul 01, 2005 11:15 pm Post subject: |
|
|
I downloaded it and read the installation instructions, and it still doesn't work. Maybe i didn't install it correctly. |
|
Back to top |
|
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Fri Jul 01, 2005 11:37 pm Post subject: |
|
|
Do you receive any error messages?
Are you loading the PHP page via Abyss? _________________ Olly |
|
Back to top |
|
 |
|