Simple Insert into database problem
Posted: Sat Jun 14, 2003 1:44 am
I'm very new to php and I'm trying to insert some information from a form into my database. Right now, my form handling script is on the same page as the form and I'd prefer to keep it that way. My problem is that when I run it, I always get the same error....that there's an undefined variable. I've cut the script down into it's most basic form and here it is.
I think my problem might be what I should be putting as the form action; I know that it must be simple, but I'm not seeing it. The error message I'm getting is indicating that it's not recogizing "first_name" as a variable in my $sql line. This is the name of the field in the form however. Does it matter where this script is placed when it runs on the same page?
While I'm on the subject, what's the difference between using variables from forms as $variable versus the $HTTP_POST_VARS method? Thanks.
Code: Select all
<?php
require_once('Connections/connJF.php');//connects to database
mysql_select_db($database, $conn) or die ("Could not open database.");
$sql = "INSERT INTO applicants (first_name) VALUES ('$first_name')";
?>While I'm on the subject, what's the difference between using variables from forms as $variable versus the $HTTP_POST_VARS method? Thanks.