Created
September 19, 2012 01:49
-
-
Save mebrett/3747155 to your computer and use it in GitHub Desktop.
Form to insert new person data into the database maury1
This file contains hidden or 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 | |
//connect to database | |
$con = mysql_connect('localhost', 'root', 'root'); | |
//check connection | |
if (!$con) { | |
die('Could not connect');} | |
/*else{echo 'Success';}*/ | |
mysql_select_db('maury1'); | |
//store values | |
$nameF=mysql_real_escape_string($_POST['firstname']); | |
$nameM=mysql_real_escape_string($_POST['midname']); | |
$nameL=mysql_real_escape_string($_POST['lastname']); | |
$new_name = "INSERT INTO person (pers_no, name_first, name_mid, name_last) VALUES ('NULL', '".$nameF."', '".$nameM."', '".$nameL."')"; | |
mysql_query($new_name) or die('Error '. mysql_error()); | |
echo "Success: $nameF $nameL added with unique id"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment