message blog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • insane
    New Member
    • Feb 2008
    • 18

    message blog

    i am trying to make a message blog where i've made three database table, in one table i want insert the users ip address , current time of posting message ,header and referee..please help me ..how can i do all the things
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    Originally posted by insane
    i am trying to make a message blog where i've made three database table, in one table i want insert the users ip address , current time of posting message ,header and referee..please help me ..how can i do all the things
    Hi isane,

    Welcome to The Scripts.

    It sounds to me like you're pretty new to all this and so I'll give you a few pointers but normally the forum works best for those who have at least had a go at solving the problem themselves. In future I recommend you do this and post your question along with the relevant code.

    You can get the user IP address:
    [php]
    $lcUserIP = $REMOTE_ADDR;
    [/php]
    Current time is:
    [php]
    $lcCurrentDateT ime = mktime() ; // set as the local time - google this function for more info
    [/php]

    The other information seems like it will come from a form and so is possibly in the $_POST[] array and can be accessed using the name you gave the form elements.

    Have a read around this forum there are some great articles on getting information from forms and writing it to databases.

    If you get stuck with anything more specific post back here and I'll be happy to try to help.

    Cheers
    nathj

    Comment

    • insane
      New Member
      • Feb 2008
      • 18

      #3
      hi,
      Thanks for ur code and its right that im a new commer in this area.please keep me in ur touch.by giving suggestion .



      Originally posted by nathj
      Hi isane,

      Welcome to The Scripts.

      It sounds to me like you're pretty new to all this and so I'll give you a few pointers but normally the forum works best for those who have at least had a go at solving the problem themselves. In future I recommend you do this and post your question along with the relevant code.

      You can get the user IP address:
      [php]
      $lcUserIP = $REMOTE_ADDR;
      [/php]
      Current time is:
      [php]
      $lcCurrentDateT ime = mktime() ; // set as the local time - google this function for more info
      [/php]

      The other information seems like it will come from a form and so is possibly in the $_POST[] array and can be accessed using the name you gave the form elements.

      Have a read around this forum there are some great articles on getting information from forms and writing it to databases.

      If you get stuck with anything more specific post back here and I'll be happy to try to help.

      Cheers
      nathj

      Comment

      • nathj
        Recognized Expert Contributor
        • May 2007
        • 937

        #4
        Originally posted by insane
        hi,
        Thanks for ur code and its right that im a new commer in this area.please keep me in ur touch.by giving suggestion .
        What code have you got so far? Have you tried the things I suggested?

        Feel free to post back any time with specific questions and code snippets - I'll try to answer as best I can.

        Cheers
        nathj

        Comment

        • insane
          New Member
          • Feb 2008
          • 18

          #5
          hi,
          i've tried to do according to ur suggestion...
          here i've attached my code for the blog..this for form and on this page

          <script>

          function check(){

          if(document.for m2.name_poster. value==""){
          alert("Please Enter your Name!");
          return false;
          }

          if(document.for m2.contact_no.v alue==""){
          alert("Please Enter your Contact No!");
          return false;
          }
          if(document.for m2.email.value= =""){
          alert("Please Enter Email Address!");
          return false;
          }
          if(document.for m2.details.valu e==""){
          alert("Please Enter your Opinion!");
          return false;
          }


          return true;
          }

          function go_there()
          {
          window.location ="show.php";
          }
          </script>

          <head>
          <link rel="stylesheet " type="text/css" href="life.css" >
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <style type="text/css">
          <!--#Layer1 {
          position:absolu te;
          width:200px;
          height:115px;
          z-index:1;
          top: 164px;
          left: 286px;
          }
          #Layer2 {
          position:absolu te;
          width:500px;
          height:64px;
          z-index:2;
          left: 237px;
          top: 51px;
          background-color: #99CCFF;
          overflow: hidden;
          visibility: visible;
          }

          -->
          </style>
          </head>
          <body>

          <div id="Layer1" align="center">
          <form action="insert. php" method="post" name="form2" onSubmit="retur n check()" enctype="multip art/form-data">
          <div align="left" id="form" style="backgrou nd-color:#CCFFFF">

          <div class="legend">
          <p class="legend"> Personal Information</p>
          <fieldset id="personal">

          <em><label><b>N ame:</b></label>
          </em>
          <input type="text" name="name_post er" size="30">
          <br>
          <em><label><b>C ontact No:</b></label></em>
          <input type="text" name="contact_n o" size="30" ><br />
          <em><label><b>E mail:</b></label>
          </em>
          <input type="text" name="email" size="30"><br />
          <p class="legend1" >Message Details</p>
          <textarea name="details" rows="4" cols="40">Pleas e share any comments you have here</textarea>
          </fieldset>
          </div>
          <div id="buttons" align="center">
          <p id="buttons"><i nput name="submit" type="submit" value="Submit Message" />
          </p>
          </div>
          </div>
          </form>
          </div>
          <div id="Layer2">
          <?php
          include("dbconn ect.php");
          $sql="SELECT *
          FROM `blog_topic`
          ORDER BY `blog_topic`.`t _id` DESC
          limit 1";
          $result=mysql_q uery($sql)
          or
          die(mysql_error );
          echo '<table width="500" height="70" border="1">';
          while($row=mysq l_fetch_array($ result))
          {
          echo '<tr>';

          echo '<td> <font:Verdana ; widht:5px>';
          echo $row['topic'];
          echo '</font></td>';
          echo '</tr>';
          }

          ?>
          </table>
          </div>

          </body>


          this is another....
          <?php
          if(array_key_ex ists('submit',$ _POST))
          {
          include("dbconn ect.php");

          $lcUserIP = $REMOTE_ADDR;
          $lcCurrentDateT ime = mktime() ;
          $query="insert into post_details(na me_poster,conta ct_no,email,ip) values('$_POST[name_poster]','$_POST[contact_no]','$_POST[email]','$lcUserIP')" ;
          mysql_query($qu ery)
          or
          die(mysql_error ());
          $query="insert into message_blog(de tails,date_post ,contact_no)val ues('$_POST[details]','$lcCurrentDa teTime','$_POST[contact_no]')";
          $result=mysql_q uery($query)
          or
          die(mysql_error ());
          if(result){
          header('Locatio n:show.php');
          exit;
          }
          }
          ?>
          this for admin topic
          <?php
          if(array_key_ex ists('submit',$ _POST)){
          include("dbconn ect.php");
          $query="insert into blog_topic(topi c)value('$_POST[topic]')";
          $result=mysql_q uery($query)
          or
          die (mysql_error()) ;
          if($result){
          header('Locatio n:form2.php');
          exit;
          }
          }

          and admin form is..

          <head>
          <link rel="stylesheet " type="text/css" href="topic.css ">

          <style type="text/css">
          <!--
          #Layer2 {
          position:absolu te;
          width:200px;
          height:115px;
          z-index:1;
          left: 304px;
          top: 140px;
          }
          -->
          </style>
          </head>

          <body>
          <div id="Layer2">
          <form action="topic.p hp" method="post" name="admin">
          <div align="center" id="form">
          <p class="legend"> Message Topic</p>
          <fieldset id="topic">
          <textarea name="topic" rows="4" cols="40" style="backgrou nd:#999933"></textarea>
          </fieldset>
          </div>
          <div id="buttons" align="center">
          <p id="buttons">
          <input name="submit" type="submit" value="Submit Message"/>
          </p>
          </div>
          </form>
          </div>
          </body>

          another is to show..

          <?php
          include("dbconn ect.php");
          ?>
          <style type="text/css">
          <!--
          #Layer1 {
          position:absolu te;
          width:399px;
          height:115px;
          z-index:1;
          left: 336px;
          top: 227px;
          }
          #Layer2 {
          position:absolu te;
          width:581px;
          height:83px;
          z-index:2;
          left: 228px;
          top: 108px;
          }
          #Layer3 {
          position:absolu te;
          width:200px;
          height:115px;
          z-index:3;
          left: 420px;
          top: 404px;
          }
          -->
          </style>

          <p><h2><center> Message Blog </center></h2></p>
          <div id="Layer1">
          <?php
          $sql="SELECT * FROM `message_blog` ORDER BY `message_blog`. `b_id` DESC limit 5";
          $result=mysql_q uery($sql)
          or
          die(mysql_error ());

          while($row=mysq l_fetch_array($ result))
          {


          echo $row['details'];
          echo "<br>";
          echo "<br>";
          }
          ?>
          </div>

          <div id="Layer2">
          <?php

          $result=mysql_q uery("SELECT *
          FROM `blog_topic`
          ORDER BY `blog_topic`.`t _id` DESC limit 1 ")
          or
          die(mysql_error );
          echo '<table width="500" height="70" border="1">';
          while($row=mysq l_fetch_array($ result))
          {
          echo '<tr>';
          echo '<td>';
          echo $row['topic'];
          echo '</td>';
          echo '</tr>';
          }

          ?>
          </table>
          </div>

          <div id="Layer3">
          <?php
          echo "<a href=details.ph p> see details of message</a>";
          ?>
          </div>


          and the details is here...

          <style type="text/css">
          <!--
          #Layer1 {
          position:absolu te;
          width:533px;
          height:142px;
          z-index:1;
          left: 189px;
          top: 73px;
          }
          -->
          </style>
          <div id="Layer1">
          <?php
          include("dbconn ect.php");
          $query="select p.name_poster,p .email,p.contac t_no,m.date_pos t, m.details
          from post_details p, message_blog m where p.contact_no=m. contact_no ";

          $result=mysql_q uery($query)
          or
          die(mysql_error );
          echo '<table width="200" border="1">';
          while($row=mysq l_fetch_assoc($ result))
          {
          echo '<tr>';
          echo '<th scope="col">Pos ted by</th>';
          echo '<th scope="col">Ema il</th>';
          echo '<th scope="col">Con tact No</th>';
          echo ' <th scope="col">Pos ted time</th>';
          echo '<th scope="col">Det ailsS</th>';
          echo '</tr>';
          echo '<tr>';
          echo '<td>';
          echo $row['name_poster'];
          echo "&nbsp; </td>";
          echo "<td>";
          echo $row['email'];
          echo "&nbsp;</td>";
          echo "<td>";
          echo $row['contact_no'];
          echo "&nbsp;</td>";
          echo "<td>";
          echo $row['date_post'];
          echo "&nbsp;</td>";
          echo "<td>";
          echo $row['details'];
          echo "</td>";
          echo "</tr>";
          echo "<br>";
          }
          ?>
          </table>
          </div>
          note: i want to do a blog manager where the admin pannel will fix the topic and the users will write their comments according the topic. u know! and here a authentication process will be how can i do all things simply..and i also want to show the php output with html and css....please help me...

          INSANE

          Comment

          • insane
            New Member
            • Feb 2008
            • 18

            #6
            hi,
            i've tried to do according to ur suggestion...
            here i've attached my code for the blog..this for form and on this page

            <script>

            function check(){

            if(document.for m2.name_poster. value==""){
            alert("Please Enter your Name!");
            return false;
            }

            if(document.for m2.contact_no.v alue==""){
            alert("Please Enter your Contact No!");
            return false;
            }
            if(document.for m2.email.value= =""){
            alert("Please Enter Email Address!");
            return false;
            }
            if(document.for m2.details.valu e==""){
            alert("Please Enter your Opinion!");
            return false;
            }


            return true;
            }

            function go_there()
            {
            window.location ="show.php";
            }
            </script>

            <head>
            <link rel="stylesheet " type="text/css" href="life.css" >
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <style type="text/css">
            <!--#Layer1 {
            position:absolu te;
            width:200px;
            height:115px;
            z-index:1;
            top: 164px;
            left: 286px;
            }
            #Layer2 {
            position:absolu te;
            width:500px;
            height:64px;
            z-index:2;
            left: 237px;
            top: 51px;
            background-color: #99CCFF;
            overflow: hidden;
            visibility: visible;
            }

            -->
            </style>
            </head>
            <body>

            <div id="Layer1" align="center">
            <form action="insert. php" method="post" name="form2" onSubmit="retur n check()" enctype="multip art/form-data">
            <div align="left" id="form" style="backgrou nd-color:#CCFFFF">

            <div class="legend">
            <p class="legend"> Personal Information</p>
            <fieldset id="personal">

            <em><label><b>N ame:</b></label>
            </em>
            <input type="text" name="name_post er" size="30">
            <br>
            <em><label><b>C ontact No:</b></label></em>
            <input type="text" name="contact_n o" size="30" ><br />
            <em><label><b>E mail:</b></label>
            </em>
            <input type="text" name="email" size="30"><br />
            <p class="legend1" >Message Details</p>
            <textarea name="details" rows="4" cols="40">Pleas e share any comments you have here</textarea>
            </fieldset>
            </div>
            <div id="buttons" align="center">
            <p id="buttons"><i nput name="submit" type="submit" value="Submit Message" />
            </p>
            </div>
            </div>
            </form>
            </div>
            <div id="Layer2">
            <?php
            include("dbconn ect.php");
            $sql="SELECT *
            FROM `blog_topic`
            ORDER BY `blog_topic`.`t _id` DESC
            limit 1";
            $result=mysql_q uery($sql)
            or
            die(mysql_error );
            echo '<table width="500" height="70" border="1">';
            while($row=mysq l_fetch_array($ result))
            {
            echo '<tr>';

            echo '<td> <font:Verdana ; widht:5px>';
            echo $row['topic'];
            echo '</font></td>';
            echo '</tr>';
            }

            ?>
            </table>
            </div>

            </body>


            this is another....
            <?php
            if(array_key_ex ists('submit',$ _POST))
            {
            include("dbconn ect.php");

            $lcUserIP = $REMOTE_ADDR;
            $lcCurrentDateT ime = mktime() ;
            $query="insert into post_details(na me_poster,conta ct_no,email,ip) values('$_POST[name_poster]','$_POST[contact_no]','$_POST[email]','$lcUserIP')" ;
            mysql_query($qu ery)
            or
            die(mysql_error ());
            $query="insert into message_blog(de tails,date_post ,contact_no)val ues('$_POST[details]','$lcCurrentDa teTime','$_POST[contact_no]')";
            $result=mysql_q uery($query)
            or
            die(mysql_error ());
            if(result){
            header('Locatio n:show.php');
            exit;
            }
            }
            ?>
            this for admin topic
            <?php
            if(array_key_ex ists('submit',$ _POST)){
            include("dbconn ect.php");
            $query="insert into blog_topic(topi c)value('$_POST[topic]')";
            $result=mysql_q uery($query)
            or
            die (mysql_error()) ;
            if($result){
            header('Locatio n:form2.php');
            exit;
            }
            }

            and admin form is..

            <head>
            <link rel="stylesheet " type="text/css" href="topic.css ">

            <style type="text/css">
            <!--
            #Layer2 {
            position:absolu te;
            width:200px;
            height:115px;
            z-index:1;
            left: 304px;
            top: 140px;
            }
            -->
            </style>
            </head>

            <body>
            <div id="Layer2">
            <form action="topic.p hp" method="post" name="admin">
            <div align="center" id="form">
            <p class="legend"> Message Topic</p>
            <fieldset id="topic">
            <textarea name="topic" rows="4" cols="40" style="backgrou nd:#999933"></textarea>
            </fieldset>
            </div>
            <div id="buttons" align="center">
            <p id="buttons">
            <input name="submit" type="submit" value="Submit Message"/>
            </p>
            </div>
            </form>
            </div>
            </body>

            another is to show..

            <?php
            include("dbconn ect.php");
            ?>
            <style type="text/css">
            <!--
            #Layer1 {
            position:absolu te;
            width:399px;
            height:115px;
            z-index:1;
            left: 336px;
            top: 227px;
            }
            #Layer2 {
            position:absolu te;
            width:581px;
            height:83px;
            z-index:2;
            left: 228px;
            top: 108px;
            }
            #Layer3 {
            position:absolu te;
            width:200px;
            height:115px;
            z-index:3;
            left: 420px;
            top: 404px;
            }
            -->
            </style>

            <p><h2><center> Message Blog </center></h2></p>
            <div id="Layer1">
            <?php
            $sql="SELECT * FROM `message_blog` ORDER BY `message_blog`. `b_id` DESC limit 5";
            $result=mysql_q uery($sql)
            or
            die(mysql_error ());

            while($row=mysq l_fetch_array($ result))
            {


            echo $row['details'];
            echo "<br>";
            echo "<br>";
            }
            ?>
            </div>

            <div id="Layer2">
            <?php

            $result=mysql_q uery("SELECT *
            FROM `blog_topic`
            ORDER BY `blog_topic`.`t _id` DESC limit 1 ")
            or
            die(mysql_error );
            echo '<table width="500" height="70" border="1">';
            while($row=mysq l_fetch_array($ result))
            {
            echo '<tr>';
            echo '<td>';
            echo $row['topic'];
            echo '</td>';
            echo '</tr>';
            }

            ?>
            </table>
            </div>

            <div id="Layer3">
            <?php
            echo "<a href=details.ph p> see details of message</a>";
            ?>
            </div>


            and the details is here...

            <style type="text/css">
            <!--
            #Layer1 {
            position:absolu te;
            width:533px;
            height:142px;
            z-index:1;
            left: 189px;
            top: 73px;
            }
            -->
            </style>
            <div id="Layer1">
            <?php
            include("dbconn ect.php");
            $query="select p.name_poster,p .email,p.contac t_no,m.date_pos t, m.details
            from post_details p, message_blog m where p.contact_no=m. contact_no ";

            $result=mysql_q uery($query)
            or
            die(mysql_error );
            echo '<table width="200" border="1">';
            while($row=mysq l_fetch_assoc($ result))
            {
            echo '<tr>';
            echo '<th scope="col">Pos ted by</th>';
            echo '<th scope="col">Ema il</th>';
            echo '<th scope="col">Con tact No</th>';
            echo ' <th scope="col">Pos ted time</th>';
            echo '<th scope="col">Det ailsS</th>';
            echo '</tr>';
            echo '<tr>';
            echo '<td>';
            echo $row['name_poster'];
            echo "&nbsp; </td>";
            echo "<td>";
            echo $row['email'];
            echo "&nbsp;</td>";
            echo "<td>";
            echo $row['contact_no'];
            echo "&nbsp;</td>";
            echo "<td>";
            echo $row['date_post'];
            echo "&nbsp;</td>";
            echo "<td>";
            echo $row['details'];
            echo "</td>";
            echo "</tr>";
            echo "<br>";
            }
            ?>
            </table>
            </div>
            note: i want to do a blog manager where the admin pannel will fix the topic and the users will write their comments according the topic. u know! and here a authentication process will be how can i do all things simply..and i also want to show the php output with html and css....please help me...

            INSANE

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              USE CODE TAGS!

              No one will read that.

              Comment

              • nathj
                Recognized Expert Contributor
                • May 2007
                • 937

                #8
                Originally posted by markusn00b
                USE CODE TAGS!

                No one will read that.
                that's why I've not replied again, that and I'm not sure where the problem is - what is it that you are stuggling with?

                Be more specific rather than postinga ll of your code.

                cheers
                nathj

                PS People here are really friendly and are happy to help but give us a fighting chance - we have jobs of our own - I know I do.

                Comment

                • insane
                  New Member
                  • Feb 2008
                  • 18

                  #9
                  sorry to disturb u guys..

                  Comment

                  • nathj
                    Recognized Expert Contributor
                    • May 2007
                    • 937

                    #10
                    Originally posted by insane
                    sorry to disturb u guys..
                    It's not a disruption if you have a specific questions. I can see you've put a lot of work into your project and I am happy to help. I just need to know what the exact question is.

                    Cheers
                    nathj

                    Comment

                    • insane
                      New Member
                      • Feb 2008
                      • 18

                      #11
                      sorry to disturb u guys..and next time if i post i will use code tags

                      Comment

                      • insane
                        New Member
                        • Feb 2008
                        • 18

                        #12
                        hi..
                        here im new so plz dont take it otherwise!!!
                        so far i know u will show me the way...
                        thanks
                        insane
                        Last edited by insane; Feb 5 '08, 04:14 PM. Reason: ITS foolish

                        Comment

                        • insane
                          New Member
                          • Feb 2008
                          • 18

                          #13
                          sorry to disturb u guys..and next time if i post i will use code tags

                          myproblem is here:where i want to show it decendind order and with in limit,i also want to shoe the ip address from wher it is post and want to get the output within HTML AND CSS
                          [CODE]
                          [PHP]$query="select p.name_poster,p .email,p.contac t_no,m.date_pos t, m.details[/PHP]
                          [CODE]

                          MY insert code is here
                          [[PHP]if(array_key_ex ists('submit',$ _POST))[/PHP] [PHP]$lcUserIP = $REMOTE_ADDR;[/PHP] [PHP]$lcCurrentDateT ime = mktime() ;[/PHP] [PHP]$query="insert into post_details(na me_poster,conta ct_no,email,ip) values('$_POST[name_poster]','$_POST[contact_no]','$_POST[email]','$lcUserIP')" ;[/PHP]
                          Again sorry.....INSAN E

                          Comment

                          • nathj
                            Recognized Expert Contributor
                            • May 2007
                            • 937

                            #14
                            Hi insane,

                            it looks like you are making good progress with your roject. When I first started trying to do things like this I read an article here on TheScripts:

                            Data Abstraction Layer

                            This showed me how to get data from a database and display it on my site. Als as it is a PHP class it means that the code is only in one place and can be used in many places without bloating the final pages.

                            Have read over this, the basic premise is to get the results of your query into an associative array and then loop through the array using foreach() echoing out the details you want in the format you want.

                            I thought it best to point you in the direction of this articel as we learn best when we do something and also it's a bit daft to simply copy it from one place to another.

                            Cheers
                            nathj

                            Comment

                            • insane
                              New Member
                              • Feb 2008
                              • 18

                              #15
                              hi,
                              thanks.its fine thing for me to do my job..but i want to get my output in desending order and want limit it.but my nestd loop which retrieving data from two table.plz help me....

                              [PHP]$query="select p.name_poster,p .email,p.contac t_no,m.date_pos t, m.details from post_details p, message_blog m where p.contact_no=m. contact_no ";
                              [/PHP]
                              and in bangladesh where current time is GMT+6 hrs
                              how can i do it plz

                              Comment

                              Working...