By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,899 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,899 IT Pros & Developers. It's quick & easy.

Variables not passing from html file to php file

P: n/a
I have the following two files used to insert data into a database. when
meinsert.php is executed a blank record is inserted in the database as if
the .php file is not receiving the variables.

Any ideas why this might be happening? Environment is stock RH9 with no
updates. I believe it is PHP 4.2.2 and Apache 2.0.40.

Thanks,

Mike

meinsert.html
<html>
<body>
<form action="meinsert.php" method="post">
Last Name: <input type="text" name="lastname"><br>
His Name: <input type="text" name="hisname"><br>
Her Name: <input type="text" name="hername"><br>
Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip: <input type="text" name="zip"><br>
Phone Number: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
Weekend Date: <input type="date" name="WkEndDate"><br>
Wedding Date: <input type="text" name="weddate"><br>
Referred By: <input type="text" name="referred"><br>
Prayer Couple: <input type="text" name="prayercouple"><br>
Paid: <input type="text" name="paid"><br>
Area: <input type="text" name="area"><br>
<input type="submit" value="SUBMIT"><br>
</form>
</body>
</html>

meinsert.php
<html>
<head>
<title>Insert Couple to Database</title>
</head>
<body>

<?php

//connect to database server
$dbcnx = @mysql_connect("localhost", "root", "password");

if (!dbcnx) {
echo( "<p>Unable to connect to the database server.<p>");
exit();
}

if (! @mysql_select_db("ME") ){
echo ( "<p>Unable to locate the ME database.</p>" );
exit ();
}
echo ("Adding Couple");
//if ($submitcouple == "SUBMIT"){
echo ("getting here!<br>");
$sql = "INSERT INTO Couples SET
LastName = '$lastname',
HisName = '$hisname',
HerName = '$hername',
Address = '$address',
City = '$city',
State = '$state',
Zip = '$zip',
Phone = '$phone',
eMail = '$email',
WkEndDate = '$WkEndDate',
WeddingDate = '$weddate',
Referred = '$referred',
PrayerCouple = '$prayercouple',
Paid = '$paid',
Location = '$area'";

if (@mysql_query($sql)){
echo ( "<p> " . $hisname . "and " . $hername . "have been added to the
database.</p>");
}else{
echo ("<p>Error adding couple to the database: " . mysql_error() .
"</p>");
}

//}

?>
</body>
</html>
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
A horsie named Mike Wilcox demonstrated surprising intelligence and its
ability to use morse code on Tue, 09 Sep 2003 23:07:55 -0500 when it
tapped <vsx7b.407198$Ho3.61795@sccrnsc03> with its hoof:
I have the following two files used to insert data into a database. when
meinsert.php is executed a blank record is inserted in the database as
if the .php file is not receiving the variables.

[...]

echo ("Adding Couple");
//if ($submitcouple == "SUBMIT"){
echo ("getting here!<br>");
$sql = "INSERT INTO Couples SET
LastName = '$lastname',


Try:
LastName = '_$POST[lastname]',

The register_globals option is probably off.

Jul 16 '05 #2

P: n/a

My money is on the fact that you have global variables turned off.

/Marcin

Mike Wilcox wrote:
I have the following two files used to insert data into a database. when
meinsert.php is executed a blank record is inserted in the database as if
the .php file is not receiving the variables.

Any ideas why this might be happening? Environment is stock RH9 with no
updates. I believe it is PHP 4.2.2 and Apache 2.0.40.

Thanks,

Mike

meinsert.html
<html>
<body>
<form action="meinsert.php" method="post">
Last Name: <input type="text" name="lastname"><br>
His Name: <input type="text" name="hisname"><br>
Her Name: <input type="text" name="hername"><br>
Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip: <input type="text" name="zip"><br>
Phone Number: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
Weekend Date: <input type="date" name="WkEndDate"><br>
Wedding Date: <input type="text" name="weddate"><br>
Referred By: <input type="text" name="referred"><br>
Prayer Couple: <input type="text" name="prayercouple"><br>
Paid: <input type="text" name="paid"><br>
Area: <input type="text" name="area"><br>
<input type="submit" value="SUBMIT"><br>
</form>
</body>
</html>

meinsert.php
<html>
<head>
<title>Insert Couple to Database</title>
</head>
<body>

<?php

//connect to database server
$dbcnx = @mysql_connect("localhost", "root", "password");

if (!dbcnx) {
echo( "<p>Unable to connect to the database server.<p>");
exit();
}

if (! @mysql_select_db("ME") ){
echo ( "<p>Unable to locate the ME database.</p>" );
exit ();
}
echo ("Adding Couple");
//if ($submitcouple == "SUBMIT"){
echo ("getting here!<br>");
$sql = "INSERT INTO Couples SET
LastName = '$lastname',
HisName = '$hisname',
HerName = '$hername',
Address = '$address',
City = '$city',
State = '$state',
Zip = '$zip',
Phone = '$phone',
eMail = '$email',
WkEndDate = '$WkEndDate',
WeddingDate = '$weddate',
Referred = '$referred',
PrayerCouple = '$prayercouple',
Paid = '$paid',
Location = '$area'";

if (@mysql_query($sql)){
echo ( "<p> " . $hisname . "and " . $hername . "have been added to the
database.</p>");
}else{
echo ("<p>Error adding couple to the database: " . mysql_error() .
"</p>");
}

//}

?>
</body>
</html>


Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.