Page 1 of 1

Storing previous form data in database

Posted: Sun Oct 24, 2010 8:40 pm
by miss
i have created a login page and redirected to nextpage .In that page some details is to be filled and stored in the database along with loginusername..
this is my code...

Code: Select all

<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("Marketing") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE Marketingemployeetable(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
Employeeid varchar(15), Date date,Sector varchar(30),Place varchar(40),Contactpersonname varchar(30),contactaddress varchar(30),Mobileno varchar(12))")
or die(mysql_error()); 

echo "Table Created!";

?>

Code: Select all

<?php
$con = mysql_connect("localhost","root", "");
if (!$con)
{die('Could not connect to DB: ' . mysql_error() );} 
mysql_select_db ("Marketing", $con);
$date = $_POST['month'].$_POST['dt'].$_POST['year'] ; 
$myusername=$_POST['myusername'];
$sql="INSERT INTO Marketingemployeetable (Employeeid, Date,Sector,Place,Contactpersonname,Contactaddress,Mobileno)VALUES ('$myusername','$date','$_POST[project]','$_POST[place]','$_POST[Contactpersonname]','$_POST[Contactaddress]','$_POST[Mobileno]')"; 
if (!mysql_query($sql,$con))
{die ('Error: ' . mysql_error());}
echo "Record added"; 
mysql_close($con)?>
here i am grabing myusername from previous form...I dont whether i am going correct or wrong..please help me out






scottayy wrote:Please use the syntax tags when posting code

Re: Storing previous form data in database

Posted: Mon Oct 25, 2010 12:47 am
by requinix
General Posting Guidelines

And don't create duplicate threads.

Re: Storing previous form data in database

Posted: Mon Oct 25, 2010 1:09 am
by John Cartwright
Locked.