Jump to content


Photo

how to post, with user name


  • Please log in to reply
1 reply to this topic

#1 pakzz

pakzz
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 27 April 2006 - 02:16 PM

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

<?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'; ?>



#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 27 April 2006 - 03:48 PM

Pardon?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users