0

insert.php

<?php
$dbun = "$_POST[dbun]";
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$sql="INSERT INTO $dbun (sn, date, particular, dr, cr)
VALUES
('$_POST[sn]','$_POST[date]','$_POST[ptr]','$_POST[dr]','$_POST[cr]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>

DB name = my_db

user.php

<html>
<body>

<form action="db.php" method="post">
NEW DATA BASE USER: <input type="text" name="snn" />
<input type="submit" />
<br>
<form action="db.php" method="post">
DATA BASE USER NAME: <input type="text" name="dbun" />

<input type="submit" />
</form>

</body>
</html>

db.php

<?php
$snn = "$_POST[snn]";
		
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE $snn
(
Sn int,
Date int,
Particular varchar(15),
Dr int,
Cr int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>

index.php

<form action="insert.php" method="post">
 
      DB User name: 
      <input type="text" name="dbun" />
      <br>
      Sn: 
      <input type="text" name="sn" />
      <br>
      Date: 
      <input type="text" name="date" />
      <br>
      Particurar: 
      <input type="text" name="ptr" />
      <br>
      Dr: 
      <input type="text" name="dr" />
      <br>
      Cr:</span>
      <input type="text" name="cr" />
       <br>
      <br>
      <input type="submit" />
      

</form>
<a href="user.php">USER</a></span>
<a href="output.php">OUT PUT</a>
</body>
</html>

My question is how to edit my sql data that already entered with html post plz help....

2
Contributors
6
Replies
17
Views
6 Years
Discussion Span
Last Post by dono.reseller
0

sorry db.php is this

<?php
$snn = "$_POST[snn]";
		
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create table
mysql_select_db("my_db", $con);
$sql = CREATE TABLE $snn
(
Sn int,
Date int,
Particular varchar(15),
Dr int,
Cr int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>
0

sorry db.php is this

<?php
$snn = "$_POST[snn]";
		
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create table
mysql_select_db("my_db", $con);
$sql = CREATE TABLE $snn
(
Sn int,
Date int,
Particular varchar(15),
Dr int,
Cr int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>
0

1st new data user to creat new table in index.php

0

and we have to enter data but how to edit that entered data

0

sorry db.php is here

<?php
$snn = "$_POST[snn]";
		
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create table
mysql_select_db("my_db", $con);
$sql = CREATE TABLE $snn
(
Sn int,
Date int,
Particular varchar(15),
Dr int,
Cr int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.