PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    Simple CMS

    Share
    avatar
    s.w.vanderlaan

    Number of posts : 19
    Age : 38
    Localisation : The Netherlands
    Registration date : 2009-03-22

    Simple CMS

    Post  s.w.vanderlaan on Fri Apr 10, 2009 5:39 am

    Hi,

    So I wanted to add a little CMS to the site and posted about it already, but it turned it this is a more suitable place for this subject on this forum. So here goes again.

    In principle I got a solution. But there's still one little issue, maybe someone could help me out? This is what I do, e.g., for index.php:

    1. index.php shows a link to editindex.php if the user is an admin
    2. editindex.php has a textarea including HTMLarea 3 (really nice bar with text options)
    3. editindex.php is a form and links to updateindex.php.

    This all works very well. Accept for one thing: the update doesn't take place correclty, there's no error, but the text you write in the textarea gets lost and the database gets filled with... nothing!

    Here's the code of the updateindex.php file:

    Code:

    <?php
    include("_includes/session.php");
    session_start();
        $sql = "UPDATE content SET text='$text' WHERE con_id='1' AND fk_con_group_id='1' ";
           $res = mysql_query($sql);
       header("Location: index.php"); exit;
    ?>

    Do you know what is going wrong?

    And an additional question: should I perhaps make a function in process.php? As this update-process is going to be used for many other pages. How would I go about that? Are there any other things in the other login-script-pages that I should change (form.php, session.php)?

    Thank you!

    Regards,

    Sander
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Simple CMS

    Post  Linchpin311 on Fri Apr 10, 2009 8:30 pm

    well unless you are using another session for your script, i dont think you need to put session_start(); in the code. that should have already been taken care of in session.php.

    i think you problem has to do with the $text variable. assuming that $text is the value from editindex.php i dont see how your updateindex.php script can know what this is. how are you sending $text from one page to the other?

    what might also help you is try commenting out $res = mysql_query($sql); and under that put echo $sql;. that should put the sql right on the screen (while not processing your query) so you can see what its trying to do. my hunch is that you'll see something like SET text = ''.

    on a side note, im not all that familar with HTMLarea but i looked into it a little bit. it looks pretty cool! i dont know how it works on the back end but do you like it? are you finding uses for it in your projects?


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    s.w.vanderlaan

    Number of posts : 19
    Age : 38
    Localisation : The Netherlands
    Registration date : 2009-03-22

    Re: Simple CMS

    Post  s.w.vanderlaan on Sat Apr 11, 2009 7:09 am

    Hi,

    Thanks for the quick reply. I will try it all out.

    HTMLarea can be found here: http://www.dynarch.com/projects/htmlarea/.

    But apparently it's no longer maintained, I got way back when it was 2003 or something.

    Anyway, there is an open source descendant (Xinha), which can be found here: http://xinha.webfactional.com/.

    I do really like these HTMLarea things. It's one of those tools/objects/codes/whatever everyone always wants. There should be a worldwide general deposit for things like this.

    Will get back on the other subject.

    Sander
    avatar
    s.w.vanderlaan

    Number of posts : 19
    Age : 38
    Localisation : The Netherlands
    Registration date : 2009-03-22

    Re: Simple CMS

    Post  s.w.vanderlaan on Sat Apr 11, 2009 8:02 am

    Hey Linchpin,

    Tried to change it. But I can't make it to work.

    I include what I wanted to do:

    In the editindex.php page:
    Code:
    <form name="updateindex" method="POST" action="updateindex.php">
      <?
    $res=mysql_query("SELECT content FROM content WHERE con_id='1'");
    $num=mysql_num_rows($res);
    for($i=0; $i<$num; $i++){
      $a=mysql_fetch_row($res); ?>
        <table width="95%" border="0" cellpadding="5" cellspacing="5">
          <tr>
            <td><script type="text/javascript" defer="1">
    var config = new HTMLArea.Config();
    config.toolbar = [
          [ "fontname", "space",
            "fontsize", "space",
            "bold", "italic", "underline", "strikethrough", "separator",
            "subscript", "superscript", "separator",
            "copy", "cut", "paste", "space", "undo", "redo" ],

          [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
            "lefttoright", "righttoleft", "separator",
            "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
            "forecolor", "hilitecolor", "separator",
            "inserthorizontalrule", "createlink", "inserttable", "htmlmode", "separator",
            "showhelp", "about" ]

    ];
    HTMLArea.replace('content', config);
    </script><b>Content</b><br />
    <textarea name="content" id="content" type="text" class="textfield" style="width:100%" cols="50" rows="25"><?php
      echo "".$a[0]."";
    }?>
          </textarea>
          </td>
          </tr>
        </table>
        <p>
       <input type="reset" name="Submit" value="Reset all">
        <input type="submit" id="Submit" name="Submit" value="Update" />
        </p>
      </form>

    Than updateindex.php:

    Code:
    <?php
    include("_includes/session.php");
        $sql = "UPDATE content SET content = '$content' WHERE con_id = '1";
           $res = mysql_query($sql);
       header("Location: index.php"); exit;
    ?>

    Now, I thought if I would set the name of the textarea as "content" the updateindex.php should "know" what I mean with "content"... I must be missing a point here. Do you know perhaps?

    But I was thinking to make it a function in process.php. Just like editing an account. Isn't that much better? Since I want more pages with the possibility to edit the content. Otherwise I'll end up with a lot of the same kind of update-pages...
    How would I go about that?

    Thank you again!

    Regards,

    Sander

    Sponsored content

    Re: Simple CMS

    Post  Sponsored content


      Current date/time is Sun Oct 22, 2017 4:53 pm