Skip to content

Instantly share code, notes, and snippets.

@mebrett
Created September 19, 2012 01:49
Show Gist options
  • Save mebrett/3747155 to your computer and use it in GitHub Desktop.
Save mebrett/3747155 to your computer and use it in GitHub Desktop.
Form to insert new person data into the database maury1
<?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