?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?inserting data from form
Author:??(---.as1.athlone1.eircom.net)
Date:???03-22-03 16:00

hey guys.
i'm new to php and have a problem inserting data into a mysql table from a form. its connecting ok and comes up data inserted successfully and a new row gets created but the data is blank. any help would be appreciated. thanx. my code is below

HTML



Name:
Email:





PHP
$connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server');
$db = mysql_select_db("test", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO registration (Name,Email)
VALUES ('$name','$email')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>

?Re: inserting data from form
Author:?fred?(---.beeb.net)
Date:???03-23-03 04:13

try

$name=$_POST{'name'];
$email=$_POST['email'];

$connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server');
$db = mysql_select_db("test", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO registration (Name,Email)
VALUES ('$name','$email')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>

?whoops error in above
Author:?fred?(---.beeb.net)
Date:???03-23-03 04:15

wrong bracket used. this should work ;)

$name=$_POST['name'];
$email=$_POST['email'];

$connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server');
$db = mysql_select_db("test", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO registration (Name,Email)
VALUES ('$name','$email')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>

?Re: whoops error in above
Author:??(---.as1.athlone1.eircom.net)
Date:???03-23-03 07:52

no, its still inserting blanks. thanx anyways

?Re: inserting data from form
Author:??(64.90.68.---)
Date:???03-24-03 09:12

in the line:

$sql = "INSERT INTO registration (Name,Email)


I think you'll need them all lowercase (name, email)

since that's how the form field is named.

?Re: inserting data from form
Author:??(---.240-203-24.mtl.mc.videotron.ca)
Date:???03-31-03 12:07

Hi, ive seen the problem that irishstudent is mentionating...
i took the part of fred and i modifiated a low bit and its giving a blanks record in the database so let show theses codes there:
---------------------------------------------------------------
file name: setuppass.php
---------------------------------------------------------------
include ("config/config.php");

$username=$_post['username'];
$passwd=$_post['userpass'];

$connection=mysql_connect("$host","$user","$pass") or die('Could not connect to the database server');
$db = mysql_select_db($datab, $connection) or die ("Unable to select database.");
$sql = "INSERT INTO '$tables' (username,passwd)
VALUES ('$username','$passwd')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>

---------------------------------------------------------------
File name: setup.php
---------------------------------------------------------------



Untitled Document

















Login Name:
Password :
?






--------------------------------------------------------------
File Name: ./config/config.php
--------------------------------------------------------------

$host = "localhost"; //localhost or serveur
$user = "username"; //username
$pass = "password"; //passwd
$datab = ""; //Your Database name
$table = ""; //The table name
?>


--------------------------------------------------------------
And in my MySQL database in the table that i gived to get those records is getting a Blank record... and i passed a little time to look around php site some cue about that... I havec an idea that wrong with multiple insert variables that make some mistake coz ive try to insert only 1 variables and its working mabe with 2 var isnt... why? what i did wrong it that script plz?

?Re: inserting data from form
Author:??(---.240-203-24.mtl.mc.videotron.ca)
Date:???04-08-03 14:26

There are no one can answer me there ?!? plz im realy blocked in!

Go to Top??|??Go to Topic??|??Threaded View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??

Provided By
Phorum