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

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 2261
$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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.