-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
35 lines (31 loc) · 938 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
if(isset($_POST['inserer'])){
$host="localhost";
$data_name="music";
$username="root";
$pass='';
$con = new mysqli($host,$username,$pass,$data_name);
$rslt = mysqli_query($con,"insert into test values(null,'".addslashes($_POST['nom'])."','".addslashes($_POST['prenom'])."');");
if(mysqli_affected_rows($con)==1){
header("Location: test.php?inserted=true");
exit();
}
header("Location: test.php?inserted=fasle");
exit();
}
?>
<form method="POST" action="test.php">
<?php
if(isset($_GET['inserted'])){
if($_GET['inserted']=='true'){
echo 'bien inserer<br>';
}else{
//hadi f au cas ou kan mochkil f base donne 3ad ghadi iban
echo "Error : n'est pas inserer<br>";
}
}
?><br>
<input type="text" name="nom" required="" placeholder="your First name"><br><br>
<input type="text" name="prenom" required="" placeholder="your last name"><br><br>
<input type="submit" name="inserer">
</form>