473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to pass form imput as variable to mysql?

hi!

I have simple form like
<form method="POST" action="create_db.php">
db name: <input type="text" name="db" size="20">
<br>
table name: <input type="text" name="table" size="20">
<br>
Skriv in field name: <input type="text" name="name" size="20">
<input type="submit" value="Submit"><input type="reset">
I want to pass thouse variable to create_db.php but having problems.. how
to do it?

<?
//create_db.php
$create ="CREATE DATABASE " + $db;

$link = mysql_connect(localhost,root);

if (! $link)
die("Couldn't connect to MySQL");
mysql_query( $create );
if ( $link ){ //om länk finns skapa tabel
mysql_select_db( $db, $link)
or die("Select DB Error: ".mysql_error());
mysql_query("CREATE TABLE $table( id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id), namn VARCHAR(30) )")
or die("Create table Error: ".mysql_error());
//sätter in värden från formen in i tabelen
mysql_query ("INSERT INTO personer ( name ) VALUES ('$name')");
}
else {
echo "succes";
mysql_close($link);
}
?>

--

Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my spelling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.

Jul 17 '05 #1
4 2267
$db = $_POST['db'];
$table= $_POST['table'];
$name= $_POST['name'];
"Carramba" <no****@note.com> wrote in message news:op.ssbn56upeel3e6@big...
hi!

I have simple form like
<form method="POST" action="create_db.php">
db name: <input type="text" name="db" size="20">
<br>
table name: <input type="text" name="table" size="20">
<br>
Skriv in field name: <input type="text" name="name" size="20">
<input type="submit" value="Submit"><input type="reset">
I want to pass thouse variable to create_db.php but having problems.. how
to do it?

<?
//create_db.php
$create ="CREATE DATABASE " + $db;

$link = mysql_connect(localhost,root);

if (! $link)
die("Couldn't connect to MySQL");
mysql_query( $create );
if ( $link ){ //om länk finns skapa tabel
mysql_select_db( $db, $link)
or die("Select DB Error: ".mysql_error());
mysql_query("CREATE TABLE $table( id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id), namn VARCHAR(30) )")
or die("Create table Error: ".mysql_error());
//sätter in värden från formen in i tabelen
mysql_query ("INSERT INTO personer ( name ) VALUES ('$name')");
}
else {
echo "succes";
mysql_close($link);
}
?>

--

Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my spelling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.

Jul 17 '05 #2
Carramba said the following on 13/06/2005 19:55:
hi!

I have simple form like
<form method="POST" action="create_db.php">
db name: <input type="text" name="db" size="20">
<br>
table name: <input type="text" name="table" size="20">
<br>
Skriv in field name: <input type="text" name="name" size="20">
<input type="submit" value="Submit"><input type="reset">
I want to pass thouse variable to create_db.php but having problems..
how to do it?

<?
//create_db.php
$create ="CREATE DATABASE " + $db;

$link = mysql_connect(localhost,root);

if (! $link)
die("Couldn't connect to MySQL");
mysql_query( $create );
if ( $link ){ //om länk finns skapa tabel
mysql_select_db( $db, $link)
or die("Select DB Error: ".mysql_error());
mysql_query("CREATE TABLE $table( id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id), namn VARCHAR(30) )")
or die("Create table Error: ".mysql_error());
//sätter in värden från formen in i tabelen
mysql_query ("INSERT INTO personer ( name ) VALUES ('$name')");
}
else {
echo "succes";
mysql_close($link);
}
?>


Use $_POST variables. See
http://www.php.net/manual/language.v...s.external.php

--
Oli
Jul 17 '05 #3
On Mon, 13 Jun 2005 20:55:08 +0200, Carramba wrote:
hi!

I have simple form like
<form method="POST" action="create_db.php"> db name: <input type="text"
name="db" size="20"> <br>
table name: <input type="text" name="table" size="20"> <br>
Skriv in field name: <input type="text" name="name" size="20"> <input
type="submit" value="Submit"><input type="reset">
I want to pass thouse variable to create_db.php but having problems.. how
to do it?

<?
//create_db.php
$create ="CREATE DATABASE " + $db;

$link = mysql_connect(localhost,root);

if (! $link)
die("Couldn't connect to MySQL");
mysql_query( $create );
if ( $link ){ //om länk finns skapa tabel
mysql_select_db( $db, $link)
or die("Select DB Error: ".mysql_error()); mysql_query("CREATE TABLE
$table( id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id), namn VARCHAR(30) )") or die("Create table Error:
".mysql_error());
//sätter in värden från formen in i tabelen mysql_query ("INSERT INTO
personer ( name ) VALUES ('$name')");
}
else {
echo "succes";
mysql_close($link);
}
?>


Fixinf the logic in your php would help as well (:
Jul 17 '05 #4
On Tue, 14 Jun 2005 07:53:15 +0200, Steve <Th*****@Aint.Valid> wrote:
On Mon, 13 Jun 2005 20:55:08 +0200, Carramba wrote:
hi!

I have simple form like
<form method="POST" action="create_db.php"> db name: <input type="text"
name="db" size="20"> <br>
table name: <input type="text" name="table" size="20"> <br>
Skriv in field name: <input type="text" name="name" size="20"> <input
type="submit" value="Submit"><input type="reset">
I want to pass thouse variable to create_db.php but having problems..
how
to do it?

<?
//create_db.php
$create ="CREATE DATABASE " + $db;

$link = mysql_connect(localhost,root);

if (! $link)
die("Couldn't connect to MySQL");
mysql_query( $create );
if ( $link ){ //om länk finns skapa tabel
mysql_select_db( $db, $link)
or die("Select DB Error: ".mysql_error()); mysql_query("CREATE TABLE
$table( id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id), namn VARCHAR(30) )") or die("Create table Error:
".mysql_error());
//sätter in värden från formen in i tabelen mysql_query ("INSERT INTO
personer ( name ) VALUES ('$name')");
}
else {
echo "succes";
mysql_close($link);
}
?>


Fixinf the logic in your php would help as well (:


what do you mean

p.s. proglem is solvt
--

Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my spelling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.

Jul 17 '05 #5

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

Similar topics

6
by: HH | last post by:
I'm learning to design web applications with php, mysql, and apache from a book. I copied a sample application called guestbook 2000 that came with the CD in the book to my htdocs folder, but...
3
by: Nath | last post by:
Please help!? I am new to writing html, javascript, pretty new to MySQL but quite proficient at writing Perl and i'm a quick learner. I am building a database driven website and i am a little...
2
by: misschristalee | last post by:
I'm having a brain blockage day.... Scenario: Search Form with 6 text boxes Query has same six fields Each has this IIF: IIf(IsNull(!!),"",!!) with each dictating the correct text box of...
7
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
1
by: Garry Jones | last post by:
When processing a form I am reading in a value to a mysql database. I then redirect the user to a "thank you" page with Header. What I would like is to remind the user the value he/she keyed in....
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
7
by: jcnone | last post by:
Does anyone know how to populate form fields on a html web page (client side) with data from an Excel file (CSV) or text file. I am currently having to input data to many text fields manually. I...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
9
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.