• 0

login display username


Question

Recommended Posts

  • 0

Oh, well have you set a session for 'loggedIn'?

A logout page is really easy. All you need is the following:

<?php   
if (isset($_SESSION['myusername'])) {  
session_destroy();   
}   
?>

Done that but when i return back to home it still shows me as logged in? Also before i log myself in, the error code. At this moment in time i cant show you as it wont allow me to see but basically its a error that is there before you log in but after its gone?

Once i can get it to come up again il edit post

  • 0

OOps my bad, use this, forgot to start the session.

<?php   
session_start();
if (isset($_SESSION['myusername'])) {  
session_destroy();   
}
?>

Thank you! Logout is working fine now!

Also here is there error code before logging in, which dissapears after i log in

Notice: Undefined index: myusername in C:\xampp\htdocs\mywebsite\Untitled1.php on line 146

  • 0
<?php 
session_start(); 
?>

<html>
  <head>
    <title>UniLad.co.uk| Home</title>
    <meta content="text/html; charset=unicode" http-equiv="Content-Type"/>
    <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"/>
    <meta name="created" content="Thu, 09 Jun 2011 10:35:58 GMT"/>
    <meta name="description"/>
    <meta name="keywords"/>
    <style type="text/css">
    <!--
    body {
      color:#000000;
      background-color:#FFFFFF;
    }
    a  { color:#0000FF; }
    a:visited { color:#800080; }
    a:hover { color:#008000; }
    a:active { color:#FF0000; }
    -->
    </style>
    <script src="https://widgets.twimg.com/j/2/widget.js">
    </script>
  </head>
  <body>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="484" align="left" height="57">
          <tbody>
            <tr height="63" valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <br/>
                <strong>
                  <font size="5" face="Tempus Sans ITC">UniLad.co.uk</font> </strong>
              </td>
            </tr>
          </tbody>
        </table>
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
            <font size="2" face="Tempus Sans ITC"></font>
          </div>
        </div>
      </div>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="503" align="right" height="48">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                  <a href="http://www.facebook.com/">
                    <font size="2" face="Tempus Sans ITC">
                      <img style="Z-INDEX: 100; POSITION: absolute; TOP: 15px; LEFT: 874px" border="0" src="FaceBook_512x512.png" width="40" height="40"/> </font></a>
                  <font size="2" face="Tempus Sans ITC"> <br/> </font> <a href="http://www.twitter.com/louismoore18">
                    <font size="2" face="Tempus Sans ITC"> <img style="Z-INDEX: 100; POSITION: absolute; TOP: 15px; LEFT: 927px" border="0" src="twitter-icon.png" width="40" height="40"/></font></a> <a></a><font size="2">
                    <font face="Tempus Sans ITC">        <strong> <em>"Fun, Banter,Uni "   UniLAD                 <font size="1">find us on</font>.. </em></strong></font>
                  </font></td>
              </tr>
            </tbody>
          </table>
          <br/>
        </div>
      </div>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <br/>
      <br/>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <br/>___________________________________________________________________________________________________________________________<br/><table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="364" align="right" height="48">
          <tbody>
            <tr height="32" valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <p align="center">
                  <font face="Tempus Sans ITC">Any questions dont hesitate to contact us.....<br/>Email: </font>
                  <a href="mailto:[email protected]">
                    <font face="Tempus Sans ITC">[email protected]</font></a> </p>
              </td>
            </tr>
          </tbody>
        </table><div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div></div>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="562" align="left" height="90">
          <tbody>
            <tr height="91" valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <font face="Tempus Sans ITC"></font>
                <em>
                  <font face="Tempus Sans ITC">
                    <form method="post" name="form1" action="checklogin.php"> Login: <input id="myusername" size="14" name="myusername"/> Password: <input id="mypassword" size="14" type="password" name="mypassword"/> <input value="Login" type="submit" name="mysubmit"/></form>New users? <a href="Untitled7.html">click here</a>         <a href="Untitled8.html">Forgotten password?<br/></a></font>
                </em>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <br/>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div>
      <br/>
      <br/>
      <br/>
      <br/>.....................................................................................................................................................................................................................................................<br/><table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="986" align="left" height="51">
        <tbody>
          <tr height="54" valign="top">
            <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
              <br/>
              <a href="Untitled1.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Home</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong> | <a href="Untitled9.html">Forum</a> | </strong> </font>
              <a href="Untitled3.html"></a>
              <a href="Untitled3.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Hottest Uni's</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong>|</strong> </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>
                  <a href="Untitled3.html">
                    <font size="4" face="Tempus Sans ITC">
                      <strong>Rate your Uni </strong>
                    </font></a>
                </strong>
              </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>| <a href="Untitled10.html">Uni LAD test</a>| <a href="Untitled11.html">Events</a> |</strong> </font>
              <a href="Untitled6.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Buy</strong> </font></a>            <font size="4" face="Tempus Sans ITC"> </font><?php echo 'LAD: '.$_SESSION['myusername']; ?>  <a href="logout.php">Logout</a></td>
          </tr>
        </tbody>
      </table><br/><br/><br/><br/><br/></div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="250" align="right" height="495">
          <tbody>
            <tr valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <br/>ADVERTISMENT<br/><object style="WIDTH: 250px; HEIGHT: 447px; " classid="clsid:D697CDE7E-AE6D-11cf-96B8-458453540000"
  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
  id="animation name" >
  <param name="movie" value="Untitled-2.swf">
  <param name="quality" value="high">
  <param name="bgcolor" value="#FFFFFF">

  <embed style="WIDTH: 250px; HEIGHT: 447px; " name="Untitled-2" src="Untitled-2.swf" quality="high" bgcolor="#FFFFFF"

    type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
  </embed>
</object> </td>
            </tr>
          </tbody>
        </table>
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <br/>
          <table style="BACKGROUND-COLOR: #ffffff" cellspacing="2" cellpadding="2" width="492" align="left" height="114">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                  <font face="Tempus Sans ITC">UniLAD. Are you a uniLAD? Have you got some LAD experience's? Rate your uni for other LAD's! UniLad is a LAD website for all the UniLads out there!. Use the website to share some of your LAD experiences. Come to one of our local events. All is fun and games. Look out more LAD things in the future. Enjoy!<br/></font>
                  <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div>
                </td>
              </tr>
            </tbody>
          </table>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="489" height="251">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">Current hotiest leaderboard<br/><div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" cellspacing="2" cellpadding="2" width="487" align="left" height="92">
          <tbody>
            <tr valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">        <br/><font face="Tempus Sans ITC">This is a WARNING to all users. The decision on what university/college to go to should not be based soley on how hot the school is! You need to take into consideration other factors too</font> </td>
            </tr>
          </tbody>
        </table>
        <br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="489" align="left" height="122">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                  <u>
                    <font face="Tempus Sans ITC">
                      <strong>Advertiment</strong> </font>
                  </u>
                  <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div>
                  <font face="Tempus Sans ITC">Are you interesting in advertising with us? <br/>Contact "</font> <a href="mailto:[email protected]">
                    <font face="Tempus Sans ITC">[email protected]</font></a> <font face="Tempus Sans ITC">" <br/></font><div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
                    <font face="Tempus Sans ITC">For price plans and deals<br/>UniLad </font> </div></td>
              </tr>
            </tbody>
          </table>
          <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
            <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="474" align="right" height="151">
              <tbody>
                <tr valign="top">
                  <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                    <form method="post" action="https://www.paypal.com/cgi-bin/webscr">
                      <input value="_s-xclick" type="hidden" name="cmd"/> <input value="KC9XSUXLTVGZ6" type="hidden" name="hosted_button_id"/> <input border="0" alt="PayPal - The safer, easier way to pay online." src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" type="image" name="submit"/> <img border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"/> </form>
                    <font face="Tempus Sans ITC">Help us carry on running by donating please! It can be anything as little as 20p! All will be welcomed!!</font> </td>
                </tr>
              </tbody>
            </table>
            <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
              <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>____________________________________________________________________________________________________________________________<br/><font size="1" face="Tempus Sans ITC">                                                              Officially owned by UniLad.co.uk | We own rights to the domain 'www.UniLad.co.uk | Website created by Louis Moore | </font></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

  • 0

OK ,Fixed it. You needed to check whether the LAD was checked in on line 146 ;).

<?php 
session_start(); 
?>

<html>
  <head>
    <title>UniLad.co.uk| Home</title>
    <meta content="text/html; charset=unicode" http-equiv="Content-Type"/>
    <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"/>
    <meta name="created" content="Thu, 09 Jun 2011 10:35:58 GMT"/>
    <meta name="description"/>
    <meta name="keywords"/>
    <style type="text/css">
    <!--
    body {
      color:#000000;
      background-color:#FFFFFF;
    }
    a  { color:#0000FF; }
    a:visited { color:#800080; }
    a:hover { color:#008000; }
    a:active { color:#FF0000; }
    -->
    </style>
    <script src="https://widgets.twimg.com/j/2/widget.js">
    </script>
  </head>
  <body>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="484" align="left" height="57">
          <tbody>
            <tr height="63" valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <br/>
                <strong>
                  <font size="5" face="Tempus Sans ITC">UniLad.co.uk</font> </strong>
              </td>
            </tr>
          </tbody>
        </table>
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
            <font size="2" face="Tempus Sans ITC"></font>
          </div>
        </div>
      </div>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="503" align="right" height="48">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                  <a href="http://www.facebook.com/">
                    <font size="2" face="Tempus Sans ITC">
                      <img style="Z-INDEX: 100; POSITION: absolute; TOP: 15px; LEFT: 874px" border="0" src="FaceBook_512x512.png" width="40" height="40"/> </font></a>
                  <font size="2" face="Tempus Sans ITC"> <br/> </font> <a href="http://www.twitter.com/louismoore18">
                    <font size="2" face="Tempus Sans ITC"> <img style="Z-INDEX: 100; POSITION: absolute; TOP: 15px; LEFT: 927px" border="0" src="twitter-icon.png" width="40" height="40"/></font></a> <a></a><font size="2">
                    <font face="Tempus Sans ITC">        <strong> <em>"Fun, Banter,Uni "   UniLAD           &
nbsp;     <font size="1">find us on</font>.. </em></strong></font>
                  </font></td>
              </tr>
            </tbody>
          </table>
          <br/>
        </div>
      </div>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <font size="2" face="Tempus Sans ITC"></font>
    </div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <br/>
      <br/>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <br/>___________________________________________________________________________________________________________________________<
br/><table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="364" align="right" height="48">
          <tbody>
            <tr height="32" valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <p align="center">
                  <font face="Tempus Sans ITC">Any questions dont hesitate to contact us.....<br/>Email: </font>
                  <a href="mailto:[email protected]">
                    <font face="Tempus Sans ITC">[email protected]</font></a> </p>
              </td>
            </tr>
          </tbody>
        </table><div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div></div>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="562" align="left" height="90">
          <tbody>
            <tr height="91" valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <font face="Tempus Sans ITC"></font>
                <em>
                  <font face="Tempus Sans ITC">
                    <form method="post" name="form1" action="checklogin.php"> Login: <input id="myusername" size="14" name="myusername"/> Password: <input id="mypassword" size="14" type="password" name="mypassword"/> <input value="Login" type="submit" name="mysubmit"/></form>New users? <a href="Untitled7.html">click here</a>         <a href="Untitled8.html">Forgotten password?<br/></a></font>
                </em>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <br/>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div>
      <br/>
      <br/>
      <br/>
      <br/>..............................................................................................................
..........................................................................................................................
.............<br/><table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="986" align="left" height="51">
        <tbody>
          <tr height="54" valign="top">
            <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
              <br/>
              <a href="Untitled1.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Home</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong> | <a href="Untitled9.html">Forum</a> | </strong> </font>
              <a href="Untitled3.html"></a>
              <a href="Untitled3.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Hottest Uni's</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong>|</strong> </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>
                  <a href="Untitled3.html">
                    <font size="4" face="Tempus Sans ITC">
                      <strong>Rate your Uni </strong>
                    </font></a>
                </strong>
              </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>| <a href="Untitled10.html">Uni LAD test</a>| <a href="Untitled11.html">Events</a> |</strong> </font>
              <a href="Untitled6.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Buy</strong> </font></a>      
      <font size="4" face="Tempus Sans ITC"> </font><?php if (isset($_SESSION['myusername'])) {  echo 'LAD: '.$_SESSION['myusername']; } else { echo 'Please Login LAD!'; } ?>  <a href="logout.php">Logout</a></td>
          </tr>
        </tbody>
      </table><br/><br/><br/><br/><br/></div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="250" align="right" height="495">
          <tbody>
            <tr valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                <br/>ADVERTISMENT<br/><object style="WIDTH: 250px; HEIGHT: 447px; " classid="clsid:D697CDE7E-AE6D-11cf-96B8-458453540000"
  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
  id="animation name" >
  <param name="movie" value="Untitled-2.swf">
  <param name="quality" value="high">
  <param name="bgcolor" value="#FFFFFF">

  <embed style="WIDTH: 250px; HEIGHT: 447px; " name="Untitled-2" src="Untitled-2.swf" quality="high" bgcolor="#FFFFFF"

    type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
  </embed>
</object> </td>
            </tr>
          </tbody>
        </table>
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <br/>
          <table style="BACKGROUND-COLOR: #ffffff" cellspacing="2" cellpadding="2" width="492" align="left" height="114">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                  <font face="Tempus Sans ITC">UniLAD. Are you a uniLAD? Have you got some LAD experience's? Rate your uni for other LAD's! UniLad is a LAD website for all the UniLads out there!. Use the website to share some of your LAD experiences. Come to one of our local events. All is fun and games. Look out more LAD things in the future. Enjoy!<br/></font>
                  <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div>
                </td>
              </tr>
            </tbody>
          </table>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <br/>
          <table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="489" height="251">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">Current hotiest leaderboard<br/><div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" cellspacing="2" cellpadding="2" width="487" align="left" height="92">
          <tbody>
            <tr valign="top">
              <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">        <br/><font face="Tempus Sans ITC">This is a WARNING to all users. The decision on what university/college to go to should not be based soley on how hot the school is! You need to take into consideration other factors too</font> </td>
            </tr>
          </tbody>
        </table>
        <br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <br/>
        <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
          <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="489" align="left" height="122">
            <tbody>
              <tr valign="top">
                <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                  <u>
                    <font face="Tempus Sans ITC">
                      <strong>Advertiment</strong> </font>
                  </u>
                  <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"></div>
                  <font face="Tempus Sans ITC">Are you interesting in advertising with us? <br/>Contact "</font> <a href="mailto:[email protected]">
                    <font face="Tempus Sans ITC">[email protected]</font></a> <font face="Tempus Sans ITC">" <br/></font><div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
                    <font face="Tempus Sans ITC">For price plans and deals<br/>UniLad </font> </div></td>
              </tr>
            </tbody>
          </table>
          <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
            <table style="BACKGROUND-COLOR: #ffffff" border="0" cellspacing="2" cellpadding="2" width="474" align="right" height="151">
              <tbody>
                <tr valign="top">
                  <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
                    <form method="post" action="https://www.paypal.com/cgi-bin/webscr">
                      <input value="_s-xclick" type="hidden" name="cmd"/> <input value="KC9XSUXLTVGZ6" type="hidden" name="hosted_button_id"/> <input border="0" alt="PayPal - The safer, easier way to pay online." src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" type="image" name="submit"/> <img border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"/> </form>
                    <font face="Tempus Sans ITC">Help us carry on running by donating please! It can be anything as little as 20p! All will be welcomed!!</font> </td>
                </tr>
              </tbody>
            </table>
            <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
              <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>____________________________________________________________________________________________________________________________<
br/><font size="1" face="Tempus Sans ITC">           
            &
nbsp;            
            &
nbsp;            
 Officially owned by UniLad.co.uk | We own rights to the domain 'www.UniLad.co.uk | Website created by Louis Moore | </font></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

  • 0

More or less the same as other coees I've given.

<?php if (isset($_SESSION['myusername'])) {  echo '<a href='logout.php'>Logout</a>'; } ?>

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\mywebsite\Untitled1.php on line 143

this may aswell be a convo between me and you haha

  • 0

Thanks guys!

Another quick question... At the moment, when logging in and username/password are incorrect it goes to a seperate page and displays 'Username/Password not correct' but i want this to pop up in an alert box if possible? This is the code for my main page login in function

<form method="post" name="form1" action="checklogin.php"> Login: <input id="myusername" size="14" name="myusername"/> Password: <input id="mypassword" size="14" type="password" name="mypassword"/> <input value="Login" type="submit" name="mysubmit"/></form>

and then it goes to checklogin.php which in this displays the error code. But i want it to display the alert before it goes to this page

  • 0

I'm sorry, I really don't know! I know it may be simple but I think coz it's simple that's why I'm missing it!

I know how to create an alert box and I've seen with my checklogin.php page how it connects to database and checks it but I can't get my head around it :/

  • 0

can you help please?

Ive got a post message board system. Ive got it to write to a database and display form the database but if i want to post a comment on this it first displays

Reply Posted.

C:\xampp\htdocs\mywebsite\msg.php on line 41

12'>Return

And when i click the link it displays

Go Back...You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '

Notice: Use of undefined constant id - assumed' at line 1

Can you help i dont understand what it is...

<?php    
// Connecting to the database again    
mysql_connect("localhost", "root", "");    
mysql_select_db("test");   
// Here's a link that will allow you to go back to the index    
echo "<a href='Untitled9.php'>Go Back...</a>";   
// This query selects the current thread using the $_GET value.    
$sql = mysql_query("SELECT * FROM threads WHERE id = " . $_GET['id'] . "") or die(mysql_error());   


//Now we are getting our results and making them an array    
while($r = mysql_fetch_array($sql)) {    
// Here is the thread title.    
echo "<h2>$r[title]</h2>";    
// Everything within the two curly brackets can read from the database using $r[]    
// We need to convert the UNIX Timestamp entered into the database for when a thread...    
// ... is posted into a readable date, using date().    
$posted = date("jS M Y h:i",$r['posted']);   
// Now this shows the thread with a horizontal rule after it.    
echo "$r[message]<h4>Posted by $r[author] on $posted</h4><hr>";    
// End of Array    
}   

echo "<h3>Replies...</h3>";    
// Here we will get it to show the replies    
// This query selects the replies from the database where the thread ID matches the thread $_GET value.    
$sql = mysql_query("SELECT * FROM replies WHERE thread = '$_GET[id]'");    
// Now we are getting our results and making them an array    
while($r = mysql_fetch_array($sql)) {    
// Everything within the two curly brackets can read from the database using $r[]    
// We need to convert the UNIX Timestamp entered into the database for when a thread...    
// ... is posted into a readable date, using date().    
$posted = date("jS M Y h:i",$r[posted]);    
// Now this shows the thread with a horizontal rule after it.    
echo "$r[message]<h4>Posted by $r[author] on $posted</h4><hr>";    
// End of Array    
}    
?>   
<form action="newreply.php" method="POST">    
Your Name: <input type="text" name="author">    
/* Line 41 */<input type="hidden" value="<?php echo $_GET[id]; ?>" name="thread"><br>    
Message:<br><textarea cols="60" rows="5" name="message"></textarea><br>    
<input type="submit" value="Post Reply">    
</form> 

  • 0

Here you go, it's quick and dirty and omits the form, but you should get the gist of it.

<?php
function getThreadById($id){
  $res = mysql_query(sprintf('SELECT * FROM threads WHERE id = %d LIMIT 1;', $id));
  return is_resource($res) ? mysql_fetch_assoc($res) : false ;
}
function getRepliesByThreadId($id){
  $replies = array();
  $res = mysql_query(sprintf('SELECT * FROM replies WHERE thread = %d;', $id));
  while($reply = mysql_fetch_assoc($res)){
    array_push($replies, $reply);
  }
  return $replies;
}
?>
<html>
  <head>
    <title>
      Threads
    </title>
  </head>
  <body>
    <?php if($thread = getThreadById(filter_input(INPUT_GET, 'id'))): ?>
      <div id="thread">
        <h2>
          <?php echo $thread['title']; ?>
        </h2>
        <p>
          <?php echo $thread['message']; ?>
        </p>
        <h4>
          Posted by <?php echo $thread['message']; ?> on <?php echo date('jS M Y h:i', $thread['posted']); ?>
        </h4>
      </div>
      <div id="replies">
        <?php if(0 < count($replies = getRepliesByThreadId($thread['id']))): ?>
          <h3>
            Replies
          </h3>
          <?php foreach($replies as $reply): ?>
            <p>
              <?php echo $reply['message']; ?>
            </p>
            <h4>
              Posted by <?php echo $reply['message']; ?> on <?php echo date('jS M Y h:i', $reply['posted']); ?>
            </h4>
          <?php endforeach; ?>
        <?php else: ?>
          <h3>
            No Replies
          </h3>
        <?php endif; ?>
      </div>
    <?php else: ?>
      <p>
        Invalid Thread
      </p>
    <?php endif; ?>
  </body>
</html>

  • 0

Eeep, sorry, noticed a typo.

<?php

function getThreadById($id){
  $res = mysql_query(
    sprintf('SELECT * FROM threads WHERE id = %d LIMIT 1;', $id)
  );
  return is_resource($res) ? mysql_fetch_assoc($res) : false ;
}

function getRepliesByThreadId($id){
  $replies = array();
  $res = mysql_query(
    sprintf('SELECT * FROM replies WHERE thread = %d;', $id)
  );
  while($reply = mysql_fetch_assoc($res)){
    array_push($replies, $reply);
  }
  return $replies;
}

function posted_on($time, $format = 'jS M Y h:i'){
  return date($format, $time);
}

?>
<html>
  <head>
    <title>
      Threads
    </title>
  </head>
  <body>
    <?php if($thread = getThreadById(filter_input(INPUT_GET, 'id'))): ?>
      <div id="thread">
        <h2><?php echo $thread['title']; ?></h2>
        <p><?php echo $thread['message']; ?></p>
        <h4>Posted by <?php echo $thread['author']; ?> on <?php echo posted_on($reply['posted']); ?></h4>
      </div>
      <div id="replies">
        <?php if(0 < count($replies = getRepliesByThreadId($thread['id']))): ?>
          <h3>Replies</h3>
          <?php foreach($replies as $reply): ?>
            <p><?php echo $reply['message']; ?></p>
            <h4>Posted by <?php echo $reply['author']; ?> on <?php echo posted_on($reply['posted']); ?></h4>
          <?php endforeach; ?>
        <?php else: ?>
          <h3>No Replies</h3>
        <?php endif; ?>
      </div>
    <?php else: ?>
      <p>Invalid Thread</p>
    <?php endif; ?>
  </body>
</html>

  • 0

Eeep, sorry, noticed a typo.

<?php

function getThreadById($id){
  $res = mysql_query(
    sprintf('SELECT * FROM threads WHERE id = %d LIMIT 1;', $id)
  );
  return is_resource($res) ? mysql_fetch_assoc($res) : false ;
}

function getRepliesByThreadId($id){
  $replies = array();
  $res = mysql_query(
    sprintf('SELECT * FROM replies WHERE thread = %d;', $id)
  );
  while($reply = mysql_fetch_assoc($res)){
    array_push($replies, $reply);
  }
  return $replies;
}

function posted_on($time, $format = 'jS M Y h:i'){
  return date($format, $time);
}

?>
<html>
  <head>
    <title>
      Threads
    </title>
  </head>
  <body>
    <?php if($thread = getThreadById(filter_input(INPUT_GET, 'id'))): ?>
      <div id="thread">
        <h2><?php echo $thread['title']; ?></h2>
        <p><?php echo $thread['message']; ?></p>
        <h4>Posted by <?php echo $thread['author']; ?> on <?php echo posted_on($reply['posted']); ?></h4>
      </div>
      <div id="replies">
        <?php if(0 < count($replies = getRepliesByThreadId($thread['id']))): ?>
          <h3>Replies</h3>
          <?php foreach($replies as $reply): ?>
            <p><?php echo $reply['message']; ?></p>
            <h4>Posted by <?php echo $reply['author']; ?> on <?php echo posted_on($reply['posted']); ?></h4>
          <?php endforeach; ?>
        <?php else: ?>
          <h3>No Replies</h3>
        <?php endif; ?>
      </div>
    <?php else: ?>
      <p>Invalid Thread</p>
    <?php endif; ?>
  </body>
</html>

Thanks for the time taken to write that for me! :)

Although when i post, i can see it but when i click on it, it displays 'Invalid thread' ?

Heres code for posting

<?php  
mysql_connect("localhost", "root", "");  
mysql_select_db("test");  
?> 

<form action="newthread.php" method="POST"> 
LAD Name: <input type="text" name="author" ><br>  
 Title: <input type="text" name="title" ><br>  
Message:<br><textarea cols="60" rows="5" name="message"></textarea><br>  
<input type="submit" value="Post Banter">  
</form> 


<?php  
// We are selecting everything from the threads section in the database and ordering them newest to oldest.  
$sql = mysql_query("SELECT * FROM threads ORDER BY posted DESC");     
// Now we are getting our results and making them an array  
while($r = mysql_fetch_array($sql)) {   
// Everything within the two curly brackets can read from the database using $r[]  
// We need to convert the UNIX Timestamp entered into the database for when a thread...  
// ... is posted into a readable date, using date().  
$posted = date("jS M Y h:i",$r['posted']);  
// Now we will show the available threads  
echo "<h3><a href='msg.php?id=$r[id]'>$r[title]</a> ($r[replies])</h3><h4>Posted by $r[author] on $posted</h4>";    
// End of Array  
}  
?> 

  • 0

A few points to take note of:-

  1. Make sure that script is connecting to the database
  2. Make sure the URL format is .php?id=1, where 1 is the thread id
  3. Make sure the id you're passing is a valid thread

Had a little play, Got it working!

Thanks

Untill next time

  • 0

Notice: Undefined offset: 0 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 41

Notice: Undefined offset: 0 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 27

Notice: Undefined offset: 1 in C:\xampp\htdocs\mywebsite\reddit_vote_tut\src\votes.php on line 27

<?php 
include("config.php"); 

function getAllVotes($id) 
        { 
        /** 
        Returns an array whose first element is votes_up and the second one is votes_down 
        **/ 
        $votes = array(); 
        $q = "SELECT * FROM entries WHERE id = $id"; 
        $r = mysql_query($q); 
        if(mysql_num_rows($r)==1)//id found in the table 
                { 
                $row = mysql_fetch_assoc($r); 
                $votes[0] = $row['votes_up']; 
                $votes[1] = $row['votes_down']; 
                } 
        return $votes; 
        } 

function getEffectiveVotes($id) 
        { 
        /** 
        Returns an integer 
        **/ 
        $votes = getAllVotes($id); 
/* line 27 */   $effectiveVote = $votes[0] - $votes[1]; 
        return $effectiveVote; 
        } 

$id = $_POST['id']; 
$action = $_POST['action']; 

//get the current votes 
$cur_votes = getAllVotes($id); 

//ok, now update the votes 

if($action=='vote_up') //voting up 
{ 
/*line 41 */    $votes_up = $cur_votes[0]+1; 
        $q = "UPDATE threads SET votes_up = $votes_up WHERE id = $id"; 
} 
elseif($action=='vote_down') //voting down 
{ 
        $votes_down = $cur_votes[1]+1; 
        $q = "UPDATE threads SET votes_down = $votes_down WHERE id = $id"; 
} 

$r = mysql_query($q); 
if($r) //voting done 
        { 
        $effectiveVote = getEffectiveVotes($id); 
        echo $effectiveVote." votes"; 
        } 
elseif(!$r) //voting failed 
        { 
        echo "Failed!"; 
        } 
?>

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • NirLauncher 1.30.24 by Razvan Serea NirLauncher is a suite of more than 200 of NirSoft's excellent portable freeware Windows utilities, and provides an interface that makes it easy to find and launch the tools you need. Which works for us - because there's something here for everyone. Have you forgotten a password stored in your browser or email client, for instance? Recovery tools here may be able to find them for you. Maybe you'd like to check your hard drive health? A disk tool will display its S.M.A.R.T. data (if the drive supports this), so you can view read/ write errors, temperature and other useful details. Is your system unstable? The System Utilities section includes several tools that can help to explain why your PC might be crashing. And there are a host of other programs on offer in categories like "Network Monitoring", "Web Browser Tools", "Video/ Audio Related Utilities", "Outlook/ Office Utilities" and more. Please note, perhaps because a few of these tools can be used maliciously (the password revealers, say), some antivirus programs will flag them as threats. We've never had a problem with any NirSoft tool, though, and you can read more on this issue at the author's site. NirLauncher is an excellent set of free tools, and a must-have for everyone's portable troubleshooting toolkit. NirLauncher Features: NirLauncher can be used from USB flash drive without need of any installation. NirLauncher and all the utilities in the package are completely freeware, without any Spyware/Adware/Malware. This package doesn't contain any 3-party software, toolbars, Web browser plugins, or other unwanted surprises. It will not install any software on your system and it will not change your Web browser homepage or other settings on your system. NirLauncher package includes variety of tools that you may need for your daily computer use, including utilities to recover lost passwords, to monitor your network, to view and extract cookies, cache, and other information stored by your Web browser, to search files in your system, and more... For every utility in the package, you can easily run it, view the help file, or jump to the Web page of the utility. When using it from USB flash drive, the configuration of every utility is saved into .cfg file on the flash drive. On x64 systems, NirLauncher automatically run the x64 version of the utility, when there is a separated x64 version. NirLauncher also allows to add more software packages in additional to the main NirSoft package. NirLauncher allows you generate plugin files for BartPE (Launcher -> Generate BartPE Plugin Files), so you can easily use the utilities of NirSoft from a bootable live windows CD. Additional packages (Piriform, SysInternals...) and instructions are available on the Nirlauncher download page. Note: This zip file below is password-protected. The password for extracting the files is nirsoft9876$ Download: NirLauncher 1.30.24 | 39.8 MB (Freeware) Link: NirLauncher Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • What people who support this position of LibreOffice do not understand is that EuroOffice is not made to appease the open source enthusiasts (I am also one) and evangelists. EuroOffice was made because some European companies wanted independence from Microsoft Office Suite, which is something installable on your computer. This move to independence was pushed by public institutions and governments in Europe, as well. Using a proprietary FORMAT as default, does not make you dependent on MS. The actual program does. A format can be changed with a simple update in the future in a dystopian world where MS would manipulate the format to lock others out. However, using MS Office proprietary format, guarantees that all the current documents used by companies, organizations, institutions, etc, will be compatible with EuroOffice and the suite will have the best chances at adoption, especially by slow moving organizations like governments and the public sector. It is as simple as that. For the same reason, even the UI is incredibly similar to MS Office. For the same reason (adoption) the choice was made to be open source. Not because EU particularly loves open source ideologically, but because it gives the best starting point to create trust in the project and amass developers and contributions to the project quickly, to catch up with proprietary projects like MS Office. I don't understand how people don't realize it.
    • How old is this tip? Seems 15-20 years old? Processor states for the CPU under Windows power options has been a thing for a long, long time. It certainly isn't new or hidden... Also, with laptops it doesn't make any difference what OS you are running, all of them are configured for battery longevity over performance, for obvious reasons. Wanted to add as well that most systems in use currently do burst as setup in the uefi bios settings, and usually when a setting is "hidden" like this in Windows it's because it's either obsolete or it is redundant--doesn't override the bios and the CPU drivers. There is a lot of crap in the registry that needs to come out...;) It's hamless and might consume 1-2kb of space in total, though.
    • I can't believe Starmer is still there...his party lost so big. He's a stubborn coot, but this is largely unenforceable, so I would imagine he'll be resigning soon. A key here is for parents to buy their kids phones sans Internet access--and set up the Internet at home, where mom and day can, you know, act like parents instead expecting the government to raise their kids.
    • EA launches in-game advertising platform for brands to "connect with audiences" by Pulasthi Ariyasinghe The gaming giant Electronic Arts is exploring more ways to inject real-life brands into its games. Announced today as EA Advertising, the new platform is attempting to make it easier for brands to reach out for deals with the company and put their products inside titles like EA Sports FC, Madden, NHL, Skate, or The Sims. EA revealed that its EA Sports side of the company brings in "hundreds of millions of players across console, PC, and mobile" every year. Fan engagement of these titles was also touted as being "extraordinary," with 23,000 NFL seasons worth of games being played in Madden NFL daily, while EA Sports FC sees over a billion matches a day. “Players come to EA’s games and live experiences every day to play, watch, create and connect,” said David Tinson, Chief Experiences Officer at Electronic Arts. “That gives brands a meaningful opportunity to show up in ways that add value and respect the player experience, while maintaining authenticity in the worlds our teams are building. With EA Advertising, we’re helping brands become part of those moments in ways that are relevant and built for players.” Using the new program EA Advertising, brands will be able to inject their products into games in real-time via dynamic placement. EA says partners will have access to everything from stadium signage in sports games and targeted adverts to in-game content custom-made for the brands. These are described as additions designed to "enhance, not disrupt" experiences. "In these interactive gameplay environments, brands become part of the game itself, reflecting how players engage with advertising in real-world contexts," adds the company "Brands can activate across live environments, tailoring placements to meet campaign objectives, and update campaigns with ongoing optimization informed by aggregated engagement insights." Current real-world brand partnerships EA has built into its games include Visa (EA Sports FC and College Football), Lowe's (EA Sports FC, Madden NFL, and College Football), Red Bull (EA SPORTS FC), Xfinity and Peacock (EA SPORTS FC), and Mountain Dew’s (College Football).
  • Recent Achievements

    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
    • Conversation Starter
      flexorcist earned a badge
      Conversation Starter
    • One Month Later
      AndreaB earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      512
    2. 2
      +Edouard
      205
    3. 3
      PsYcHoKiLLa
      136
    4. 4
      ATLien_0
      91
    5. 5
      Steven P.
      85
  • Tell a friend

    Love Neowin? Tell a friend!