Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I wrote a code to insert information from text field into database by clicking a submit button but I don’t know why it wouldn't out. I'll appreciate if you can help to solve this problem.Code: Select all
<?php
if ($_POST[submit] == "Submit")
{
$host_name = 'localhost'; // Set this to your Database Name
$database_name= 'login';
$database_username = 'root'; // Set this to your MySQL username
$database_password = 'root'; // Set this to your MySQL password
$connect = mysql_pconnect($host_name,$database_username, $database_password)
or die ("coneect nashod jigar");
$db = mysql_select_db( $database_name, $connect) or die ("select nashod jigar");;
$textfield = $_POST['textfield'];
$textfield2 = $_POST['textfield2'];
$query = "INSERT INTO logindata (username, passw) VALUES ($textfield, $textfield2)";
mysql_query($query,$connect) or die('Error, insert query failed');
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]