8
Contributors
13
Replies
21
Views
6 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1
    diafol 3,669   6 Years Ago

    how to use Google? how to use php.net? how to use forum search? how to show us your code so far? Read More

0

To insert data into Mysql DB using PHP yop should have to use Mysql insert statement.
An Example of this
HTML page script .
<form action ="next.php" method="post" >
<input type ="text" name="name" />
</form>

page next.php
$link = mysql_connect("Server name","username","passwd");
mysql_select_db("db name"):
$result = mysql_query("insert into tablenmae values($_POST[name])");
if($result)
echo "Record inserted.";

0

So to insert value to mysql there are following steps

1. make connectio to mysql using
$con=mysql_connect("[server ip/address]","[user]","[password]")
eg:-

$con=mysql_connect("localhost","root","");

2. select the database
$db=mysql_select_db("database_name",$con);
eg:-

$db=mysql_select_db("employee",$con);

3. insert the data into database using mysql query
$res=mysql_query("Insert into abc values('field1'...);
eg:

$query=mysql_query("Insert into abc values('iim','manager')");

Hopefully it's clear...
If you have any doubt just click here

0

thankz both 3 of you :)....i know how to use google but i only post here to have a second option in case i cant find anything in google...

@ardav.....if you cant answer nicely ... just dont reply ...... and btw thanks for the
effort :)

0

You waste everybody's time with inane questions like this.

how to insert data into mysql database using a textbox in php?

and this statement:

i only post here to have a second option in case i cant find anything in google

Why don't you just search Google and get a script, fiddle with it and come back when you hit a problem.

.if you cant answer nicely ... just dont reply

That's rich, if you can't be bothered to do some work for yourself, don't post. Read the guidelines. You should show some effort yourself.

Edited by diafol: n/a

0

wasting time? ....what is daniweb made for? ...actually i just pass by and drop some thread to see if somebody is replying and yeah they reply ..


Why don't you just search Google and get a script, fiddle with it and come back when you hit a problem.

thats what i said ..then i hit the thing called problem and i need some clear tuts


oh yeah you dont know what your talking .........


well yeah overall you win ... my fault :)

Edited by uselessninja: n/a

0

how to insert data into mysql database using a textbox in php?

Dear valued member, any body please send me code to INSEETDATAQUERY IN OOP PHPWITH MYSQL

Edited by Ezzaral: Snipped 'fake sig' link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.

0
<form action ="#" method="post" >
<input type ="text" name="name" />
<input type ="submit" name="submit" value="submit" />
</form>
<?php
if(isset($_POST['submit']))
$link = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$result = mysql_query("insert into tablenmae values('".$_POST[name]."')") or die(mysql_error());
if($result)
{
  echo "values inserted.";
}
else
{
  echo'Not inserted';
}

Edited by pritaeas: Removed self-promotion link.

0

Try this code:

Processor.php

<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

mysqli_query($con,"INSERT INTO Persons (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin',35)");

mysqli_query($con,"INSERT INTO Persons (FirstName, LastName, Age) 
VALUES ('Glenn', 'Quagmire',33)");

mysqli_close($con);
?>

Registration.php


<html>
<body>

<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname">
Lastname: <input type="text" name="lastname">
Age: <input type="text" name="age">
<input type="submit">
</form>

</body>
</html>
0

Dear new members, could you please stop necroposting to this thread. It died a natural death, but has now been resurrected. There are many similar threads in DW that were satisfactory answered.

The OP did not show any effort himself and did not think to read our guidelines. Therefore, he didn't really deserve a 'full solution'. In addition, providing solutions to dead threads like this only serves to clutter up our forum thread list with this nonsense. If you wish to show off your ability, then consider writing a cope snippet or a tutorial.

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.