Jump to content

how to post, with user name


pakzz

Recommended Posts

Hei, how can i save username in my database?? whn you people log in i use SESSION to safe userid, but it don't take with user id in database, plzz help

[code]
<?php
session_start();

if($_SESSION['autentisert'] == false) {
  header('Location: logg_inn.php'); // Videresend til logg inn skjemaet
}

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

$_SESSION['userid'];

$tittel = htmlentities($_POST['tittel']);
$innlegg = htmlentities($_POST['innlegg']);

if(!empty($tittel) and !empty($innlegg)){

// Conntecting database
include '../sql/config.php';

// Henter tittel og innlegg, og samtidig Unngår SQL-injection
$tittel = mysql_escape_string(trim($_POST['tittel']));
$innlegg = mysql_escape_string($_POST['innlegg']);


  $sql = "INSERT INTO blogg(tittel, innlegg, time)VALUES('".$tittel."', '".$innlegg."', now())";
  mysql_query($sql) or die("some wrong: ".mysql_error());

  mysql_close();
  
  header('Location: ../index.php');
}

    else {
  echo "<p><font color=\"red\">Fyll it all</font></p>";
   }
  

}
}
?>

<?php include 'include/topptekst.php'; ?>
<?php include 'templates/innlegg.tpl'; ?>
<?php include 'include/bunntekst.php'; ?>
[/code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.