Last active
February 18, 2017 20:01
-
-
Save nikolaykrylov/9784c6be2b8622842a9cc262fbd4f784 to your computer and use it in GitHub Desktop.
Write from form to database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'login.php'; | |
$con = mysqli_connect($db_hostname, $db_username, $db_password, $db_database); | |
mysqli_set_charset($con, "utf8"); | |
if (mysqli_connect_errno()) { | |
echo "Failed to connect to MySQL:" . mysqli_connect_error(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'connect.php'; | |
if (isset($_POST['name']) && | |
isset($_POST['surname'])) { | |
$name = $_POST['name']; | |
$surname = $_POST['surname']; | |
$query = "INSERT INTO `mytable1` VALUES (NULL, '$name', '$surname');"; | |
$info = mysqli_query($con, $query); | |
} | |
?> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset = "utf-8"> | |
</head> | |
<body> | |
<form method="POST" action="form2.php"> | |
<input name="name" type="text" placeholder="Имя"/> | |
<input name="surname" type="text" placeholder="Фамилия"/> | |
<input type="submit" value="Отправить"/> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db_hostname = 'localhost'; | |
$db_database = 'mydb1'; | |
$db_username = 'root'; | |
$db_password = ''; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment