gegevens in databse doen met INSERT

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Louis Deconinck

Louis Deconinck

14/06/2015 11:21:57
Quote Anchor link
Dit is mijn code, maar waneer ik op verzenden druk, krijg ik niets ... hoe kan ik dit oplossen?

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
35
36
37
38
39
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);

if (isset($_POST['submit'])) {

$link=mysqli_connect("*","*","*","*");

$ilayout = mysqli_real_escape_string($link, $_POST['inputlayout']);
$iimg = mysqli_real_escape_string($link, $_POST['inputimg']);
$ivideo = mysqli_real_escape_string($link, $_POST['inputvideo']);
 
// attempt insert query execution
$sql = "INSERT INTO bases (layout, img, video, votes) VALUES ('$ilayout', '$iimg', '$ivideo', 0)";


if(mysqli_query($link, $sql)){
    echo "Base for layout $ilayout was added to the database";
}
else{
    echo "ERROR: Could not execute $sql. " . mysqli_error($link);
}

}

?>

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<center>
<form name="add" method="post" action="" >
<input type="text" name="inputlayout" placeholder="Layout"><br/>
<input type="text" name="inputimg" placeholder="Image location"><br/>
<input type="text" name="inputvideo" placeholder="Unique youtube code"><br/>
<input type="submit">
</form>
</center>
</body>
</html>
 
PHP hulp

PHP hulp

19/04/2024 02:49:03
 
- Ariën  -
Beheerder

- Ariën -

14/06/2015 11:33:39
Quote Anchor link
Je submit heeft geen name.

Een betere controle is:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
<?php
if($_SERVER['REQUEST_METHOD']=="POST") {
    // het forumulier is verstuurd via POST
} else {
    // Het formulier is NIET verstuurd via POST. Toon hier bijvoorbeeld het formulier!
}
?>
 
Louis Deconinck

Louis Deconinck

14/06/2015 11:46:40
Quote Anchor link
heel erg bedankt, dat werkte idd :)
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.