473,385 Members | 1,542 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,385 software developers and data experts.

PHP:Unable to post variables from html form to mysql database

hello experts,
Plz dont treat this as another newbie query , i did my homework but
still getting nowhere :( :( :(

Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to
post data from html form to php file(connecting to mysql database and
inserting into a table) .
This seemingly simple problem is making me go mad !!! I googled
extensively and already tried the following

I enabled " register_globals = On " .... in /etc/php.ini and
also took used _$POST syntax.

wot could be the problem .... is it the case that /etc/php.ini file is
not being read .... how do i know whether this is the default location
for php.ini?
Where can i find the PHPRC environment variable (the variable
responsible for the php.ini default location)

Is the problem something else .....?

Plz help me out experts!!!!

Thx Adv

Regards,
Sammista.

Following is the code ...

form.html
---------
<HTML>
<HEAD>
<TITLE> email entry form </TITLE>
</HEAD>
<BODY>

<P>plz fil the form </P>

<FORM METHOD="POST" ACTON="form-handler.php">

NAME: <BR>
<INPUT TYPE=TEXT NAME="givename" SIZE=25> <BR>
AGE: <br>
<INPUT TYPE=TEXT NAME="givenaddress" SIZE=25> <BR>

<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
form-handler.php
-----------------
<HTML>
<HEAD>
<TITLE> EMAIL FORM HANDLER </TITLE>
</HEAD>

<BODY>

<?
mysql_connect("localhost","root") or die("Failure on db connection");

mysql_select_db("mydb");

//$query = " insert into sample(name,address)
values(_$POST['givename'],_$POST['givenaddress'])";
$query = " INSERT INTO sample SET
name = '_$POST[givename]',
address = '_$POST[givenaddress]' ";

$result = mysql_query($query) or die("Unable to record your info");
print("result:$result");
print("your info has been recorded");

?>

</body>
</html>
Jul 17 '05 #1
3 3512
jf
_$POST ???

$_POST !!

or if it isn't the problem try in a file info.php:
<?php phpinfo(); ?>
On 29 Sep 2004 12:23:12 -0700
sa*******@gmail.com (sammmista) wrote:
hello experts,
Plz dont treat this as another newbie query , i did my homework but
still getting nowhere :( :( :(

Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to
post data from html form to php file(connecting to mysql database and
inserting into a table) .
This seemingly simple problem is making me go mad !!! I googled
extensively and already tried the following

I enabled " register_globals = On " .... in /etc/php.ini and
also took used _$POST syntax.

wot could be the problem .... is it the case that /etc/php.ini file is
not being read .... how do i know whether this is the default location
for php.ini?
Where can i find the PHPRC environment variable (the variable
responsible for the php.ini default location)

Is the problem something else .....?

Plz help me out experts!!!!

Thx Adv

Regards,
Sammista.

Following is the code ...

form.html
---------
<HTML>
<HEAD>
<TITLE> email entry form </TITLE>
</HEAD>
<BODY>

<P>plz fil the form </P>

<FORM METHOD="POST" ACTON="form-handler.php">

NAME: <BR>
<INPUT TYPE=TEXT NAME="givename" SIZE=25> <BR>
AGE: <br>
<INPUT TYPE=TEXT NAME="givenaddress" SIZE=25> <BR>

<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
form-handler.php
-----------------
<HTML>
<HEAD>
<TITLE> EMAIL FORM HANDLER </TITLE>
</HEAD>

<BODY>

<?
mysql_connect("localhost","root") or die("Failure on db connection");

mysql_select_db("mydb");

//$query = " insert into sample(name,address)
values(_$POST['givename'],_$POST['givenaddress'])";
$query = " INSERT INTO sample SET
name = '_$POST[givename]',
address = '_$POST[givenaddress]' ";

$result = mysql_query($query) or die("Unable to record your info");
print("result:$result");
print("your info has been recorded");

?>

</body>
</html>

Jul 17 '05 #2
sammmista wrote:
hello experts,
Plz dont treat this as another newbie query , i did my homework but
still getting nowhere :( :( :(

Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to
post data from html form to php file(connecting to mysql database and
inserting into a table) .
This seemingly simple problem is making me go mad !!! I googled
extensively and already tried the following

I enabled " register_globals = On " .... in /etc/php.ini and
also took used _$POST syntax.

<snip>

1.
it is NOT _$POST but $_POST!

2.
to check if your ini is used try the command phpinfo(); you can see your
settings then - if you change something it should be there too.

3.
try to turn error reporting on when developing scripts. do this by
starting your script with something like
<?php
error_reporting(E_ALL);

that might put out a lot of notices too but helps writing clean code.

4.
to find out where php looks for his ini just turn to the manual. i
prefer using the directive in the apache httpd.conf

PHPIniDir "/your/path"

regards
sh

--
"The goal of Computer Science is to build something that will last at
least until we've finished building it." -- unknown
Jul 17 '05 #3
sammmista wrote:
I enabled " register_globals = On " .... in /etc/php.ini and
also took used _$POST syntax.
Famous last words: "I don't know how to deactivate this time bomb. I
better press every button I see."
wot could be the problem .... is it the case that /etc/php.ini file is
not being read .... how do i know whether this is the default location
for php.ini?
<?php phpinfo(); ?>
Where can i find the PHPRC environment variable (the variable
responsible for the php.ini default location)
Somewhere in the source code.
Is the problem something else .....?
Yes, it is.
<FORM METHOD="POST" ACTON="form-handler.php">
"ACTON" should be "action".
<?
You don't want to start this block with "<?". Use "<?php".
$query = " INSERT INTO sample SET
name = '_$POST[givename]',
address = '_$POST[givenaddress]' ";
Ouch!

Look up the syntax for INSERT and use $_POST instead of _$POST. If you
go to your php.ini and set your error_reporting to E_ALL, you might be
able to find some of those errors by yourself.
$result = mysql_query($query) or die("Unable to record your info");


Not very friendly, eh? Have a look at mysql_error().

Regards,
Matthias
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Rozman | last post by:
Hi, I bet there are some free SW, that will generate web interface for existing mysql database ? Could you point me in right direction ? Thanks in advance, regards, Rob.
3
by: Armin Irger | last post by:
Hi, i'am running a debian sarge with the delivered apache2 mysql and php4. The file "mitarbeiter_eingabe.php" gets the data over a html <FORM> and send it to...
9
by: christopher_board | last post by:
Hi all. I am trying to write a php page which connects to a MySQL Database which is supposed to get the results from a table within a database and display the results in a table. Below is the...
6
by: fpcreator2000 | last post by:
Hello everyone. I'm having problems with a page I've created that is used to insert data into a database. It uploads two files into two distinct folder, and it takes the filenames and inserts...
1
by: updesigns | last post by:
I am currently using a php form to update data into a mysql database. Am unsure how to use a php script to upload a file and copy the url link into the mysql database
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
8
johngault
by: johngault | last post by:
I've been working with this PHP page for several days now and I'm stumped. The page is supposed to allow the user to upload up to six images for their profile. When the user adds an image it (the...
1
by: chanshaw | last post by:
Alright so I got php running and installed i have mysql running and installed the thing im having a hard time with is having the php to call information from the mysql database. Im on Windows Vista...
2
by: puneetmca | last post by:
hi i want to insert employees DOB into database through html forms but my code is not working....only empty record is shown in the database in edob ..rest of the records are working...
0
by: adajon92 | last post by:
I have a problem with mySQL database. To start off, I'm a super N00b and am trying to make a web page using PHP and MySQL for a class project. Currently the database and website are...
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
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.