Jump to content

andrew_biggart

Members
  • Posts

    363
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by andrew_biggart

  1. Ok im getting the blank screen which means theres an error in my code grr. I have tried the above solution by changing all " to /", and i have also tried changing them to '. But i cant get my head around this at all. This is the code im trying to use can someone please have a scan through it and let me know what i am doing wrong! Thanks for your patience! <?php if(isset($_SESSION['myusername'])) { echo " <img alt='' src='../icons/myacc.gif/' width='12' height='11' /> <a class='button6' href='my_profile.php'>My Account</a> <img alt='' src='../icons/mypro.gif' width='12' height='11' /> <a class='button6' href='profile.php'>My Profile</a> <img alt='' src='../icons/mymes.gif' width='12' height='11' /> <a class='button6' href='my_profile_messages.php'>My Messages</a> <img alt='' src='../icons/myale.gif' width='11' height='11' /> <a class='button6' href='my_profile_alerts.php'>My Alerts</a> <img alt='' src='../icons/myreq.gif' width='12' height='11' /> <a class='button6' href='my_profile_requests.php'>My Requests</a> <img alt='' src='../icons/myfri.gif' width='12' height='11' /> <a class='button6' href='my_profile_friends.php'>My Friends</a> <img alt='' src='../icons/mylog.gif' width='12' height='12' /> <a class='button6' href='logout.php'>Logout</a> "; } else{ <form method='post'> <table style='float: right'> <tr> <td><input class='username' name='username' type='text' value='Username'/></td> <td class='logmein'>:Username</td> <td><input class='password' name='Password1' type='password' value='Password'/></td> <td class='logmein'>:Password</td> <td><input class='submit' name='Submit2' type='submit' value='C'umon in'/><a href='user_register.htm'"><input class='register' name='Submit2' type='button' value='Register'/></a></td> </tr> </table> </form> } ?>
  2. ok so this is what i have got! <?php if(isset($_SESSION['myusername'])) { echo " <img alt=/"/" src=/"../icons/myacc.gif/" width=/"12/" height=/"11/" /> <a class=/"button6/" href=/"my_profile.php/">My Account</a> <img alt=/"/" src=/"../icons/mypro.gif/" width=/"12/" height=/"11/" /> <a class=/"button6/" href=/"profile.php?username=$myusername/">My Profile</a> <img alt=/"/" src=/"../icons/mymes.gif/" width=/"12/" height=/"11/" /> <a class=/"button6/" href=/"my_profile_messages.php/">My Messages</a> <img alt=/"/" src=/"../icons/myale.gif/" width=/"11/" height=/"11/" /> <a class=/"button6/" href=/"my_profile_alerts.php/">My Alerts</a> <img alt=/"/" src=/"../icons/myreq.gif/" width=/"12/" height=/"11/" /> <a class=/"button6/" href=/"my_profile_requests.php/">My Requests</a> <img alt=/"/" src=/"../icons/myfri.gif/" width=/"12/" height=/"11/" /> <a class=/"button6/" href=/"my_profile_friends.php/">My Friends</a> <img alt=/"/" src=/"../icons/mylog.gif/" width=/"12/" height=/"12/" /> <a class=/"button6/" href=/"logout.php/">Logout</a> "; } else{ <form method=/"post/"> <table style=/"float: right/"> <tr> <td><input class=/"username/" name=/"username/" type=/"text/" value=/"Username/"/></td> <td class=/"logmein/">:Username</td> <td><input class=/"password/" name=/"Password1/" type=/"password/" value=/"Password/"/></td> <td class=/"logmein/">:Password</td> <td><input class=/"submit/" name=/"Submit2/" type=/"submit/" value=/"C'umon in/"/><a href=/"user_register.htm/"><input class=/"register/" name=/"Submit2/" type=/"button/" value=/"Register/"/></a></td> </tr> </table> </form> } ?> am i going along the right lines? thankyou by the way
  3. Ok so i have changed my mind! instead of displaying the div i want to display different info in the div depending on if the user is logged in or not! if the user is not logged in i want to display the following login form. <form method="post"> <table style="float: right"> <tr> <td><input class="username" name="username" type="text" value="Username"/></td> <td class="logmein">:Username</td> <td><input class="password" name="Password1" type="password" value="Password"/></td> <td class="logmein">:Password</td> <td><input class="submit" name="Submit2" type="submit" value="C'umon in"/><a href="user_register.htm"><input class="register" name="Submit2" type="button" value="Register"/></a></td> </tr> </table> </form> and if the user is logged in display a sub menu like this <img alt="" src="../icons/myacc.gif" width="12" height="11" /> <a class="button6" href="my_profile.php">My Account</a> <img alt="" src="../icons/mypro.gif" width="12" height="11" /> <a class="button6" href="profile.php?username=$myusername">My Profile</a> <img alt="" src="../icons/mymes.gif" width="12" height="11" /> <a class="button6" href="my_profile_messages.php">My Messages</a> <img alt="" src="../icons/myale.gif" width="11" height="11" /> <a class="button6" href="my_profile_alerts.php">My Alerts</a> <img alt="" src="../icons/myreq.gif" width="12" height="11" /> <a class="button6" href="my_profile_requests.php">My Requests</a> <img alt="" src="../icons/myfri.gif" width="12" height="11" /> <a class="button6" href="my_profile_friends.php">My Friends</a> <img alt="" src="../icons/mylog.gif" width="12" height="12" /> <a class="button6" href="logout.php">Logout</a> Basically i want the code to check whether or not the session myusername exists and echo the correct html if it is or isnt! Thanks for your help
  4. Thankyou, so do i need to chage all the " in the div to ' ??
  5. Ok what i want to do is have this div <div id="nav_menu"> <img alt="" src="../icons/myacc.gif" width="12" height="11" /> <a class="button6" href="my_profile.php">My Account</a> <img alt="" src="../icons/mypro.gif" width="12" height="11" /> <a class="button6" href="profile.php?username=$myusername">My Profile</a> <img alt="" src="../icons/mymes.gif" width="12" height="11" /> <a class="button6" href="my_profile_messages.php">My Messages</a> <img alt="" src="../icons/myale.gif" width="11" height="11" /> <a class="button6" href="my_profile_alerts.php">My Alerts</a> <img alt="" src="../icons/myreq.gif" width="12" height="11" /> <a class="button6" href="my_profile_requests.php">My Requests</a> <img alt="" src="../icons/myfri.gif" width="12" height="11" /> <a class="button6" href="my_profile_friends.php">My Friends</a> <img alt="" src="../icons/mylog.gif" width="12" height="12" /> <a class="button6" href="logout.php">Logout</a> </div> But i only want this information if the session $myusername is valid otherwise i dont want it to show up. Can someone please point me in the right direction to do this as i am at the end of teather with it Thanks
  6. I really need to start learning if statements but yea that has worked thanks alot everyone for your help
  7. one last thing sorry im trying to get the number to be displayed in brackets ie messages (5) nd when i try and put the brackets in the echo is fucks up so ive done it this way. With them before and after the php. But the problem is they show up even if there is no messages so how do i dd them to the echo successfully so they only show up when there is a number to display? (<?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Message_user) as mescount FROM User_messagesT WHERE Message_user='$username' "; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['mescount']; ?>)
  8. is this right now? quotes on which query? <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Message_user) as mescount FROM User_messagesT WHERE Message_user=$username "; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['mescount']; ?>
  9. Im trying to count the numbe of messages a user has and i can get it to count all the messages but when i try and add the where statement it doesnt display the number grrrrr. Im using the follwoing code. <?php include("config_contact.php"); $username=$_SESSION['myusername']; // Retrieve data from database $sql = "SELECT count(Message_user) as mescount WHERE Message_user=$username FROM User_messagesT "; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['mescount']; ?>
  10. Can anyone hep please? apologys for the double post but ive just realised i have posted it in the wrong section. But basiclly what i am trying to is first off al posts and info from the post table, then i want to get all the users that made a post eg $rows post_user and use this info to add to a select statement which wil then be used to slect the user_info table and select all rows where username=$rows post_user and then display prfoile_pic beside the post. Im using the folowing code but the image part is not working. <?php include("config_blog.php"); // Retrieve data from database $sql="SELECT * FROM User_postT ORDER BY Post_id DESC LIMIT 30" ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ // Retrieve data from database $sql2="SELECT * FROM User_infoT WHERE username=$rows Post_username" ; $result2=mysql_query($sql2); // Start looping rows in mysql database. while($rows2=mysql_fetch_array($result2)){ ?> <table class="profileforum"> <tr><td style="width: 55px"><? echo "<img src='../Thumbnail_images/". $rows2['Profile_picture'] . "' style='width:50px; height:50px;' />";?></td> <td> <table class="forum_post" cellspacing="0" cellpadding="0" style="width: 345px; height: 52px"> <tr><td class="forum_sub">Posted by <a class="posts1" href="profile.php?username=<? echo $rows['Post_username']; ?>"><? echo $rows['Post_username']; ?></a> on <? echo $rows['Post_date']; ?></td></tr> <tr><td class="forum_h" valign="top"><a class="posts2" href="view_topic.php?Post_id=<? echo $rows['Post_id']; ?>"><? echo $rows['Post_subject']; ?></a></td></tr> </table> </td></tr> </table> <? // close while loop } // close connection mysql_close(); ?>
  11. i just cant get my head around it at all!! is it really that difficult or am i just being retarded?
  12. What im trying to do is first of all select all of the recent posts made by users and display them and then i want so get the usernames of the people who made the post, once i have got these i want to select all users which are = to $rows post_usersnames and get there profile pic and display it beside the post. Its hard to explain this properly when ur this dumb lol but hopefully u can make some sense of it. Im using the following code to try and do it but im just getting a banc screen, although when i remove the scond select statement the post info dispays correctly. <?php include("config_blog.php"); // Retrieve data from database $sql="SELECT * FROM User_postT ORDER BY Post_id DESC LIMIT 30" ; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ // Retrieve data from database $sql2="SELECT * FROM User_infoT WHERE username=$rows Post_username" ; $result2=mysql_query($sql2); // Start looping rows in mysql database. while($rows2=mysql_fetch_array($result2)){ ?> <table class="profileforum"> <tr><td style="width: 55px"><? echo "<img src='../Thumbnail_images/". $rows2['Profile_picture'] . "' style='width:50px; height:50px;' />";?></td> <td> <table class="forum_post" cellspacing="0" cellpadding="0" style="width: 345px; height: 52px"> <tr><td class="forum_sub">Posted by <a class="posts1" href="profile.php?username=<? echo $rows['Post_username']; ?>"><? echo $rows['Post_username']; ?></a> on <? echo $rows['Post_date']; ?></td></tr> <tr><td class="forum_h" valign="top"><a class="posts2" href="view_topic.php?Post_id=<? echo $rows['Post_id']; ?>"><? echo $rows['Post_subject']; ?></a></td></tr> </table> </td></tr> </table> <? // close while loop } // close connection mysql_close(); ?>
  13. hear is one of the soutions i have tried but it just sends al users to the adminprofile.php instead of just the admin grrrrr. <?php include("config_members.php"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $row = mysql_fetch_assoc($result); $userav = $row['Profile_picture']; // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1 + $myusername=AdMiN){ // Register $myusername, $mypassword and redirect to file session_register("myusername"); session_register("mypassword"); $_SESSION['myusername'] = $myusername; $_SESSION['myavatar'] = $userav; header("location:admin_profile.php?username=$myusername"); exit(); } else if($count==1){ // Register $myusername, $mypassword and redirect to file session_register("myusername"); session_register("mypassword"); $_SESSION['myusername'] = $myusername; $_SESSION['myavatar'] = $userav; header("location:my_profile.php?username=$myusername"); exit(); } else { echo "<h1 class=login_status>Wrong Username or Password</h1>"; } ?>
  14. Im using the following code to check the username and password when ever i user logs in. <?php include("config_members.php"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $row = mysql_fetch_assoc($result); $userav = $row['Profile_picture']; // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file session_register("myusername"); session_register("mypassword"); $_SESSION['myusername'] = $myusername; $_SESSION['myavatar'] = $userav; header("location:my_profile.php?username=$myusername"); exit(); } else { echo "<h1 class=login_status>Wrong Username or Password</h1>"; } ?> What i want to do is add an if statement to check if myusername is = to admin and if so goto adminprofile.php and then for the else statemtent i want it to redirect to myprofile.php for ll other users, how do i go about doing this? ive tried a few different if statements but im not the best at them so can someone peae point me in the right direction please?
  15. Ok i know i shouldnt post this hear but i crawled the web over and over and know one wil give me answers like this one. What im after is some form of tutorial to explain to me how to write a script to upload an image, save one with a size of 100 x 100 and save another of 50 x 50 does anyone know any good tutorials online that coud point me in the right direction? Thanks
  16. Hey just a quick question but does anyone know where i can get a decent free mysql database? at the minute im usuing a site called freemysql.net but to put it its abit wank. Its making my code not work, i only need the free one to test my site etc but if anyone knows of where i can get a free thats a good as one that u have to pay for that would be awesome. Thnaks
  17. i do want to limit it in any way because its to show the comments that the users have made on a post so i want them all to be show for the post_id. Its happening on a few pages so i can seem to work out what i am doing wrong at all grrrrr
  18. Ok im using pahination for one of the sections of my site and ive got it working 90% properly but the probem i have is it is creating creating to many pages, im using the following code can anyone see why? <?php /* Place code to connect to your DB here. */ include('config.php'); // include your code to connect to DB. $post_id=$_GET['Post_id']; $tbl_name="User_commentsT"; //your table name // How many adjacent pages should be shown on each side? $adjacents = 3; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "view_topic.php?Post_id=$post_id"; //your file name (the name of this file) $limit = 10; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT Comment_username, Comment_comment, Comment_date FROM $tbl_name WHERE Post_id='$post_id' ORDER BY Post_id ASC LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage&page=$prev\">« Previous</a>"; else $pagination.= "<span class=\"disabled\">« Previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage&page=1\">1</a>"; $pagination.= "<a href=\"$targetpage&page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage&page=1\">1</a>"; $pagination.= "<a href=\"$targetpage&page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage&page=$next\">Next »</a>"; else $pagination.= "<span class=\"disabled\">Next »</span>"; $pagination.= "</div>\n"; } ?> <?php while($rows = mysql_fetch_array($result)) { ?> <table style="width: 350px" cellspacing="0" cellpadding="0" align="center"> <tr><td> <table class="replies_table"> <tr><td class="repliesh">Posted by <a class="replies1" href="profile.php?username=<? echo $rows['Comment_username']; ?>"><? echo $rows['Comment_username']; ?></a> posted on <? echo $rows['Comment_date']; ?></td></tr> <tr><td class="replies"><? echo $rows['Comment_comment']; ?></td></tr> </table> </td><td class="viewspace"></td></tr> </table> <br /> <?php } ?> <br /> <div id="pagination"> <?=$pagination?> </div>
×
×
  • 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.