473,383 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Variables not passing from html file to php file

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
2 3159
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Richards Noah \(IFR LIT MET\) | last post by:
I'm trying to test some cgi php, but do not have access to a webserver (in any way, shape, or form). I've been trying to fudge testing by using the CLI php.exe in the windows distribution. I've...
1
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
2
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
37
by: eoindeb | last post by:
Sorry to ask another global variable question, but from reading other posts I'm still not sure whether to use them or not. I have a program with a set function that calls 4 other functions in...
5
by: wolfing1 | last post by:
I'm working on a shopping cart page. In page A (checkout) the user enters their credit card information. On postback, if everything is correct, it sends the user to page B (confirmation). My...
3
by: dirk | last post by:
Hello, As beginner, I'm a bit confused by passing 2 variables using a html-form with method=POST. If passing one of them, it works ; if passing both together, nope. At least when I reload the...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.