Plateformes BDD

Revision 1

Avec APTANA, écrie le code HTML.
Sauvegarder le fichier comme : index.php


Code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
 
<title>Revisiontitle>
 

<link href="" rel="stylesheet">
 

<script src="">script>
 
<style>
body {
margin: 0px;
background: #F5F5F5;
font-family: Helvetica, sans-serif;
color: #484848;
font-size: small;
}
 
input, select {
padding: 5px 4px;
color: #585858;
margin-bottom: 3px;
border: 1px solid #C0C0C0;
border-radius: 4px;
background: #FAFAFA;
padding-right: 25px;
box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset;
/*box-shadow: 1px 1px 1px #084B8A;*/
}
 
input:focus, select:focus {
background: #ffffff;
box-shadow: 0 0 5px #136296;
border-color: #136296;
}
 
.login {
margin: auto;
margin-top: 100px;
width: 800px;
border: 1px solid #136296;
border-radius: 4px;
background: #ffffff;
padding: 10px;
box-shadow: 0 0 5px #136296;
}
 
/*http://cssgradientbutton.com/#*/
 
.button_green {
cursor: pointer;
border: 1px solid #8bcf54;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
font-size: 12px;
font-family: arial, helvetica, sans-serif;
padding: 10px 10px 10px 10px;
text-decoration: none;
display: inline-block;
text-shadow: -1px -1px 0 rgba(0,0,0,0.3);
font-weight: bold;
color: #FFFFFF;
background-color: #a9db80;
background-image: -webkit-gradient(linear, left top, left bottom, from(#a9db80), to(#96c56f));
background-image: -webkit-linear-gradient(top, #a9db80, #96c56f);
background-image: -moz-linear-gradient(top, #a9db80, #96c56f);
background-image: -ms-linear-gradient(top, #a9db80, #96c56f);
background-image: -o-linear-gradient(top, #a9db80, #96c56f);
background-image: linear-gradient(to bottom, #a9db80, #96c56f);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#a9db80, endColorstr=#96c56f);
}
 
.button_green:hover {
 
border: 1px solid #74bf36;
background-color: #8ed058;
background-image: -webkit-gradient(linear, left top, left bottom, from(#8ed058), to(#7bb64b));
background-image: -webkit-linear-gradient(top, #8ed058, #7bb64b);
background-image: -moz-linear-gradient(top, #8ed058, #7bb64b);
background-image: -ms-linear-gradient(top, #8ed058, #7bb64b);
background-image: -o-linear-gradient(top, #8ed058, #7bb64b);
background-image: linear-gradient(to bottom, #8ed058, #7bb64b);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#8ed058, endColorstr=#7bb64b);
}
 
style>
 
head>
 
<body>
<div class='login'>
<form action='resultat.php' method='post'>
<table border='0px' style='width:100%'>
<tr>
<td colspan="2"><h3>Loginh3>td>
tr>
<tr>
<td> Name td>
<td>
<input type='text' name='contact_name'>
td>
tr>
<tr>
<td> Telephone td>
<td>
<input type='text' name='contact_telephone'>
td>
tr>
<tr>
<td> e-mail td>
<td>
<input type='email' name='contact_email'>
td>
tr>
<tr>
<td>td>
<td>
<input class="button_green" type='submit' value='Send'>
td>
tr>
 
table>
div>
<br />
<br />
form>
body>
 
html>

Sauvegarder le fichier comme : resultat.php
Code

<?php
$username = "root";
$password=""; //PUT HERE THE LOCAL HOST PASSWORD
 
if ($mysqli = new PDO('mysql:host=localhost;dbname=revision', $username, $password))
{}else{echo "bad news";}
 
$mysqli-> exec("set names utf8");
?>


foreach
( $_POST as $key => $value) {

$$key= $value;
 
}
 
$sql_insert=$mysqli->prepare("INSERT INTO revision.contact
(contact_name, contact_telephone, contact_email)
VALUES (?, ?, ?)");
 
$sql_insert->execute(array($contact_name, $contact_telephone, $contact_email));
 
?>

Créer une nouvelle base de données avec le nom revision, et executer le script "CREATE TABLE";
Code

CREATE TABLE `contact` (
`contact_id` int(11) NOT NULL AUTO_INCREMENT,
`contact_name` varchar(30) DEFAULT NULL,
`contact_telephone` varchar(20) DEFAULT NULL,
`contact_email` varchar(50) DEFAULT NULL,
PRIMARY KEY (`contact_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;