Try this:

extract($_POST);

extract --  Import variables into the current symbol table from an array

All of my forms have worked without $_POST or $_GET. Is there a reason for
inavailability of variables???

Its a good practice to use $_POST for security reasons.

Vishal.

-----Original Message-----
From: Ciemny, Jessica [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 30, 2004 10:30 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Passing <form> values to PHP


Hey every, I'm new to the group and to PHP (3 days now) and I would like to
ask a question. I purchased a book on PHP a day or so ago and as I'm going
through the book it comes to a point where it talks about passing html form
values to PHP. So I type up the examples from the book, both the html file
and the PHP file and I run it and I don't get anything when the PHP file is
accessed. Hmmmm puzzling! I don't get any errors at all, but the values just
aren't coming across.

The book says that I should be able to take the "name=xyz" value from the
HTML form and just use it as a regular variable ($xyz) in the PHP file. But
this doesn't work.

After much digging on web pages and through email lists I found reference to
something called the $_POST variable. This seems to be the only way that I
can make the PHP file use the "name=xyz" values from the HTML file. So in
the PHP file I would have to use the variable "$_POST[xyz]" to get the form
value returned.

Anyone have any ideas as to what's up. I hope its just something silly that
I'm missing being a newby to PHP and all.

I will include small versions of the file here for reference:

HTML FILE
---------

<html><body>
<form action="x.php" method="post">
Please enter your name:
<input type="text" name="xyz">
<input type="submit" value="submit">
</form>
</body></html>


PHP FILE (Doesn't Work)
---------
<html><body>
<?php
echo("The value of name is $xyz");
?>
</body></html>


PHP FILE (Does Work)
---------
<html><body>
<?php
echo("The value of name is $_POST[xyz]");
?>
</body></html>

So I guess my question ultimately is, what are the different ways in which
form data can be passed to a PHP script?

Thanks you,

Jessica

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to