0

I try to do an insert into my database using a form but it fails.
My field type is longtext, because I want to add an iframe link. Can someone help me?

Here is my source code :

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

$connect = new PDO('mysql:host=localhost;dbname=horseblog;charset=utf8', 'root', '');
$res = $connect->exec('INSERT INTO musique SET lien="'.$_POST['lien'].'"');
header("location:mainPage.php");
}

My form :

<form class="form-inline" method="post"  action ="ajoutMusic.php">
    <div class="form-group">
        <label for="exampleInputName2">LIEN :</label>
        <input type ="text" class="form-control" name="lien" style="margin-left: 5%;" /><br/><br/>

        <span style="width: 200px"></span>
    </div>
    <input  class="btn btn-warning"style="margin-left: 3%; "type="submit" name="valider" value="ajouter"><br/><br/>
</form>
Blaatpraat
  • 2,829
  • 11
  • 23
djodev
  • 13
  • 4
  • 9
  • Can you post the error message? Or say whay does not work exactly? – Blaatpraat Jun 10 '15 at 10:01
  • 1
    See also [When to use single quotes, double quotes, and backticks?](http://stackoverflow.com/q/11321491), and then use `→prepare()` and `→execute([…])` with placeholders instead. – mario Jun 10 '15 at 10:04
  • 1
    If people would look up in the documentation I would be _soooo happy_. One does not simply merge an INSERT statement with an UPDATE statement. – Jonast92 Jun 10 '15 at 10:16
  • it works when i do that directly in the phpmyadmin and when i do that with a simple text like 'test of insertion' but when i want to insert : that doesnt work – djodev Jun 10 '15 at 10:23

0 Answers0