Jump to content

Help Regarding Database Entry!!


amitojduggal

Recommended Posts

Hello Everyone,

i need help regarding following issue,
i have a main form on which users enter data, when they click submit link, i made a check whether they have entered data correctly or not. so the next page actually displays the data they have entered, now i want that data to be entered in the database, as the user clicks submit link on the page. MYSQL is the database.
Tell me how i can achieve that. If possible please tell steps and basic code formation...

Thank you
Amitoj
Link to comment
https://forums.phpfreaks.com/topic/27452-help-regarding-database-entry/
Share on other sites

[code] if ($_POST[checkbox]=="agree")
  {
  if (($_POST[textfield3] =="") or($_POST[textfield]=="") or($_POST[textfield2]=="") or
  ($_POST[textarea]=="")or ($_POST[textfield4]=="") or($_POST[textfield5]=="") )
  { echo " Please Fill IN Complete Information";
  }
  else
  {
  echo "Your Name : <b>$_POST[textfield3]</b><BR>";
 
  echo "Name Of The Company : <b>$_POST[textfield]</b><BR>";
  echo "Your Designation : <b>$_POST[textfield2]</b><BR>";
  echo "Response Message : <b>$_POST[textarea]</b><BR>";
  echo " Contact Information<BR>";
  echo "Phone Number : <b>$_POST[textfield4]</b><BR>";
  echo "Email Id : <b>$_POST[textfield5]</b><BR>";
  echo "Review Of The Presentation : <b>$_POST[q]</b><BR>";

  echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"Thanks.php\">";
  echo "<label></label>";

  echo "<div align=\"center\">";
  echo "    <input type=\"submit\" name=\"Submit\" value=\"Submit\" />";
  echo " </div>";
    echo " <label>";
   
  echo " <div align=\"center\"></div>";
  echo" </label>";
  echo "</form>";[/code]


This is the php part of my document
Now i want the values in textfield3,2 ,1 and so on to be entered in the database(MYSQL)
How to do that??
Please tell me steps....
Amitoj
Do you have the table built already? Here is start for you this would go into the else area
[code]
<?
$dbhostname="localhost"; #this is the name of the machine the database id running on could also be an IP
$dbusername="change_this"; #this is the user name that has permission to the database
$dbpassword="change_this"; #this is the password of the user ($dbusername) that has permisson to the database
$dnname="change_this"; #this is the name of the database that you are using

$textfield1 = $_POST[$textfield1];
$textfield2 = $_POST[$textfield2];
$textfield3 = $_POST[$textfield3];
$linkID = mysql_connect($dbhostname, "$dbusername", "$dbpassword") or die('I cannot connect to the database.');

mysql_select_db("$dnname");

$sql_addrecord="INSERT INTO table_name(id, name, email, homepage, comment)
VALUES ('$textfield1', '$textfield2', '$textfield3');";

$result = mysql_query($sql_addrecord);

mysql_close($linkID);
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.