mirror of
https://github.com/BreizhHardware/PHP.git
synced 2026-01-18 16:27:32 +01:00
TP 8
This commit is contained in:
5
.idea/.gitignore
generated
vendored
Normal file
5
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
12
.idea/PHP.iml
generated
Normal file
12
.idea/PHP.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
7
.idea/discord.xml
generated
Normal file
7
.idea/discord.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/PHP.iml" filepath="$PROJECT_DIR$/.idea/PHP.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -35,22 +35,153 @@
|
||||
?>
|
||||
<hr>
|
||||
<h2>Exercice 2</h2>
|
||||
<form action="TP5-PHP-Marquet.php" method="post">
|
||||
<form action="TP5-PHP-Marquet.php" method="get">
|
||||
<label for="Nom">Nom : </label>
|
||||
<input type="text" name="Nom" id="Nom">
|
||||
<label for="Prenom">Prénom : </label>
|
||||
<input type="text" name="Prenom" id="Prenom">
|
||||
<label for="Niveau">Niveau : </label>
|
||||
<input type="radio" name="Débutant" id="Débutant">
|
||||
<input type="radio" name="Avancé" id="Avancé">
|
||||
<input type="button" value="Envoyer">
|
||||
<label for="Niveau">Débutant</label>
|
||||
<input type="radio" name="Niveau" id="Niveau" value="Débutant">
|
||||
<label for="Niveau">Intermédiaire</label>
|
||||
<input type="radio" name="Niveau" id="Niveau" value="Intermédiaire">
|
||||
<input type="submit" value="Effacer">
|
||||
<input type="submit" value="Envoyer">
|
||||
</form>
|
||||
<?php
|
||||
if(isset($_POST['Nom']) && isset($_POST['Prenom']) && isset($_POST['Niveau'])){
|
||||
$nom = $_POST['Nom'];
|
||||
$prenom = $_POST['Prenom'];
|
||||
$niveau = $_POST['Niveau'];
|
||||
echo "Nom : " . $nom . "<br>Prénom : " . $prenom . "<br>Niveau : " . $niveau;
|
||||
//Le bouton Effacer vide le formulaire
|
||||
if(isset($_GET['Nom']) && isset($_GET['Prenom']) && isset($_GET['Niveau'])){
|
||||
/*
|
||||
$nom = $_GET['Nom'];
|
||||
$prenom = $_GET['Prenom'];
|
||||
$niveau = $_GET['Niveau'];
|
||||
echo "Bonjour " . $prenom . " " . $nom . ". Vous avez un niveau " . $niveau;
|
||||
*/
|
||||
echo "Bonjour " . $_GET['Prenom'] . " " . $_GET['Nom'] . ". Vous avez un niveau " . $_GET['Niveau'];
|
||||
}
|
||||
?>
|
||||
<hr>
|
||||
<h2>Exercice 3</h2>
|
||||
<form action="TP5-PHP-Marquet.php" method="get">
|
||||
<label for="Nom">Nom : </label>
|
||||
<input type="text" name="Nom" id="Nom">
|
||||
<label for="Prenom">Prénom : </label>
|
||||
<input type="text" name="Prenom" id="Prenom">
|
||||
<label for="Age">Age : </label>
|
||||
<input type="text" name="Age" id="Age">
|
||||
<br>
|
||||
<label for="Langue">Langue pratiquées (choisir 2 au minimum) : </label>
|
||||
<br>
|
||||
<select name="Langue[]" id="Langue" multiple>
|
||||
<option value="Français">Français</option>
|
||||
<option value="Anglais">Anglais</option>
|
||||
<option value="Espagnol">Espagnol</option>
|
||||
<option value="Allemand">Allemand</option>
|
||||
<option value="Italien">Italien</option>
|
||||
</select>
|
||||
<br>
|
||||
<label for="Competance">Compétences informatiques (choisir minimum 2) : </label>
|
||||
<br>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="HTML">
|
||||
<label for="Competance">HTML</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="CSS">
|
||||
<label for="Competance">CSS</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="PHP">
|
||||
<label for="Competance">PHP</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="SQL">
|
||||
<label for="Competance">SQL</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="C">
|
||||
<label for="Competance">C</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="C++">
|
||||
<label for="Competance">C++</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="JS">
|
||||
<label for="Competance">JS</label>
|
||||
<input type="checkbox" name="Competance[]" id="Competance" value="Python">
|
||||
<label for="Competance">Python</label>
|
||||
<br>
|
||||
<input type="submit" value="Effacer">
|
||||
<input type="submit" value="Envoyer">
|
||||
</form>
|
||||
<?php
|
||||
if(isset($_GET['Nom']) && isset($_GET['Prenom']) && isset($_GET['Age']) && isset($_GET['Langue']) && isset($_GET['Competance'])){
|
||||
echo "Bonjour " . $_GET['Prenom'] . " " . $_GET['Nom'] . ". Vous avez " . $_GET['Age'] . " ans. Vous parlez ";
|
||||
foreach($_GET['Langue'] as $langue){
|
||||
echo $langue . " ";
|
||||
}
|
||||
echo ". Vous avez des compétences en ";
|
||||
foreach($_GET['Competance'] as $competance){
|
||||
echo $competance . " ";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<hr>
|
||||
<h2>Exercice 4</h2>
|
||||
<form action="TP5-PHP-Marquet.php" method="post">
|
||||
<label for="NB1">Nombre 1 : </label>
|
||||
<input type="number" name="NB1" id="NB1">
|
||||
<br>
|
||||
<label for="NB2">Nombre 2 : </label>
|
||||
<input type="number" name="NB2" id="NB2">
|
||||
<br>
|
||||
<label for="Resultat">Résultat : </label>
|
||||
<input type="number" name="Resultat" id="Resultat" disabled>
|
||||
<br>
|
||||
<label for="Operation">Opération : </label>
|
||||
<input type="submit" name="Operation" id="Operation" value="Addition">
|
||||
<input type="submit" name="Operation" id="Operation" value="Soustraction">
|
||||
<input type="submit" name="Operation" id="Operation" value="Multiplication">
|
||||
<input type="submit" name="Operation" id="Operation" value="Division">
|
||||
</form>
|
||||
<?php
|
||||
if(isset($_POST['NB1']) && isset($_POST['NB2']) && isset($_POST['Operation'])){
|
||||
$nb1 = $_POST['NB1'];
|
||||
$nb2 = $_POST['NB2'];
|
||||
$operation = $_POST['Operation'];
|
||||
switch($operation){
|
||||
case "Addition":
|
||||
$resultat = $nb1 + $nb2;
|
||||
break;
|
||||
case "Soustraction":
|
||||
$resultat = $nb1 - $nb2;
|
||||
break;
|
||||
case "Multiplication":
|
||||
$resultat = $nb1 * $nb2;
|
||||
break;
|
||||
case "Division":
|
||||
$resultat = $nb1 / $nb2;
|
||||
break;
|
||||
}
|
||||
echo "<script>document.getElementById('Resultat').value = " . $resultat . "</script>";
|
||||
}
|
||||
?>
|
||||
<hr>
|
||||
<h2>Exercice 5</h2>
|
||||
<form action="TP5-PHP-Marquet.php" method="post">
|
||||
<label for="File1">Fichier 1 : </label>
|
||||
<input type="file" name="File1" id="File1">
|
||||
<br>
|
||||
<label for="File2">Fichier 2 : </label>
|
||||
<input type="file" name="File2" id="File2">
|
||||
<br>
|
||||
<button type="submit" name="Envoyer" id="Envoyer">Envoyer</button>
|
||||
</form>
|
||||
<!-- Pour chaque fichier, affichez l'image ainsi que les informations associées dans un tableau-->
|
||||
<?php
|
||||
if(isset($_POST['Envoyer'])){
|
||||
$file1 = $_FILES['File1'];
|
||||
$file2 = $_FILES['File2'];
|
||||
echo "<table>";
|
||||
echo "<tr><th>Fichier 1</th><th>Fichier 2</th></tr>";
|
||||
echo "<tr><td><img src='" . $file1['tmp_name'] . "' alt='" . $file1['name'] . "'></td><td><img src='" . $file2['tmp_name'] . "' alt='" . $file2['name'] . "'></td></tr>";
|
||||
echo "<tr><td>Nom : " . $file1['name'] . "</td><td>Nom : " . $file2['name'] . "</td></tr>";
|
||||
echo "<tr><td>Type : " . $file1['type'] . "</td><td>Type : " . $file2['type'] . "</td></tr>";
|
||||
echo "<tr><td>Taille : " . $file1['size'] . "</td><td>Taille : " . $file2['size'] . "</td></tr>";
|
||||
echo "<tr><td>Chemin temporaire : " . $file1['tmp_name'] . "</td><td>Chemin temporaire : " . $file2['tmp_name'] . "</td></tr>";
|
||||
echo "<tr><td>Erreur : " . $file1['error'] . "</td><td>Erreur : " . $file2['error'] . "</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
?>
|
||||
<hr>
|
||||
<h2>Exercice </h2>
|
||||
|
||||
</html>
|
||||
0
TP8/PHP/TP8-PHP-Marquet.php
Normal file
0
TP8/PHP/TP8-PHP-Marquet.php
Normal file
44
TP8/SQL/citationsOLD.sql
Normal file
44
TP8/SQL/citationsOLD.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- Table auteur
|
||||
CREATE TABLE auteur (
|
||||
id INTEGER,
|
||||
nom VARCHAR(64) NOT NULL,
|
||||
prenom VARCHAR(64) NOT NULL,
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
INSERT INTO auteur (id, nom, prenom) VALUES
|
||||
(1, 'de Montesquieu', 'Charles'),
|
||||
(2, 'Hugo', 'Victor'),
|
||||
(3, 'Marx', 'Karl'),
|
||||
(4, 'Bernard', 'Tristan'),
|
||||
(5, 'de La Fontaine', 'Jean');
|
||||
-- Table siecle
|
||||
CREATE TABLE siecle (
|
||||
id INTEGER,
|
||||
numero INTEGER,
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
INSERT INTO siecle (id, numero) VALUES
|
||||
(2, 17),
|
||||
(3, 18),
|
||||
(4, 19),
|
||||
(5, 20);
|
||||
-- Table citation
|
||||
CREATE TABLE citation (
|
||||
id INTEGER,
|
||||
phrase VARCHAR(255) NOT NULL,
|
||||
auteurid INTEGER,
|
||||
siecleid INTEGER,
|
||||
PRIMARY KEY(id),
|
||||
FOREIGN KEY(auteurid) REFERENCES auteur(id),
|
||||
FOREIGN KEY(siecleid) REFERENCES siecle(id)
|
||||
);
|
||||
--
|
||||
INSERT INTO citation (id, phrase, auteurid, siecleid) VALUES
|
||||
(1, 'Ne sentirons-nous jamais que le ridicule des autres?', 1, 3),
|
||||
(2, 'L''animal a cet avantage sur l''homme qu''il ne peut être sot.', 2, 4),
|
||||
(3, 'L''homme est un loup pour l''homme ', 3, 4),
|
||||
(4, 'Les hommes sont toujours sincères. Ils changent de sincérité, voilà tout.', 4, 5),
|
||||
(5, 'L''histoire de l''humanité est l''histoire de la lutte des classes.', 3, 4),
|
||||
(6, 'Rien ne sert de courir, il faut partir à point ', 5, 2);
|
||||
|
||||
|
||||
31
TP8/SQL/data.sql
Normal file
31
TP8/SQL/data.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
DELETE FROM citation;
|
||||
DELETE FROM siecle;
|
||||
DELETE FROM auteur;
|
||||
|
||||
-- --- Populate auteur table ------------
|
||||
ALTER SEQUENCE auteur_id_seq RESTART;
|
||||
INSERT INTO auteur (nom, prenom) VALUES
|
||||
('de Montesquieu', 'Charles'),
|
||||
('Hugo', 'Victor'),
|
||||
('Marx', 'Karl'),
|
||||
('Bernard', 'Tristan'),
|
||||
('de La Fontaine', 'Jean');
|
||||
|
||||
-- --- Populate siecle table ------------
|
||||
ALTER SEQUENCE siecle_id_seq RESTART;
|
||||
INSERT INTO siecle (numero) VALUES
|
||||
(17),
|
||||
(18),
|
||||
(19),
|
||||
(20);
|
||||
|
||||
-- -- --- Populate citation table ------------
|
||||
ALTER SEQUENCE citation_id_seq RESTART;
|
||||
INSERT INTO citation (phrase, auteurid, siecleid) VALUES
|
||||
('Ne sentirons-nous jamais que le ridicule des autres?', 1, 2),
|
||||
('L''animal a cet avantage sur l''homme qu''il ne peut être sot.', 2, 3),
|
||||
('L''homme est un loup pour l''homme ', 3, 3),
|
||||
('Les hommes sont toujours sincères. Ils changent de sincérité, voilà tout.', 4, 4),
|
||||
('L''histoire de l''humanité est l''histoire de la lutte des classes.', 3, 3),
|
||||
('Rien ne sert de courir, il faut partir à point ', 5, 1);
|
||||
30
TP8/SQL/model.sql
Normal file
30
TP8/SQL/model.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
DROP TABLE IF EXISTS auteur CASCADE;
|
||||
DROP TABLE IF EXISTS siecle CASCADE;
|
||||
DROP TABLE IF EXISTS citation CASCADE;
|
||||
|
||||
-- Table auteur
|
||||
CREATE TABLE auteur (
|
||||
id SERIAL PRIMARY KEY,
|
||||
nom VARCHAR(64) NOT NULL,
|
||||
prenom VARCHAR(64) NOT NULL
|
||||
);
|
||||
|
||||
-- Table siecle
|
||||
CREATE TABLE siecle (
|
||||
id SERIAL PRIMARY KEY,
|
||||
numero INTEGER
|
||||
);
|
||||
|
||||
-- Table citation
|
||||
CREATE TABLE citation (
|
||||
id SERIAL PRIMARY KEY,
|
||||
phrase VARCHAR(255) NOT NULL,
|
||||
auteurid INTEGER,
|
||||
siecleid INTEGER,
|
||||
FOREIGN KEY(auteurid) REFERENCES auteur(id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY(siecleid) REFERENCES siecle(id)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
);
|
||||
--
|
||||
1
TP8/SQL/query.sql
Normal file
1
TP8/SQL/query.sql
Normal file
@@ -0,0 +1 @@
|
||||
select * from auteur WHERE id<3;
|
||||
Reference in New Issue
Block a user