Page 1 of 2
How To Use Code - PLZ HELP
Posted: Wed Jan 22, 2003 5:45 pm
by m311ton
Alright, for starters I know nothing about PHP besides what I have read here and there around this website.
Recently I downloaded a news posting w/comments code from eveilwalrus.com but I have no clue how to get it to work or what to do with it. Its exactly what Im looking for and desperately need though. I need to be able to have a news headline on a webpage where people can come and comment on it. Please, if anyone would help and let me know what to do so I can get it to work!!
emmm...
Posted: Wed Jan 22, 2003 8:38 pm
by uberpolak
Urgh, that's kinda tricky with just that information, how far along have you got? Are you in a position where you have a bunch of code you know nothing about, or are you trying to customize it for your site and you got stuck? Asking someone to fix it all up for you without doing anything yourself is a pretty tall order, but some people might be up for it.
Posted: Thu Jan 23, 2003 3:21 am
by twigletmac
It might be an idea (if you haven't already) to do some tutorials:
http://www.php.net/tut.php
http://www.phpcomplete.com
http://www.phpbuilder.com
http://www.devshed.com
That way you can ask the right questions and you'll have a better understanding of the answers that you get. It makes it a lot easier for everyone really.
Mac
Posted: Thu Jan 23, 2003 6:46 pm
by m311ton
Alright, let me try and explain a problem in a simple code and maybe I can take the solution and apply it to the code I found...
As found on the tutorial, I used the following code...
<form action="action.php" method="POST">
Your name: <input type="text" name="name" />
Your age: <input type="text" name="age" />
<input type="submit">
</form>
and created a action.php with the following code...
Hi <?php echo $_POST["name"]; ?>.
You are <?php echo $_POST["age"]; ?> years old.
However when I fill out the information and click submit, on the following page nothing shows up. When I use a PHP editor, I get an error message that says "undefined index"......what does that mean?
Posted: Thu Jan 23, 2003 7:03 pm
by mydimension
if your version of php is less that 4.0.6 then you should use $HTTP_POST_VARS as oppsed to $_POST
Posted: Thu Jan 23, 2003 7:33 pm
by m311ton
Tried that, but I still get the error message..
Notice: Undefined index: name in action.php on line....
Posted: Thu Jan 23, 2003 9:03 pm
by mydimension
in the example you give everything should work. there is probably a problem with the actual code you are using. show us that along with the full error message. that should help.
Posted: Thu Jan 23, 2003 9:29 pm
by m311ton
Using the code that I posted before, I get this error message after clicking submit...
"
Hi
Notice: Undefined index: name in C:\WINDOWS\Desktop\asdf\action.php on line 9
. You are
Notice: Undefined index: age in C:\WINDOWS\Desktop\asdf\action.php on line 10
years old. "
Where C:\Windows\Desktop\asdf\ is where the files saved. Thats all there is to it, im confused

Posted: Fri Jan 24, 2003 12:00 am
by mydimension
that still dosen't help. can you do a complete copy&paste of your code so we can see exactly what is going on?
Posted: Fri Jan 24, 2003 6:15 pm
by m311ton
The following code is in index.htm
<html>
<head>
<title></title>
</head>
<body>
<form action="action.php" method="HTTP_POST_VARS">
Your name: <input type="text" name="name" />
Your age: <input type="text" name="age" />
<input type="submit">
</form>
</body>
</html>
And the following is in action.php
<html>
<head>
<title></title>
</head>
<body>
Hi <?php echo $HTTP_POST_VARS ["name"]; ?>.
You are <?php echo $HTTP_POST_VARS ["age"]; ?> years old.
</body>
</html>
Thats the exact code I am using and the error message is as follows
Hi
Notice: Undefined index: name in C:\WINDOWS\Desktop\asdf\action.php on line 9
. You are
Notice: Undefined index: age in C:\WINDOWS\Desktop\asdf\action.php on line 10
years old.
Posted: Fri Jan 24, 2003 10:22 pm
by mydimension
if that is a direct copy&paste then your problem lies in the fact that you have one space to many in the way you are calling the arrays. instead of:
use:
that should do it. if not then im stumped.
Posted: Sat Jan 25, 2003 1:01 pm
by m311ton
I greatly appreciate you taking the time to help me, but Im sorry to say that it still did not work. I have gone through multiple tutorials and done as you have suggested, but yet nothing seems to work. I guess PHP just isnt the way to go for now, so Ill try something else. Thank you again for your help, if anyone else has this problem/solution let me know.
Posted: Sat Jan 25, 2003 2:16 pm
by mydimension
im blind. in your form code you have this:
Code: Select all
<form action="action.php" method="HTTP_POST_VARS">
change it to this:
Code: Select all
<form action="action.php" method="post">
there are only two possible values for method, get and post
Posted: Sat Jan 25, 2003 3:32 pm
by m311ton
still doesnt work
Posted: Sat Jan 25, 2003 10:47 pm
by mydimension
tried seeing if i could duplicate there here on my machine but i couldn't. always worked fine. here is the code im using.
index.html:
Code: Select all
<html>
<head>
<title></title>
</head>
<body>
<form action="action.php" method="post">
Your name: <input type="text" name="name" />
Your age: <input type="text" name="age" />
<input type="submit">
</form>
</body>
</html>
action.php:
Code: Select all
<html>
<head>
<title></title>
</head>
<body>
Hi <?php echo $_POST['name']; ?>.
You are <?php echo $_POST['age']; ?> years old.
</body>
</html>
i am running PHP 4.3.0