Created
August 2, 2013 07:48
-
-
Save ezos86/6138174 to your computer and use it in GitHub Desktop.
This is a basic Database Insert
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
<!DOCTYPE> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<form action="db-insert.php" method="post"> | |
<label for="firstName">First Name:</label> | |
<input id="firstName" name="firstName" value="" /> | |
<br> | |
<label for="lastName">Last Name:</label> | |
<input id="lastName" name="lastName" value="" /> | |
<br> | |
<label for="age">Age:</label> | |
<input id="age" name="age" value="" /> | |
<input type="submit" /> | |
</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 | |
$firstName = $_POST['firstName']; | |
$lastName = $_POST['lastName']; | |
$age = $_POST['age']; | |
echo $firstName . ' ' . $lastName . ' '. $age; | |
$dbn = mysqli_connect('localhost', 'root', '', 'peach_db') or die(mysqli_error('error')); | |
$query = "INSERT INTO Persons (PID,FirstName, LastName, Age) VALUES (Null,'".$firstName."','".$lastName."',".$age.")"; | |
echo $query; | |
mysqli_query($dbn,$query) or die(mysql_error($dbn)); | |
mysqli_close($dbn); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment