Kyle Y.
Kyle Y.

Reputation: 175

Cannot copy $_POST variables into regular variables

I am trying to copy variables from a form into easier-to-write variables like so:

$first = $_POST["first"];
$last = $_POST["last"];
$phone = $_POST["phone"];
$card = $_POST["card"];

I know the $_POST variables have substance because I am able to echo them, see the value I entered from the HTML form, and use the $_POST variables directly in the rest of my code. However, for some reason I keep getting this XAMPP error when I execute the php file:

Notice: Undefined variable: first in C:\xampp\htdocs\DataFinal.php on line 78

(I get 1 error for each variable)

What am I doing wrong?

Upvotes: 3

Views: 695

Answers (1)

user229044
user229044

Reputation: 239452

Presumably you're copying them into variables in some local scope that isn't shared by DataFinal.php's line 78. Otherwise the code you've posted is correct; that is indeed variable assignment. It doesn't get much simpler.

Upvotes: 1

Related Questions