How To Use Code - PLZ HELP
Moderator: General Moderators
How To Use Code - PLZ HELP
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!!
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...
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.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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
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
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?
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?
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
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
"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
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
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.
<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.
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
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.
Code: Select all
$HTTP_POST_VARS ї"name"]Code: Select all
$HTTP_POST_VARSї"name"]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.
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
im blind. in your form code you have this:
change it to this:
there are only two possible values for method, get and post
Code: Select all
<form action="action.php" method="HTTP_POST_VARS">Code: Select all
<form action="action.php" method="post">- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
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:
action.php:
i am running PHP 4.3.0
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>Code: Select all
<html>
<head>
<title></title>
</head>
<body>
Hi <?php echo $_POST['name']; ?>.
You are <?php echo $_POST['age']; ?> years old.
</body>
</html>