Jump to content

how tocreate a forum that repost to database -


lordbux

Recommended Posts

hi friends

i am a newbie to php and need a bit of help to create a small forum

that can report and derive data from a mysql database

==============================

 

i need 2 text boxes

TEXTBOX1= Roll Number

TEXTBOX2= Name 

 

and 2 buttons

BUTTON1= Add

BUTTON2= Show

================================

When  BUTTON1 is clicked, the  values in TEXTBOX1 & TEXTBOX2 Should be submitted to a table (any name) in database.

When  BUTTON2 is clicked after providing a value in TEXTBOX2 - TEXTBOX1 should show a NAME from the database where Roll=TEXTBOX2 from the

database.

 

here is the database details

=================

dbname= tonks

usrname= root

password= behind

Host= localhost

------------------------------------

 

plas give an example code that can do this

thanks in advance :)  :)  :)

Basic example of a user post:

<?php
session_start();
if(isset($_POST['msg'])){
     $msg = mysql_real_escape_string(htmlentities($_POST['msg']));
     $user_id = $_SESSION['user'];
     $thread_id = mysql_real_escape_string($_GET['id']);
     $results = mysql_query("INSERT INTO posts (thread_id, message, user_id) VALUES ('$thread_id', '$msg', '$user_id')");
     echo 'Your message was posted successfully';
}
?>

 

Basic example of showing the thread:

<?php
$thread = mysql_real_escape_string($_GET['id']);
$results = mysql_query("SELECT pos.message, us.username FROM posts pos INNER JOIN users us ON pos.user_id=us.id WHERE pos.thread_id=$thread") or die();
while($values = mysql_fetch_array($results)){
     echo 'Username: ' . $values['username'] . '<br />';
     echo 'Message: ' . $values['message'] . '<br /><br />';
}
?>

 

That's the basic idea of what you're in.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.