Jump to content

freemancomputer

Members
  • Posts

    66
  • Joined

  • Last visited

Everything posted by freemancomputer

  1. I have a form on my web site for rating movies that uses radios. I would like to move away from that to a line of images where a user can click on there rating depending on which number down the line they click. I'm not sure if this should be done making the image into a submit or just a link. Here is what I have right now with the radios that works, this does feed into jquery so the user dosent have to leave the page. Any pointers and opinions are welcome. Thank you. <form id="add-rating"> <input type="radio" name="MOVIE_RATING" value="1" > 1 <input type="radio" name="MOVIE_RATING" value="2" > 2 <input type="radio" name="MOVIE_RATING" value="3" checked="yes"> 3 <input type="radio" name="MOVIE_RATING" value="4" > 4 <input type="radio" name="MOVIE_RATING" value="5" > 5 <br> <input type="hidden" name="MOVIE_ID" value="<?php echo $id; ?>"> <input type="hidden" name="MOVIE_TITLE" value="<?php echo stripslashes($title); ?>"> <input type="hidden" name="USER_ID" value="<?php echo $loggedinusername; ?>"> <input type="submit" value="Rate"> </form>
  2. turns out i forgot a ; after $find_num_votes= mysql_result($find_result, $i, "num_votes");
  3. even with the , in there it still dose not work.
  4. I am having a problem with updating 2 table entry's at time. If i take out the num_votes it will add the rating. I'm not sure if I'm not doing the math correctly or if its not being entered correctly, then again I could be way off. @mysql_select_db($database) or die( "Unable to select database"); $title = mysql_real_escape_string(urldecode($_POST["title"])); $rating= mysql_real_escape_string($_POST['rating']); $find_query="SELECT * FROM movie WHERE title='$title'"; $find_result=mysql_query($find_query); $find_rating= mysql_result($find_result, $i, "rating"); $find_num_votes= mysql_result($find_result, $i, "num_votes") $sum_rating = $find_rating + $rating; $sum_num_votes = $find_num_votes + 1; include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $title= mysql_real_escape_string($_POST['title']); $error = ''; $sql_rating = "UPDATE movie SET rating='$sum_rating' num_votes='$sum_num_votes' WHERE title='$title'"; mysql_query($sql_rating) or die (mysql_error());
  5. I am working on a website that lists movies. On this I have user accounts. What I am trying to do is make it so a user can check off and rate the movies they have watched. Once the user checks a movie off I will have a list they can look at in there profile. My first thought was to add a column to the user table that will list the ID number of the movies from the move table along with there rating. I am not sure how to do something like this or if this is the best way. This is my first run at trying to get 2 different tables working together so Im not sure of the best starting point.
  6. Maybe im not explaining things correctly. Take a look at my site and go to a movie. The reason why I moved it from one column to 7 is because there are several people that can add movies to the list and by doing it this why I found it makes it easier to make the output the same. drinktothecredits.com
  7. The point of moving them to 7 diffrent columns is because I will not be the only person adding things to the database. Doing it way makes it easier to have things look the same through out the web site. Not all rows will have a full 7 actors, but they will have at least one.
  8. I just changed around my database and as such I need to update my search form. The way it used to work was a user could use the search bar to look for actors. In changing my database there in no longer a actor column, there are how ever actor_1, actor_2 ... until actor_7. What I am trying to do it set it up so my form looks the same but the back end will look in all the actor columns for the name. So when a user selects actor from the drop down menu it will look in all 7 actor columns. Here is what i had before that worked. for the search bar <form action="/search.php" method="post"> <span class="rulesub">Search: </span><input type="text" name="search"> <select size="1" name="dropdown"> <option value="" selected>Search by...</option> <option value="title">Title</option> <option value="actors">Actors</option> <option value="difficulty">Difficulty 1-5</option> </select> <input type="Submit" value="Search" name="Submit"> </form> for the search page $connect = mysql_connect('localhost', $username, $password) or die ("Unable to connect to host"); mysql_select_db($database) or die ("Unable to connect to database"); $search = empty($_POST['search'])? die ("Please enter search criteria.") : mysql_escape_string($_POST['search']); $dropdown = empty($_POST['dropdown'])? die ("Please select from search criteria.") : mysql_escape_string($_POST['dropdown']); $query = mysql_query("SELECT * FROM movie WHERE $dropdown Like '%$search%'") or die (mysql_error()); if(mysql_num_rows($query) == 0) { printf("Could not find $search while looking in $dropdown, please try again."); //exit; } else{ $num=mysql_numrows($query); mysql_close($connect); ?> Output thanks
  9. Thanks that looks to have fixed it. Is it just doing a 2nd look at the type part of it? Not sure if I understand why that would need to be in both spots.
  10. Ok so I thought my pagination was working just fine until I took a closer look at the database. Turns out its not showing everything that it should. With the way I Have it now it only shows 2 pages of 40 items, there is closer to 60 that should be shown. I moved it to show only 15 per page to see if it was an error with the page reading but it showed only 3 pages for a total of 45 items. Here is what i have right now with is showing the 20 per page. Any ideas? <?php session_start(); $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Drink To The Credits</title> <link href="mainstyle.css" rel="stylesheet" type="text/css" /> </head> <body class="background"> <div id="header"> <?php include_once"header.php" ?></div> <div id="content"> <?php include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or trigger_error("SQL", E_USER_ERROR); $sql = "SELECT COUNT(*) FROM movies WHERE type LIKE 'movie'"; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; $rowsperpage = 20; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT title FROM movies ORDER BY title LIMIT $offset, $rowsperpage" ; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); ?> <table width="70%" align="left"> <tr> <td align="center" class="rulesub">Movies</td> </tr> <?php while ($list = mysql_fetch_assoc($result)) { ?> <tr> <td> <a class="nav" href=/rules.php?title=<?php echo urlencode($list['title']); ?>><?php echo $list['title']; ?></a> <br /> <?php } $range = 3; if ($currentpage > 1) { echo " <a class='nav' href='<?php movies.php?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a class='nav' href='movies.php?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a class='nav' href='movies.php?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a class='nav' href='movies.php?currentpage=$nextpage'>></a> "; echo " <a class='nav' href='movies.php?currentpage=$totalpages'>>></a> "; } // built with a tutorial from php freaks ?> </table> </div> <div id="sidecontent"><?php include_once"newmovies.php" ?></div> <div id="footer"> <?php include_once"footer.php" ?></div> </body> </html> I am also looking to have the out put broken into 2 columns so there would be 40 per page. Sorry if the post is rambling, lacking on the sleep so I shall be heading to bed.
  11. Thank you for the info, I will look into it. Now to get 2 columns working
  12. This is the error i get Here is what i had for the next page link which is line 76 echo " <a class="nav" href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; What is the problem with using php_self? And what should I be useing?
  13. Using the tutorial from php freaks i was able to get pagination working on my site. How ever there are a few changes id like to make. I would like to have it listed in 2 columns. The other problem that I'm having is when i attempt to add class="nav" to the next page link i get an error. Can a class be used in a php echo? Here's what I have. <?php session_start(); $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Drink To The Credits</title> <link href="mainstyle.css" rel="stylesheet" type="text/css" /> </head> <body class="background"> <div id="header"> <?php include_once"header.php" ?></div> <div id="content"> <?php include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or trigger_error("SQL", E_USER_ERROR); $sql = "SELECT COUNT(*) FROM movies WHERE type LIKE 'movie'"; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; $rowsperpage = 15; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT title FROM movies ORDER BY title LIMIT $offset, $rowsperpage" ; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); while ($list = mysql_fetch_assoc($result)) { ?> <tr> <td> <a class="nav" href=/rules.php?title=<?php echo urlencode($list['title']); ?>><?php echo $list['title']; ?></a> <br /> <?php } $range = 3; if ($currentpage > 1) { echo " <a href='<?php {$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // built with a tutorial from php freaks ?> </div> <div id="sidecontent"><?php include_once"newmovies.php" ?></div> <div id="footer"> <?php include_once"footer.php" ?></div> </body> </html> Thank you in advance
  14. Awesome thanks, I have don't remember putting those in there. They were not in my back up, must of been one of those late night "this will work" moments. I will be looking at the password suggestion. Thanks again.
  15. I am having a bit of a problem with my log on scrip sense i moved to a different host. Users are able to log in but most of there info isn't passed. The way I have it set up right now if your logged in the home page says "You are signed in as: 'user'". But all its showing is "You are signed in as:". The only thing I can tell that is getting passed is there user rank. There are other areas where the email is not showing up ether. Here is what i have. This is on every page unless your logged in <form name="form1" method="post" action="checklogin.php"> <span class="rulesub">Username:</span><input name="myusername" type="text" id="myusername" /> <span class="rulesub">Password:</span><input name="mypassword" type="password" id="mypassword" /> <input type="submit" name="Submit" value="Login" /> <div align="center">Not a member? <a class="nav" href="new_user.php">Sign up.</a> </form> This is my check log in script <?php ob_start(); include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $encrypted_password=md5($mypassword); $sql="SELECT * FROM user WHERE username='$myusername' and password='$encrypted_password' and active=1"; $result=mysql_query($sql); $count=mysql_num_rows($result); $row = mysql_fetch_assoc($result); $rank = $row['rank']; $loggedinusername = $row['username']; $loggedinuseremail = $row['email']; if($count==1){ session_start(); $_SESSION['login'] = "1"; $_SESSION['rank'] = $rank; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail; header ("Location:index.php"); } else { $errorMessage = "Invalid Login"; session_start(); $_SESSION['login'] = ''; header ("Location:login.php"); } ?> This is what i have for the session part on every page <?php session_start(); $_SESSION['login']; $_SESSION['rank']; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail; $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail']; ?> And this is what I am using to show the user name. <?php if($rank>=1){ ?> <p class="rulesub"> You are signed in as: <?php echo $loggedinusername; ?> <br /><a class="nav" href="logout.php" title="Log out" target="_self">Log Out</a> </p> <?php }?> Thanks in advance
  16. I am trying to change my web site to user only to public view. I still need users to be able to log in so they can edit things. I did a quick fix to allow everyone to view things by removing the ! from the sessions. How ever with that when i try to log in it just loops to login.php. There are links on the page that only admins will be able to see. Here is my session with the removed !. <?php session_start(); if($_SESSION['login']){ $_SESSION['rank']; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail; header("location:login.php"); } $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail']; ?> How would i got about allowing eveyone to see this page but the log in still work? If you need anymore code let me know Thank you
  17. This is my log in scrip include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $encrypted_password=md5($mypassword); $sql="SELECT * FROM user WHERE username='$myusername' and password='$encrypted_password' and active=1"; $result=mysql_query($sql); $count=mysql_num_rows($result); $row = mysql_fetch_assoc($result); $rank = $row['rank']; $loggedinusername = $row['username']; $loggedinuseremail = $row['email']; if($count==1){ session_start(); $_SESSION['login'] = "1"; $_SESSION['rank'] = $rank; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail; header ("Location:index.php"); } else { $errorMessage = "Invalid Login"; session_start(); $_SESSION['login'] = ''; header ("Location:login.php"); } and this is my session session_start(); if(!$_SESSION['login']){ $_SESSION['rank']; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail; header("location:login.php"); } $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail'];
  18. This i what I have for my log out script <? session_start(); session_destroy(); header("location:login.php"); ?>
  19. I'm not really sure if this is a cookie problem but that's all I could think of. I have a web site that users have to log into. I have seen that when I log out of my account and log into my test account my main user name will still show on the welcome page unless I let the computer sit for a bit or if I clear recent history. This happens in all the main browsers. I have also started having a problem where if I update something in my database it shows up in MySQL right away but can take a while to show up on the web page unless i clear the history. Not sure what code to post to give you an idea so if you want to see something let me know and I will put it up. Thank you
  20. I am in the process of opening my web site to the general public. Right now you have to have a username and password to see anything on the site. What I am looking to do is make it so anyone can see most things on the site. There will still be user accounts for things like admins and submitting ideas. What i have now is some links that look at the user rank and only show up if you are higher then a rank. What I need to do is make it so you don't need to log in to see the site but you still need to log in to edit things. Here is my sessions scrip <?php session_start(); if(!$_SESSION['login']){ $_SESSION['rank']; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail; header("location:login.php"); } $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail']; ?> How do I edit this so you are free to move around the site even if your not logged in? Thanks
  21. Each page that would need the sessions? and as I have them now or as I had them before I moved them. And thank you
  22. I did not get the problem if I went right to the header. I had it in the header so I would flow easily through the whole site. I took the header and made it the index.php and renamed the old index to something else and made an include on the new index for the main page. This allows the log in for the main page now I have the problem of the header and session not flowing through the whole site.
  23. Thanks for all the help so far. I have moved the header include to line 1 and still get the error the only difference is the line number I then created a test page with just the header include and get the same errors.
  24. When I moved from hosting the site myself there were not errors and everything worked just fine. When I went to the site and wasn't logged it I would be redirected to the log in page. From there I could log in and move around the site with no problem. When I moved to a hosting site yesterday is when the problems came up. The only 2 things that have changed was going from php 5.3 to 5.2 and who I'm hosting it with. I had it configured to report the errors seance I put the page together because its a work in progress.
  25. Line 10 in index.php is the include for the header <div id="header"> <?php include_once"header.php" ?></div> lines 1-9 are where I have the title, css and what not everything above there is HTML The way it was set up on my old site was that if you were not logged in it would send you right to the log in page right now it pulls up the index page with the errors. Thanks again The jumping in and out of php and using the short tags are bad habits that I have picked up from teaching myself php and am working on fixing.
×
×
  • 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.