Jump to content

ShoeLace1291

Members
  • Posts

    401
  • Joined

  • Last visited

Posts posted by ShoeLace1291

  1. I am having a problem with my css coding that I can't figure out.  In the attachment, the news section is below the left navigation menu when the news should be directly to the right of the navigation menu.  How do I get it so the news will be in the correct position?

     

    This is my HTML code:

    <HTML>
    <HEAD>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <TITLE>Storm Creations.net</TITLE>
    <LINK rel=stylesheet href='storm.css'>
    </HEAD>
    <BODY>
    
    
    <script type="text/javascript">
    
    /***********************************************
    * AnyLink Vertical Menu- © Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    //Contents for menu 1
    var menu1=new Array()
    menu1[0]='<a href="services.php?act=hosting">HOSTING</a>'
    menu1[1]='<a href="services.php?act=template">TEMPLATE DESIGN</a>'
    menu1[2]='<a href="services.php?act=coding">CUSTOM CODING</a>'
    
    
    
    //Contents for menu 2, and so on
    var menu2=new Array()
    menu2[0]='<a href="downloads.php?cat=resources">RESOURCES</a>'
    menu2[1]='<a href="downloads.php?cat=phpscripts">PHP SCRIPTS</a>'
    menu2[2]='<a href="downloads.php?cat=templates">FREE TEMPLATES</a>'
    
    //Contents for menu 2, and so on
    var menu3=new Array()
    menu3[0]='<a href="tutorials.php?program=photoshop">ADOBE PHOTOSHOP</a>'
    menu3[1]='<a href="tutorials.php?program=gimp">THE GIMP</a>'
    menu3[2]='<a href="tutorials.php?program=php">PHP PROGRAMMING</a>'
    menu3[3]='<a href="tutorials.php?program=html">HTML LAYOUTS</a>'
    menu3[4]='<a href="tutorials.php?program=css">STYLE SHEETS</a>'
    
    
    var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
    var horizontaloffset=2 //horizontal offset of menu from default location. (0-5 is a good value)
    
    /////No further editting needed
    
    var ie4=document.all
    var ns6=document.getElementById&&!document.all
    
    if (ie4||ns6)
    document.write('<div id="dropmenudiv" style="visibility:hidden;width: 160px" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
    
    function getposOffset(what, offsettype){
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }
    
    
    function showhide(obj, e, visible, hidden, menuwidth){
    if (ie4||ns6)
    dropmenuobj.style.left=dropmenuobj.style.top=-500
    dropmenuobj.widthobj=dropmenuobj.style
    dropmenuobj.widthobj.width=menuwidth
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
    obj.visibility=visible
    else if (e.type=="click")
    obj.visibility=hidden
    }
    
    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge"){
    var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
    edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth
    }
    else{
    var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
    var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
    edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
    if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
    edgeoffset=dropmenuobj.y
    }
    }
    return edgeoffset
    }
    
    function populatemenu(what){
    if (ie4||ns6)
    dropmenuobj.innerHTML=what.join("")
    }
    
    
    function dropdownmenu(obj, e, menucontents, menuwidth){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    clearhidemenu()
    dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
    populatemenu(menucontents)
    
    if (ie4||ns6){
    showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
    dropmenuobj.x=getposOffset(obj, "left")
    dropmenuobj.y=getposOffset(obj, "top")
    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
    }
    
    return clickreturnvalue()
    }
    
    function clickreturnvalue(){
    if (ie4||ns6) return false
    else return true
    }
    
    function contains_ns6(a, b) {
    while (b.parentNode)
    if ((b = b.parentNode) == a)
    return true;
    return false;
    }
    
    function dynamichide(e){
    if (ie4&&!dropmenuobj.contains(e.toElement))
    delayhidemenu()
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
    delayhidemenu()
    }
    
    function hidemenu(e){
    if (typeof dropmenuobj!="undefined"){
    if (ie4||ns6)
    dropmenuobj.style.visibility="hidden"
    }
    }
    
    function delayhidemenu(){
    if (ie4||ns6)
    delayhide=setTimeout("hidemenu()",disappeardelay)
    }
    
    function clearhidemenu(){
    if (typeof delayhide!="undefined")
    clearTimeout(delayhide)
    }
    
    </script>
       <div class='wrapper'>
         <div id='banner'><img src='images/banner.gif' width='100%'></div>
         <div align='center' id='toplinks'>
    
                  <ul align='center' class='midbar'>
                  <li><a href='index.php'>home</a></li>
                  <li><a href='support.php'>support</a></li>
    
                  <li><a href='staff.php'>staff</a></li>
                  <li><a href='forums/index.php' target='new'>forum</a></li></ul></div>
         <div id='middle'><div id='menu'>
    
                  <ul class='mainnav'>
                  <li><img src='images/navigation.gif'></li>
                  <li><a href='index.php'>Index</a></li>
                  <li><a href='forums/index.php' target='new'>Forum</a></li>
                  <li><a href='support.php'>Support</a></li>
                  <li><a href='staff.php'>Staff</a></li>
                  <li><a href='services.php'>Services</a></li>
    
                  <li><a href='downloads.php'>Downloads</a></li>
                  <li><a href='tutorials.php'>Tutorials</a></li>
                  <li><a href='irc.php'>IRC Chat</a></li>
                  <li style='border-bottom: 1px solid #396339;'><a href='affiliates.php'>Affiliates</a></li>
                  </ul>
        <div class='content'><p align='center'>Site News</p><br><b>Welcome to Storm Creations!</b><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh commodo consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh commodo consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh commodo consequat.<br><br><b>Another Article</b><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh commodo consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh commodo consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh commodo consequat.<br><hr width='50%'></hr></div>
    
        </div></div>
    </BODY>
    </HTML>
    

     

    This is my CSS sheet:

    body { background-image: url(images/background.gif);
           background-attachment: fixed;
           font-size: 10px;
           color: #FFFFFF;
           font-family: verdana;
           margin-top: 0px;
           margin-bottom: 0px;
           margin-left: 50px;
           margin-right: 50px;
           background: #6a946a url(images/background.gif) repeat-y 50% 0;
    }
    
    a:link, a:hover, a:visited, a:active { color: #FFFFFF; }
    
    .wrapper { background-color: #FFFFFF;
               margin-top: 0px;
               margin-bottom: 0px;
               color: #000000;
    }
    
    .navtable { background-color: #396339;
    }
    
    .linkrow { background-color: #6a946a;
               text-align: right;
               padding: 3px;
               color: #FFFFFF;
               font-family: verdana;
               font-size: 10px;
               margin-bottom: 0px;
               border-bottom: 1px solid #396339;
               border-right: 1px solid #396339;
    }
    
    .linkrowhover { background-color: #396339;
               text-align: right;
               padding: 3px;
               color: #FFFFFF;
               font-family: verdana;
               font-size: 10px;
    }
    
    .linkrow a:link, .linkrow a:hover, .linkrow a:visited, .linkrow a:active { color: #FFFFFF; }
    
    midbar { /* background-image: url(images/midbar.gif);
              #FFFFFF;
              padding: 5px;
              text-align: center; 
              vertical-align: middle;
              font-family: verdana;
              font-size: 10px; */
    } 
    .midbar a:link, .midbar a:hover, .midbar a:visited, .midbar a:active { color: #FFFFFF;   }
    
    .menublank { background-color: #6a946a;
                 margin-bottom: 0px; }
    
    .membersarea { background-color: #6a946a;
                   color: #e4e4e4; 
                   font-size: 10px;
                   font-verdana;
                   padding: 5px;
                   border: 1px solid #396339;
                   text-align: left;
    }
    
    .navtop { background-color: #396339;
              text-align: center;
              padding: 3px;
              font-size: 10px;
              font-family: verdana;
              color: #FFFFFF;
    }
    
    .navtop a { color: #FFFFFF; }
    
    
    #dropmenudiv{
    position:absolute;
    background-color: #6a946a;
    border:1px solid black;
    border-bottom-width: 0;
    font:normal 10px Verdana;
    z-index: 100;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=80);
    -moz-opacity: 0.8;
    }
    
    #dropmenudiv a{
    width: 100%;
    display: block;
    text-indent: 3px;
    border-bottom: 1px solid black;
    padding: 1px 0;
    text-decoration: none;
    font-weight: bold;
    }
    
    #dropmenudiv a:hover{ /*hover background color*/
    background-color: #396339;
    
    }
    
    #toplinks { background-image: url(images/midbar.gif);
                font-size: 10px;
                color: #FFFFFF;
                font-family: verdana;
                padding: 5px;
                
          
    }
    
    #toplinks ul{
    /*margin: 0;
    padding: 4px;
    margin-bottom: 1em;*/
    float: center;
    width: 100%;
    border: 0px;
    background-color: transparent;
    }
    
    
    
    #toplinks ul li{
    display: inline;
    }
    
    #toplinks ul li a{
    float: center;
    color: #FFFFFF;
    padding: 6px;
    padding-top: 0px;
    padding-bottom: 0px;
    text-decoration: none;
    background: transparent url(images/vertical.gif) center right no-repeat;
    }
    
    #toplinks ul li a:visited{
    color: #FFFFFF;
    }
    
    #toplinks ul li a:hover{
    color: #FFFFFF;
    background-color: transparent;
    }
    
    
    #banner { float: center;
              background-color: transparent;
              width: 100%;
              height: 120px;
              margin: 0px;
    }
    
    #mainnav { float: center;
               width: 155px;
    }
    
    ul.mainnav{
    
    list-style:none; /* this line will remove any kind of bullet from the menu */
    
    width: 155px; /* sets the menu width */
    
    margin:0;
    
    padding:0;
    border: 1px solid #396339;
    
    }
    
    
    
    #menu a
    
    {
    
    display: block; /* this is a very important property here and it controls the way the menu elements are displayed - like block-level elements */
    
    padding: 5px 3px 5px 10px; /* sets the padding properties */
    
    font-weight:bold; /* sets the font weight */
    
    background-color: #6a946a; /* sets the color of the background */
    
    border-top: 1px solid #396339; /* this code sets the line between the menu items */
    
    }
    
    
    
    #menu a:link
    
    {
    
    color: #efefef; /* sets the font color */
    
    text-decoration: none;
    
    }
    
    
    
    #menu a:visited
    
    {
    
    color: #396339;
    
    text-decoration: none;
    
    }
    
    
    
    #menu a:hover
    
    {
    
    background:#6a946a url(images/bullet.gif) no-repeat left center; /* when the cursor is over, in the left side of the menu item background it will be display the arrow.gif picture */
    
    text-indent:15px; /* this line of code move the text 15 px to the right */
    
    }
    
    
    
    #menu a:active
    
    {
    
    color: #396339;
    
    text-decoration: none;
    
    } 
    
    #menu li { background-color: #6a946a;
               text-align: right;
    }
    
    #content {
                float: right;
                wrapping: 0px;
                width: 50%;
    }
    
    #middle { float: center;
    }

     

    Thanks in advance for any help.

     

     

    [attachment deleted by admin]

  2. Ok, I tried the tutorial from this site, but now the sql records are not showing up.  The links are showing up fine, but it doesn't display the sql records.  This is my code:

    <?php
    $action = $_GET["action"];
    
    $m_time = explode(" ",microtime()); 
    $m_time = $m_time[0] + $m_time[1]; 
    $starttime = $m_time;
    
    ob_start();
    require_once('config.php');
    
    session_start(); // Use session variable on this page. This function must put on the
    include('constants.php'); 
    
    if(!session_is_registered("username")){
    
          $user = "Guest";
    
      }
    
    if(session_is_registered("username")){
    
         $user = $_SESSION['username'];
    
        }
    
    include('templates/default/header_body.tpl');
    
    $fid = $_GET["id"];
    
    $getfname = mysql_query("SELECT * FROM vbb_forums WHERE fid = $fid");
    
    while($f=mysql_fetch_array($getfname))
    
    {
    
      $fname=$f["fname"];
    
    }
    
    
    echo "<div><p align='left'><a href='index.php'>Index</a> -> <a href='viewforum.php?id=$fid'>$fname</a><br><br><a href='addthread.php?fid=$fid'>Create Thread</a></p></div>";
    
    if(!isset($_GET['page'])){
        $page = 1;
    } else {
        $page = $_GET['page'];
    }
    
    // Define the number of results per page
    $max_results = 15;
    
    // Figure out the limit for the query based
    // on the current page number.
    $from = (($page * $max_results) - $max_results); 
    
    // Perform MySQL query on only the current page number's results
    
    $sql = mysql_query("SELECT * FROM vbb_threads LIMIT $from, $max_results WHERE fid = $fid");
    
        echo "<table align='center' cellspacing='1' cellpadding='1' border='0' width='75%'>
        <tr>
           <td align='left' width='100%' colspan='5'></td>
       </tr><tr>
           <td colspan='5' height='25' class='header'>$fname</td>
       </tr><tr>
           <td width='10%' class='title_threads'> </td>
           <td width='35%' class='title_threads''>Subject/Creator</td>
           <td width='10%' class='title_threads''>Views</td>
           <td width='10%' class='title_threads''>Replies</td>
           <td width='35%' class='title_threads''>Last Post</td>
        </tr><tr>";
    
    //Are there any threads in this forum?
    $getthreads = "SELECT * FROM vbb_threads WHERE fid = $fid";
    $threads_result = mysql_query($getthreads);
    $num_threads = mysql_num_rows($threads_result);
    
    //If no, display a message.
    if($num_threads < 1)
    
    {
    
        echo "<td colspan='5' class='forumrow'>There are currently no threads in this forum.</td>";
    
    } 
    
    
    
    while($t=mysql_fetch_array($sql)){
        // Build your formatted results here.
       
       
    
          $tcreator=$t["tcreator"];
          $tsubject=$t["tsubject"];
          $tid=$t["tid"];
          $tviews=$t["tviews"];
          $tlastpost_auth=$t["tlastpost_auth"];
          $tlastpost_datetime=$t["tlastpost_datetime"];
    
         $get_replies = "SELECT * FROM vbb_replies where tid = $tid";
         $replies_result = mysql_query($get_replies);
         $replies = mysql_num_rows($replies_result);
    
         include('templates/default/threadlist_body.tpl');
    
        }
    
      
    
    
       echo "</table>";
    
    
    // Figure out the total number of results in DB:
    $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM vbb_threads"),0);
    
    // Figure out the total number of pages. Always round up using ceil()
    $total_pages = ceil($total_results / $max_results);
    
    // Build Page Number Hyperlinks
    echo "<center><b>Page:</b>";
    
    // Build Previous Link
    if($page > 1){
        $prev = ($page - 1);
        echo "<a href=\"".$_SERVER['PHP_SELF']."?id=$fid&page=$prev\"><<Previous</a> ";
    }
    
    for($i = 1; $i <= $total_pages; $i++){
        if(($page) == $i){
            echo "$i ";
            } else {
                echo "<a href=\"".$_SERVER['PHP_SELF']."?id=$fid&page=$i\">$i</a> ";
        }
    }
    
    // Build Next Link
    if($page < $total_pages){
        $next = ($page + 1);
        echo "<a href=\"".$_SERVER['PHP_SELF']."?id=$fid&page=$next\">Next>></a>";
    }
    echo "</center>";
    
    
      include('templates/default/footer_body.tpl');
    
    ?>

  3. I am having problems with my pagination code.  The limit is 15 and there are 16 threads in the selected forum but it's not showing a link to the next page and it's displaying all 16 threads.  This is my code:

    <?php
    $action = $_GET["action"];
    
    $m_time = explode(" ",microtime()); 
    $m_time = $m_time[0] + $m_time[1]; 
    $starttime = $m_time;
    
    ob_start();
    require_once('config.php');
    
    session_start(); // Use session variable on this page. This function must put on the
    include('constants.php'); 
    
    if(!session_is_registered("username")){
    
          $user = "Guest";
    
      }
    
    if(session_is_registered("username")){
    
         $user = $_SESSION['username'];
    
        }
    
    include('templates/default/header_body.tpl');
    
    $fid = $_GET["id"];
    
    $getfname = mysql_query("SELECT * FROM vbb_forums WHERE fid = $fid");
    
    while($f=mysql_fetch_array($getfname))
    
    {
    
      $fname=$f["fname"];
    
    }
    
    
    echo "<div><p align='left'><a href='index.php'>Index</a> -> <a href='viewforum.php?id=$fid'>$fname</a><br><br><a href='addthread.php?fid=$fid'>Create Thread</a></p></div>";
    
    //Start pagination
    $q = mysql_query("SELECT * FROM `vbb_threads` WHERE fid = $fid ORDER BY tid DESC LIMIT 15");
      if(!$q) die(mysql_error());  
    $total_items = mysql_num_rows($q);
    
    
      $limit = 15; 
    
       if((!$limit)  || (is_numeric($limit) == false) || ($limit < 10) || ($limit > 50)) {
         
        } 
    
       if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) {
          $page = 1; //default
        } 
    
        $total_pages = ceil($total_items / $limit);
        $set_limit = $page * $limit - ($limit);
    
        $prev_page = $page - 1;
    
        if($prev_page >= 1) { 
           echo("<b><</b> <a href='viewforum.php?id=$fid&page=$prev_page><b><--</b></a>"); 
    } 
    
      for($a = 1; $a <= $total_pages; $a++)
      {
       if($a == $page) {
          echo("<b> $a</b> | "); //no link
     } else {
      echo("  <a href=viewforum.php?id=$fid&page=$a> $a </a> | ");
         } 
    } 
    
      $next_page = $page + 1;
    
      if($next_page <= $total_pages) {
       echo("<a href='viewforum.php?id=$fid&page=$next_page'><b>--></b></a> > >"); 
    } 
    //End Pagination
    
    echo "<table align='center' cellspacing='1' cellpadding='1' border='0' width='75%'>
        <tr>
           <td align='left' width='100%' colspan='5'></td>
       </tr><tr>
           <td colspan='5' height='25' class='header'>$fname</td>
       </tr><tr>
           <td width='10%' class='title_threads'> </td>
           <td width='35%' class='title_threads''>Subject/Creator</td>
           <td width='10%' class='title_threads''>Views</td>
           <td width='10%' class='title_threads''>Replies</td>
           <td width='35%' class='title_threads''>Last Post</td>
        </tr><tr>";
    
    //Are there any categories in this program?
    $get_threads = "SELECT * FROM vbb_threads where fid = $fid";
    $threads_result = mysql_query($get_threads);
    $num_threads = mysql_num_rows($threads_result);
    
    if($num_threads < 1)
    
    {
    
        echo "<td colspan='5' class='forumrow'>There are currently no threads in this forum.</td>";
    
    }
       
       while($t=mysql_fetch_array($q))
    
       {
    
          $tcreator=$t["tcreator"];
          $tsubject=$t["tsubject"];
          $tid=$t["tid"];
          $tviews=$t["tviews"];
          $tlastpost_auth=$t["tlastpost_auth"];
          $tlastpost_datetime=$t["tlastpost_datetime"];
    
         $get_replies = "SELECT * FROM vbb_replies where tid = $tid";
         $replies_result = mysql_query($get_replies);
         $replies = mysql_num_rows($replies_result);
    
         include('templates/default/threadlist_body.tpl');
    
        }
    
       echo "</table>";
    
      include('templates/default/footer_body.tpl');
    
    ?>

  4.  if(!session_is_registered("username")){
    
          $user = "Guest";
    
      }
    
    if(session_is_registered("username")){
    
         $user = $_SESSION['username'];
    
                $uidquery = mysql_query("SELECT * FROM vbb_members WHERE username='".$_SESSION['username']."'");
    
            $get=mysql_fetch_array($uidquery);
    
                     $uid=$get["uid"];
    
    
        }

  5. Erg, I got that cookie script from a tutorial.  The login form is displayed at the top of my page if the user is logged out and the username is displayed if they are logged in.  This file is what controls that action:

     

    header_body.tpl

    <div id="wrapper">
    
    <div id="header" width='100%'>
    <div id="logo">
    
    	<span class="name"><?php echo "$site_name"; ?></span><br />
    	<span class="slogan"><?php echo "$description"; ?></span>
    </div>
    <div id="login">
    <?php
    
    if($user == "Guest"){
    
    ?>
      <form id="form1" method="post" action="login.php">
        <label>
        <input name="username" type="text" class="text" value="username" onfocus="if(this.value==this.defaultValue) this.value='';" />
        </label>
    
            <label>
            <input name="password" type="password" class="text" value="password" onfocus="if(this.value==this.defaultValue) this.value='';" />
                    <input type='hidden' name='last_login' value='<?php echo "$date at $time"; ?>'>
            <input name="submit" type="submit" class="submit" value="Login" />
            </label>
            
      </form><?php } if($user != "Guest"){ echo "Welcome back, $user!<br><a href='profile.php?action=edit&uid=$uid'>Edit Profile</a> | <a href='messages.php?action=inbox'>Inbox</a> | <a href='index.php?action=calendar'>Events Calendar</a>"; } if($perm == 1){ echo "<a href='admincp/index.php'>Admin Panel</a>"; } ?>
        </div>
      </div>
      
    
    <div id="userbar">
    <div id="userinfo">
      <ul>
        <li><a href="index.php">Forum Index</a></li>
    <li><a href="members.php?action=controls">User CP</a></li>
    <li><a href='members.php?action=list'>Members List</a></li>
    <li><?php if($user == "Guest"){ echo "<a href='login.php'>Login</a> <a href='register.php'>Register</a>"; } if($user != "Guest"){ echo "<a href='logout.php'>Logout</a>"; } ?></li>
      </ul>
    
      </div>
    <div id="search">
    <div id="form">
      <form id="form2" name="form2" method="post" action="index.php?action=search">
        <label>
        <input name="thread" type="text" value="Search and enter"><input type='submit' class='submit' name='go' value='Go'>
        </label>
        </form>
    </div>
    
      </div>
    </div>
    <?php
    if($user == 'Guest'){
    echo "<div class='error'>You are not logged in.  Please do so using the above form or by clicking <a href='login.php'>here</a>.</div>";
    }
    
    ?>

  6. Login.php

    <?php
    require_once('config.php');
    // Use session variable on this page. This function must put on the top of page.
    session_start();
    
    include('constants.php');
    
    $message="";
    //Login Section.
    $Login=$_POST['submit'];
    if($Login){ // If clicked on Login button.
    $username=$_POST['username'];
    $password=md5($_POST['password']); // Encrypt password with md5() function.
    $last_login = $_POST['last_login'];
    
    
    
    // Check matching of username and password.
    $result=mysql_query("select * from members where username='$username' and password='$password'");
    if(mysql_num_rows($result)!='0'){ // If match.
    session_register("username"); // Craete session username.
    mysql_query("UPDATE vbb_members SET logged_in=logged_in+1, last_login='$last_login' WHERE username='$username'");
    
    setcookie("$username","07470433",time()+60*60*24*7);
    
    header("Location:index.php"); 
    
    }else{ // If not match.
    $message="--- Incorrect Username or Password ---";
    }
    
    } // End Login authorize check.
    ?> 
    
    
    <? echo $message; ?> 
    <table>
    <tr><form action='login.php' method='POST'>
    <td>User : </td>
    <td><input name="username" type="text" id="username" /></td>
    </tr>
    <tr>
    <td>Password : </td>
    <td><input name="password" type="password" id="password" /></td>
    </tr>
    </table><input type='hidden' name='last_login' value='<?php echo "$date at $time"; ?>'>
    <input name="Login" type="submit" id="Login" value="Login" />
    </form>
    </body>
    </html>
    

     

    Logout.php

    <?php
    session_start();
    ob_start();
      session_destroy();
    require_once('config.php');
    mysql_query("UPDATE vbb_members SET logged_in=logged_in - 1 WHERE username='$username'");
      header("Location: index.php");
    ?>
    

  7. Ok, my registration/login script was working fine until I tested the registration and registered a new user.  Once I logged in with the new account, I logged out and then logged into the first account.  Everything was fine until I clicked on a link to a page that also uses the session.  The only problem is that for the username, it displays the username for the second account.  I thought the logout was successful because it no longer displayed the login form at the top of the page.  What do you guys think is causing the problem?

  8. How would I use a database to make a feature where a certain image is displayed if there have been new posts made since the user last visited that forum and a different image is displayed if there haven't been new posts made?

  9. I'm making a forum software and I was wondering what the best method to make the new posts forum marker feature was.  I just want to display an image next to the listed forum and if there haven't been any new posts since the user last visited the forum, it displays a certain image.  If there has been new posts made since the user last visited the forum, it displays a different image.  How would I use the database to do this?

  10. i got this image verification tutorial from tutorialized.com.  when i go to the form page, it doesn't load the image.  this is my form code:

    <?php
    session_start();
    ?>
    <HTML>
    <HEAD>
    <TITLE>Random image sample</TITLE>
    <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">
    </HEAD>
    <BODY>
    <?php
    $errors=0;
    if(isset($_POST['Submit']))
    {
    $number = $_POST['number'];
    if(md5($number) != $_SESSION['image_value'])
    echo '<h1>Validation string not valid! Please try again!</h1>';
    else
    {
    echo '<h1>Your string is valid!</h1>';
    //do what you want with the data
    }
    }
    ?>
    <form name="form1" method="post" action="random_sample.php">
    <table cellspacing="0" width="600" align="center">
    <tr><td valign="top" align="right">Comments</td>
    <td><input name="message" size=40 value="...your message here">
    </td></tr>
    <tr><td colspan=2 align="center">
    <font size="1" face="Geneva, Arial, Helvetica, sans-serif"><strong><font size="2">
    Please enter the string shown in the image in the form.<br> The possible characters are letters from A to Z in capitalized form and the numbers from 0 to 9.
    </font></td></tr>
    <tr><td align="center" colspan=2><input name="number" type="text" id=\"number\"></td></tr>
    <tr><td colspan=2 align="center"><img src="random_image_sample.php"></td></tr>
    <tr><td colspan=2 align="center"><input name="Submit" type="submit"
    value="Submit"></td></tr>
    </table>
    </form>
    </BODY>
    </HTML>

     

    This is my random image code:

    <?php
    //random_image_sample.php contents 
    
    //start a session 
    session_start();
    //this function is called recursivelly
      function random_string($len=5, $str='')
      {
    for($i=1; $i<=$len; $i++)
            {
            //generates a random number that will be the ASCII code of the character.
    //We only want numbers (ascii code from 48 to 57) and caps letters. 
     $ord=rand(48, 90);
     if((($ord >= 48) && ($ord <= 57)) || (($ord >= 65) && ($ord<= 90))) 
    $str.=chr($ord);
     //If the number is not good we generate another one
    else
    	$str.=random_string(1);	                                       
    }
    return $str;
    }
                                           
    //create the random string using the upper function 
    //(if you want more than 5 characters just modify the parameter)
    $rand_str=random_string(5);
                                        
    //We memorize the md5 sum of the string into a session variable
    $_SESSION['image_value'] = md5($rand_str);
                                  
    //Get each letter in one valiable, we will format all letters different
    $letter1=substr($rand_str,0,1);
    $letter2=substr($rand_str,1,1);
    $letter3=substr($rand_str,2,1);
    $letter4=substr($rand_str,3,1);
    $letter5=substr($rand_str,4,1);
                                           
    //Creates an image from a png file. If you want to use gif or jpg images, 
    //just use the coresponding functions: imagecreatefromjpeg and imagecreatefromgif.
    $image=imagecreatefrompng("images/noise.png");
                                           
    //Get a random angle for each letter to be rotated with.
    $angle1 = rand(-20, 20);
    $angle2 = rand(-20, 20);
    $angle3 = rand(-20, 20);
    $angle4 = rand(-20, 20);
    $angle5 = rand(-20, 20);
                                     
    //Get a random font. (In this examples, the fonts are located in "fonts" directory and named from 1.ttf to 10.ttf)
    $font1 = "fonts/".rand(1, 10).".ttf";
    $font2 = "fonts/".rand(1, 10).".ttf";
    $font3 = "fonts/".rand(1, 10).".ttf";
    $font4 = "fonts/".rand(1, 10).".ttf";
    $font5 = "fonts/".rand(1, 10).".ttf";
                                           
    //Define a table with colors (the values are the RGB components for each color).
    $colors[0]=array(122,229,112);
    $colors[1]=array(85,178,85);
    $colors[2]=array(226,108,97);
    $colors[3]=array(141,214,210);
    $colors[4]=array(214,141,205);
    $colors[5]=array(100,138,204);
                                           
    //Get a random color for each letter.
    $color1=rand(0, 5);
    $color2=rand(0, 5);
    $color3=rand(0, 5);
    $color4=rand(0, 5);
    $color5=rand(0, 5);
                                           
    //Allocate colors for letters.
    $textColor1 = imagecolorallocate ($image, $colors[$color1][0],$colors[$color1][1], $colors[$color1][2]);
    $textColor2 = imagecolorallocate ($image, $colors[$color2][0],$colors[$color2][1], $colors[$color2][2]);
    $textColor3 = imagecolorallocate ($image, $colors[$color3][0],$colors[$color3][1], $colors[$color3][2]);
    $textColor4 = imagecolorallocate ($image, $colors[$color4][0],$colors[$color4][1], $colors[$color4][2]);
    $textColor4 = imagecolorallocate ($image, $colors[$color5][0],$colors[$color5][1], $colors[$color5][2]);
    
    Write text to the image using TrueType fonts.
    $size = 12;
    imagettftext($image, $size, $angle1, 10, $size+15, $textColor1, $font1, $letter1);
    imagettftext($image, $size, $angle2, 35, $size+15, $textColor2, $font2, $letter2);
    imagettftext($image, $size, $angle3, 60, $size+15, $textColor3, $font3, $letter3);
    imagettftext($image, $size, $angle4, 85, $size+15, $textColor4, $font4, $letter4);
    imagettftext($image, $size, $angle5, 110, $size+15, $textColor5, $font5, $letter5);
    
    header('Content-type: image/jpeg');
    Output image to browser
    imagejpeg($image);
    Destroys the image
    imagedestroy($image);  
    
    ?>

  11. How would I set a cookie to remember a user's information if they have a checkbox marked?  This is my current login script:

    <?php
    require_once('config.php');
    // Use session variable on this page. This function must put on the top of page.
    session_start();
    
    
    $message="";
    //Login Section.
    $Login=$_POST['submit'];
    if($Login){ // If clicked on Login button.
    $username=$_POST['username'];
    $password=md5($_POST['password']); // Encrypt password with md5() function.
    
    
    // Check matching of username and password.
    $result=mysql_query("select * from vbb_members where username='$username' and password='$password'");
    if(mysql_num_rows($result)!='0'){ // If match.
    session_register("username"); // Craete session username.
    mysql_query("UPDATE vbb_members SET logged_in=logged_in+1 WHERE username='$username'");
    
    header("location:index.php"); // Re-direct to main.php
    exit;
    }else{ // If not match.
    $message="--- Incorrect Username or Password ---";
    }
    
    } // End Login authorize check.
    ?> 
    
    
    <? echo $message; ?> 
    <table>
    <tr>
    <td>User : </td>
    <td><input name="username" type="text" id="username" /></td>
    </tr>
    <tr>
    <td>Password : </td>
    <td><input name="password" type="password" id="password" /></td>
    </tr>
    </table>
    <input name="Login" type="submit" id="Login" value="Login" />
    </form>
    </body>
    </html>
    

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