-1

I'm trying to make a site were the user can enter his profile, but i can't connect to my db.

<?php
if(isset( $_POST['send'] ) ) 
{
    $bnavn = $_POST['brugernavn'];
    $fnavn = $_POST['fornavn'];
    $enavn = $_POST['efternavn'];
    $email = $_POST['email'];
    $kode = $_POST['adgangskode'];
    $sql = "INSERT INTO brugere (brugernavn, fornavn, efternav, email, adgangskode, medlemsiden) VALUES('$bnavn', '$fnavn', '$enavn', '$email', '$kode', NOW() )";
    $dbforbindelse->query( $sql );
    header( 'Location: index.php' );
}
?>
xlecoustillier
  • 16,183
  • 14
  • 60
  • 85
  • 3
    Either you didn't write your connection code or you didn't include your connection code file here in your php code. – Alive to die - Anant Mar 25 '15 at 08:27
  • http://stackoverflow.com/questions/409351/post-vs-serverrequest-method-post?rq=1 http://stackoverflow.com/a/60496/3455727 Some handy links which has nothing to do with your question –  Mar 25 '15 at 08:34

1 Answers1

0

Create a php file 'dbconf.php' with following codes

enter 
<?
   php
  $conn = mysql_connect("localhost","database_user","user_pass");
  $db = mysql_select_db("database_name");
?>

Replace database_user with your database username , user_pass with your database user password and database_name with the name of your database.
Now in above codes
`

Include 'dbconf.php'

Hope it will work

Shubh
  • 1
  • 3