Skip to content

Instantly share code, notes, and snippets.

@andrescifuentesr
Last active August 29, 2015 14:01
Show Gist options
  • Save andrescifuentesr/93c65026a315fffa3c6e to your computer and use it in GitHub Desktop.
Save andrescifuentesr/93c65026a315fffa3c6e to your computer and use it in GitHub Desktop.
Insert Basic PHP
<?php
// Connexion BDD
mysql_connect('localhost', 'hostname', 'password'); //
mysql_select_db('mybdd');
mysql_query("SET NAMES 'utf8'");
// on start la session
session_start();
ini_set('session.gc_maxlifetime', 2592000); // durée de la session => 30 jours (2592000 secondes)
//----------------------------------------------
// On enregistre les modifications
//----------------------------------------------
if ( !empty($_POST) ) {
$_POST = array_map(mysql_real_escape_string, $_POST);
extract($_POST,EXTR_OVERWRITE);
{
$sql="INSERT INTO `my_table`
(nom, email)
VALUES
('$nom', '$email')";
//message de confirmation
if (mysql_query($sql) or die(mysql_error())) {
$message_registration = "Merci ;)";
};
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment