Jump to content

PNewCode

Members
  • Posts

    331
  • Joined

  • Last visited

Everything posted by PNewCode

  1. I decided to learn a little bit about preg_replace in strings while I have a couple days of down time from activities away from the computer. I have a table that echo's the results from the mysql value in the column "comments" That works Now I added some code that I had to collect and change a LOT of times to make it work, that shows line breaks, and also converts links in the text to url's that open in a new window. Which is AWESOME! The problem is, I want to have it also work this wizard-like magic for mailto, www, and just something.com For example... What it works on now is any text that is a full written url such as https://www.google.com I also need this to work for, examples (not these specific urls, just whatever is in the text) www.google.com google.com person@gmail.com I came KIND of close, but the ones that were without the https:// in front, just ended up resulting in a link that took them to (for example) https://www.mysite.com/www.google.com So I scrapped all of that because it was making a mess. The code below is what I have that still works with the first part of this post that I have working for a full link I'm excited to see what I learn from this one ///// a bunch of connection to the database stuff here, removed for posting //// $comment = $row["comment"]; $comment = nl2br(preg_replace_callback('~(\bhttps?://\S+)(?:\s+\[([^]]+)\])?~i', function ($m) { $s='<a hr'.'ef="'.$m[1].'" target="_blank">'; $s .= isset($m[2])? $m[2]:$m[1]; return $s.'</a>';}, $comment)); //// echos out below //// <font face="Verdana, Arial, Helvetica, sans-serif" color="#ffffff"><b>'.$comment.'</b></font>
  2. @kicken Thank you! Great education again and now it all works smooth!
  3. @kicken Thank you much. I'm getting a new error now when I added that sayin which is wierd because I didn't get that before I added it, only the error that says I'm using a ' in the string. I added $ppname1 = $_POST['ppname']; $ppname = mysqli_real_escape_string($conn , $ppname1); And that second part, I'd like to circle back to that and get some more education on that
  4. Hello again everyone! Today I'm working with learning file uploads. I faces an issue when uploaded a song that has a special character, for example YA'LL I managed to take care of this for the text field by using $band21 = $_POST['band2']; $band2 = mysqli_real_escape_string($conn , $band21); But I don't see where to add such a thing for the file name of the song upload. Any thoughts? NOTE: This works perfectly as long as there's no special characters in the file name Btw, I know this is a bit messy and amatuer, please keep in mind that I'm still learning <?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); CONNECTION STUFF HERE (removed for posting) // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $id=$_SESSION['id']; $sql = "SELECT * FROM users WHERE id=$id"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $band21 = $_POST['band2']; $band2 = mysqli_real_escape_string($conn , $band21); } } else { echo " "; } if (isset($_POST["submit"])) { $allowed_audio = array('mp3','wav'); $audio_ext = $_FILES["file2"]["name"]; $ext2 = pathinfo($audio_ext, PATHINFO_EXTENSION); if (!in_array($ext2, $allowed_audio)) { if (!in_array($ext2, $allowed_audio)) { echo 'Only Mp3 or WAV Files are Allowed to be Uploaded'; } die(); } #file name with a random number so that similar dont get replaced $ppname = rand(1000,10000)."-".$_FILES["file2"]["name"]; #temporary file name to store file $ttname = $_FILES["file2"]["tmp_name"]; #upload directory path $uploads_dir = 'member-audio'; #TO move the uploaded file to specific location move_uploaded_file($ttname, $uploads_dir.'/'.$ppname); $sql = "UPDATE users SET band2 = '".$band2."', audio1 = '".$ppname."' WHERE id = $id"; if(mysqli_query($conn,$sql)){ echo " "; } else{ echo "Error"; } } ?>
  5. EUREKA!!! Just to share, here's the winning solution. I chaged it to <a href="my-profile.php?id='.$myid.'">Your Profile</a> and added $myid = $row["id"]; To the while($row = $result->fetch_assoc()) { Okay so I'm learning so much and I'm really rather excited. Especially when things WORK! lol
  6. I decided to go a different route because to be honest, with the rest of the pages design in html, the drop down menu just looked ugly lol. So I just made it an auto filled form with the id passed to it. HOWEVER, I have a new problem with this. The page also needs to grab the id of the user that is logged in, to ALSO send in part of the form. There is a "vew profile" link like in my previous post. But this one serves as a purpose for the user to view their own profile to see if they want to make any changes. In the top menu, I use once again <a href="my-profile.php?id='.$row['id'].'">Your Profile</a> But the results are my-profile.php?id= What was built on the previous post works because it's sending the id of someone else that is in a table that has many users. This doesn't because I don't seem to understand where to grab the id of the user logged in, instead of the id of someone else. Any thoughts?
  7. Hello. First... WOW I learn so much on here. Today I'm facing a new task I am bringing upon myself to take something I already have, and make it more specific. I have a drop down menu that selects a user name, from a list of users in the database. This works great. However, now that the list is getting longer, I am attempting to have this populate with only one specific user instead of all of them. This is the scenerio I want to achieve I am at the website, and I want to go to "bob"s profile page. When I get there, I see I can send him a gift (or a message). So I click on that button but it sends me to a page where I have to scroll through over 400 names to get to it. So now I am annoyed and leave the website. I wish the developer (hehe) just made it so his name was there. Bob's id in the database is 215 What I have now works great to select a person and move on to the next page and send them something based on the name because it also gets their id. So how can I do this to capture ONLY the id of the page I'm visiting, and have that as the only option in the list? (I can't just have only 215 and bob in the list because this will depend on which page is being visited) Note: Considering that everything works solid with the rest of the page with a full drop down list, and that is the part I want to edit, I am assuming that is all I should show on here to reduce clutter. If I should show more than I apologize and I am willing to post whatever else is needed to be seen <select name="gname" style="font-size:18px;"> <option>Choose A Member</option> <?php $sqli = "SELECT * FROM users ORDER BY fname ASC"; $result = mysqli_query($con, $sqli); while ($row = mysqli_fetch_array($result)) { # code... echo '<option value="'.$row['id'].'">'.$row['fname'].'</option>'; } ?> </select>
  8. @gizmola Thank you very much for the insight and education. I much appreciate it
  9. ARGH!!! Update! I feel so silly now... it was in the WHERE statement. I typed it right in the description but I wasn't typing it right in the actual script. I was putting the "?" in both ends of it. Problem is solved with $sql = "SELECT * FROM users WHERE id = '$id'"; Sorry if I wasted anyones time. Problem solved.
  10. Hello wonderful people! This one has me about pulling my hair out. All my google research and php help topics I can find, tell me that there is nothing wrong with what I have. Though I fully accept that I am clearly doing something wrong, as this is not working. Below is my code (simplified). I didn't include the connection info for obvious reasons. And I didn't include all the pages scripting that just shows pictures and stuff that aren't related to this (just images that are embedded and what-not) The PROBLEM is that when I go to the page (example https://www.website.com/profile.php?id=65) it brings up the profile for the id 218. In fact, I can replace the "65" with ANY number, and it will still bring up the database info for ID 218 Any thoughts on this? Note: The only parts I'm not including in this entire pages script is just the embedded pictures and still stuff that I typed on the page to read, which has no functions at all Note 2: If I change the SELECT line to $sql = "SELECT * FROM users WHERE id = '$user_id' "; OR $sql = "SELECT * FROM users WHERE id = '$id' "; Then I just get "0 Results" writen on the page Note 3: Keep in mind that ALL of the data shows on the page. The problem is that it is getting id 218 instead of what I put in the url. <?php session_start(); $hostname="localhost"; $username="Removed for posting"; $password="Removed for posting"; $dbname="Removed for posting"; $conn = mysqli_connect($hostname, $username, $password, $dbname); if(!$conn){ echo "Database connection error".mysqli_connect_error(); } $id=$_GET['id']; $sql = "SELECT * FROM users"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $user_token = $row["token"]; $fname = $row["fname"]; $email = $row["email"]; $unique_id = $row["unique_id"]; $facebook = $row["facebook"]; $instagram = $row["instagram"]; $twitter = $row["twitter"]; $youtube = $row["youtube"]; $tiktok = $row["tiktok"]; $osite = $row["osite"]; $favmovie = $row["favmovie"]; $favactors = $row["favactors"]; $favbands = $row["favbands"]; $favseason = $row["favseason"]; $birthday = $row["birthday"]; $locationn = $row["locationn"]; $sign = $row["sign"]; $imageURL = '/chat-v3/public/storage/images/'.$row["img"]; $bio = $row["bio"]; } } else { echo "0 results"; die(); } ?> ////// A bunch of pictures and stuff here within html that show up just fine //// <font face="Verdana, Arial, Helvetica, sans-serif"><b>User Info</b></font> <font face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $fname; ?></b></font> // The line above repeats to show the rest of the values in the database
  11. @ginerjm and @jodunno thank you both. I haven't got to do any more with this task yet because I had to go spend some quality time with the doctor for a day but I will return to it soon And yes I look forward to learning more CSS, thank you for that example. I'll use that to mold more like it and learn from it.
  12. Hello everyone My next learning adventure is almost complete, except for a pesky issue with refresh. So, the page refresh is necessary because it displays data from my database in real time Note: I know that ajax is better for this however that method still used a fresh, or at least the way I could make it work did. So since this is easier for me to learn from now (baby steps for my mind) I'm going with a script to refresh the page The problem... the page that I have that is being refreshed is in an iframe (because it has to be within a page with other link options to it, bla bla bla) and in that iframe, has a page that has a popup modal (which is important because the main page with content will still have to be behind it) If the button is clicked to bring up that popup, then it opens for 1 second (the time of the refresh) and then disappears I understand why this is happening. So what I want to know is, is there a script or something that can pause the refresh while the popup modal is open, OR have the modal open on TOP of the iframe, and still keep the database info that is within the page, inside that iframe? Note: The modal works perfect on the page when viewing Outside of the iframe, but that is because there is no refresh on it by itself. Only the iframe is being refreshed I'm guessing the option to pause the refresh might be best. Here is the refresh that is in my main page <script type="text/javascript"> setInterval(function(){ $('#test').load('batch.php'); },1000); </script> And here is the modal inside "batch.php" // one or more of these might be for something else on the page. I lost track to be honest which one is for the modal <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script> function show_modal(e) { console.log (e.href); $("#iframe_modal").attr("src", e.href); $('#myModal').modal('show'); return false; } </script> // below is what is inside the modal which is a form to send info to the database <table width="40%" border="0" align="center"> <tr align="center" valign="middle"> <td> <div class="container"> <br> <a href="post-req.php" class="btn btn-primary" onclick="return show_modal(this);">Comment</a> <br> <br> </div> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Comment This</h4> </div> <div class="modal-body"> <iframe id="iframe_modal" src="" style="width: 100%; height: 40%;"></iframe> </div> <div class="modal-footer"> <button type="button" class="btn2 btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> </td> </tr> </table>
  13. @Barand and @ginerjm Thank you. This cleared up what I was stuck on. Awesome sauce is what you all are!
  14. Hello everyone! First, I must say that what I've been able to accomplish in the last few months from learning on here and research has given me a LOT of fun, which is what I need with my old bored self haha. So thank you all! For my next learning experience, I am attempting to display 2 different "things" from 2 different databases. One is a text and one is an image. I should let you know, that this is not an actual project. I'm doing this just for learning because I thought "hmmm, what if I did this..." So no luck. Below is what I tried. Any thoughts? (and before anyone asks, I did it this way because this was my best attempt. I am still figuring out the ways of the php magic ) <?php // Database 1 $hostname = "localhost"; $username = "stuff"; $password = "stuff"; $dbname = "stuff"; // Database 2 $hostnameB = "localhost"; $usernameB = "stuff"; $passwordB = "stuff"; $dbnameB = "stuff"; // Both databases have the same table name $conn = mysqli_connect($hostname, $username, $password, $dbname); if(!$conn){ echo "Database connection error".mysqli_connect_error(); } $connB = mysqli_connect($hostnameB, $usernameB, $passwordB, $dbnameB); if(!$connB){ echo "Database connection error".mysqli_connect_error(); } $sql = "SELECT * FROM tablename"; $sqlB = "SELECT * FROM tablename"; $result = $conn->query($sql); $resultB = $connB->query($sqlB); if ($result->num_rows > 0){ // output data of each row while($row = $result->fetch_assoc()) { $comment = $row["comment"]; } } if ($resultB->num_rows > 0){ // output data of each row while($row = $resultB->fetch_assoc()) { $imglink = "img/".$row['img']; echo' <table width="10%" border="0" cellspacing="0" cellpadding="10" align="center"> <tr align="center"> <td valign="middle"><img src="'.$imglink.'" width="50" height="50" /></td> <td valign="middle"><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCFF"><b>'.$row["comment"].'</b></font></td> </tr> </table> '; } } else { echo "0 results"; } ?>
  15. Thank you very much I appreciate that
  16. @kicken I added the exit; because I know you are all much wiser than me for this. But I also wanted to share with you, that I just added all this to work as an admin page on my other site and it works the same. Even without the exit at the end, it still does as it's supposed to. If you go directly to the url, it just spits them back to the other page if they don't have the "yes" for that value in the database column. I made a test account that doesn't have that credential and one with it. And it does as it should. Without that credential that is auto detected, they can't see the page and are redirect to a "nono.php" page. However, I put the exit back on anyways just to stay with what I'm learning here, but I see no difference in the function when using the page. Just wanted to share that with you
  17. @kicken You're right I should have for best practice. @jodunno has been telling me that too and I forgot. For some reason it works even without that though. If they aren't set to have that permission in the database then they can't see the page. But still, I am going to add that after headers for best practice. Thank you @jodunno just for some explanation, the database is included because no visitor is allowed to see the website at all without logging in. So it checks that first. The only other redirect that is happening is if they try to access that page and don't have the permission for that extra page in the database It's working perfectly now. I'm even adding this as an admin access for one of my other sites that gets used more. I learned a lot on this thread. Its awesome!
  18. AND IT'S DONE! I want to thank everyone that gave so much awesome education and help on here. Between that and an unreal amount of research, I present to you the working solution. I hope this helps anyone else that might be at my level (inexperienced and new) I put this at the top of the page and TADA it works! First it checks if the person is logged in. If not then they are sent to the login page. Then when they return to this page, it checks if "yes" is in the "salecheck" column for their id If it is, then they see the rest of the page If it is not, then they get sent to a "nono.php" page that tells them they don't have access and the option to purchase the access Once they purchase it, then "yes" is entered in the database for their id, and they can see the contents of that page I COULD NOT HAVE DONE THIS WITHOUT YOU ALL! THANK YOU! (and now I need a nap) THANK YOU ALL AGAIN! I APPRECIATE YOU ALL VERY MUCH!!! <?php session_start(); include_once "configure.php"; if (!isset($_SESSION['id'])){ header("location: login.php"); }else{ $hostname = "localhost"; $username = "Removed for posting"; $password = "Removed for posting"; $dbname = "Removed for posting"; $conn = mysqli_connect($hostname, $username, $password, $dbname); if(!$conn){ echo "Database connection error".mysqli_connect_error(); } $user_id = $_SESSION['id']; $sql = "SELECT * FROM users WHERE id = '$user_id'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $modcheck = $row["salecheck"]; } } else { echo "0 results"; die(); } if($salecheck == "yes"){ }else{ header("location: nono.php"); } } ?> ////// here is the gobblty gook html that will show the extra sales perks on the same page as the scripting above //////
  19. @gizmola I just noticed a row already there called "is_admin" with what looks like what you were talking about with the tinyint thing. Maybe it would be easier to just use that since I don't have an admin section?
  20. This is basically what I'm creating. Right now it has members, and pages for them to view once they are logged in. What I am trying to add is a store that those same members can view. But if they buy the extra sales perk, they get access to see the special sales page
  21. @gizmola I deeply apologize for how I must be appearing to come accross. Trust me I definitely see everyones skill to being far beyond me and I am extremely appreciative for and all advice. I promise my intent is not to push back. Whenever I say I can't redo it all, it's because with my lack of skill I could potentially mess up a lot of other pages that I wont know how to fix (which also use the database to echo certain things, call on other things, etc). So it's really just a literal fear that if I mess with it, I'll do damage that I wont know how to undo or even have an idea on how to fix. I promise that is the only reason I hesitate or say "I can't" with things. I DO feel like you are correct in what you're saying and that it would be better for me to follow it all. I just literally can't afford to have the website crash or malfunction if I mess with the database to alter other tables and stuff. Like I said, it's just fear and lack of experience. I promise. I meant no disrespect. That being said, with this lack of experience, I'm just staring at the page like a deer in headlights right now because I'm not exactly sure what I should be showing anymore haha. I thought showing a working page, then describing what I want to do would do the trick, but I am mistaken. So another reason I don't want to have a default value is because the login is done through laravel. I have absolutely zero clue how to add a default value to new members that sign up. I looked through all the folders and I can't make any sense of any of it. I didn't create it. The developer I had to fire did. SO, thats why I am stuck making columns in tables with empty default values, and updating them as I go. I hope to one day understand how to do a better way but for now I don't. Perhaps the next idea I have I can do some junk files on the side to learn with but this one I'm running out of time on. So, That might explain a little of why I'm so BLAH to doing the suggestions, and I apologize for that. I would be happy to tell you and show you all that you need. For now, I'll post something below, and please let me know what else you would like to see, and know that while I'm getting old, I'm just a kid with this stuff haha. Here is the Database "set_three" Here is the table "users" .... Note that "modcheck" is now called "salecheck". This is a screen shot from this morning before I changed the name Also, a lot of these tables aren't being used for this. Email and all that stuff is for a different website structure that isn't relevant to my current issue or even the main website. But a different project completely I did not build this database either Here is a screen shot of the rows that are being used for this in the table called "users" that is most relevant to what I am trying to do in this thread
  22. Sorry everyone. I'm sure you're ready to give me the "look" at this point haha. So just to give a little background that you don't see in this thread... There is a login page. People come to the site, they login, and then they can see the main page. It's working great and keeps the session for a lot of things to echo for their own things they can share on a chat page too. It shows their name when they post and all is wonderful with that (I'll post that below, the page after they login for the main page) The database is full of lots and lots of things for pictures and chat posts and lots of stuff. So showing the whole database or changing it at this point would be altering over a year of work (I only took over the last few months and started learning that early too... previous developer had to be fired and I can't afford another one so I started learning it) and possibly having to spend that much time readjusting all the pages that echo different things from it. So, thats why I was trying to center it down to just this one new thing I'm adding. So the below works to show the page after they login (once they login, they are auto sent to this one) What I'm attempting to do, is create another one just like it that only people that have "yes" in their column named "salecheck" I'm SO greatful for all the help. The people here are amazing!!!!!!! Unfortunately I'm stuck at just trying to have to make this work without changing the database structure. If it's not possible it's okay. If thats the case, maybe I should just create a new website for those users however I was hoping to keep this all in one. The below is working for what it is. I didn't add any of the store yet because I wanted to have the 2 levels of it working on the side before I made it public because I have 20 different businesses ready to let me list them for a commission //////// WHEN THE USER ENTERS THE LOGIN CREDENTIALS ON THE WEBSITE, THEY ARE SENT TO THIS PAGE //////// <?php session_start(); include_once "config.php"; if(!isset($_SESSION['id'])){ header("location: login.php"); } ?> <script> document.addEventListener('contextmenu', event => event.preventDefault()); </script> <style> .ssm_opcion img { max-width: 100%; height: auto; } </style> <style> * { box-sizing: border-box; } .fab-wrapper { position: fixed; bottom: 3rem; right: 3rem; } .fab-checkbox { display: none; } .fab { position: absolute; bottom: -1rem; right: -1rem; width: 4rem; height: 4rem; background: blue; border-radius: 50%; background: #126ee2; box-shadow: 0px 5px 20px #81a4f1; transition: all 0.3s ease; z-index: 1; border-bottom-right-radius: 6px; border: 1px solid #0c50a7; } .fab:before { content: ""; position: absolute; width: 100%; height: 100%; left: 0; top: 0; border-radius: 50%; background-color: rgba(255, 255, 255, 0.1); } .fab-checkbox:checked ~ .fab:before { width: 90%; height: 90%; left: 5%; top: 5%; background-color: rgba(255, 255, 255, 0.2); } .fab:hover { background: #2c87e8; box-shadow: 0px 5px 20px 5px #81a4f1; } .fab-dots { position: absolute; height: 8px; width: 8px; background-color: white; border-radius: 50%; top: 50%; transform: translateX(0%) translateY(-50%) rotate(0deg); opacity: 1; animation: blink 3s ease infinite; transition: all 0.3s ease; } .fab-dots-1 { width: 32px; border-radius: 10px; animation-delay: 0.4s; right: 50%; transform: translateX(50%) translateY(-50%) rotate(180deg); } .fab-dots-2 { left: 50%; transform: translateX(-50%) translateY(-50%) rotate(0deg); animation-delay: 0.4s; } .fab-dots-3 { width: 32px; border-radius: 10px; animation-delay: 0.4s; right: 50%; transform: translateX(50%) translateY(-50%) rotate(90deg); } .fab-checkbox:checked ~ .fab .fab-dots { height: 6px; } .fab .fab-dots-2 { transform: translateX(-50%) translateY(-50%) rotate(0deg); } .fab-checkbox:checked ~ .fab .fab-dots-1 { width: 32px; border-radius: 10px; left: 50%; transform: translateX(-50%) translateY(-50%) rotate(45deg); } .fab-checkbox:checked ~ .fab .fab-dots-3 { width: 32px; border-radius: 10px; right: 50%; transform: translateX(50%) translateY(-50%) rotate(-45deg); } @keyframes blink { 50% { opacity: 0.25; } } .fab-checkbox:checked ~ .fab .fab-dots { animation: none; } .fab-wheel { position: absolute; bottom: 0; right: 0; border: 1px solid #; width: 10rem; height: 10rem; transition: all 0.3s ease; transform-origin: bottom right; transform: scale(0); } .fab-checkbox:checked ~ .fab-wheel { transform: scale(1); } .fab-action { position: absolute; background: #0f1941; width: 3rem; height: 3rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: White; box-shadow: 0 0.1rem 1rem rgba(24, 66, 154, 0.82); transition: all 1s ease; opacity: 0; } .fab-checkbox:checked ~ .fab-wheel .fab-action { opacity: 1; } .fab-action:hover { background-color: #f16100; } .fab-wheel .fab-action-1 { right: -1rem; top: 0; } .fab-wheel .fab-action-2 { right: 3.4rem; top: 0.5rem; } .fab-wheel .fab-action-3 { left: 0.5rem; bottom: 3.4rem; } .fab-wheel .fab-action-4 { left: 0; bottom: -1rem; } </style> <div class="fab-wrapper"> <input id="fabCheckbox" type="checkbox" class="fab-checkbox" /> <label class="fab" for="fabCheckbox"> <span class="fab-dots fab-dots-1"></span> <span class="fab-dots fab-dots-2"></span> <span class="fab-dots fab-dots-3"></span> </label> <div class="fab-wheel"> <a href="https://www.pnewcode.info/chat-v3/logout" target="_self" class="fab-action fab-action-1"> <img src="assetimgs/menuicons/losm.png" width="37" height="31"> </a> <a href="help.php" target="_self" class="fab-action fab-action-2"> <img src="assetimgs/menuicons/helpsm.png" width="37" height="31"> </a> <a href="account2.php" target="_self" class="fab-action fab-action-3"> <img src="assetimgs/menuicons/accountsm.png" width="37" height="31"> </a> <a href="home.php" target="_self" class="fab-action fab-action-4"> <img src="assetimgs/menuicons/homesm.png" width="37" height="31"> </a> </div> </div> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="center" valign="top"> <td height="738"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="center" valign="top"> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"> <div class="ssm_opcion"><a href="twitchstuff.php"><img src="homeimgs/new/1.jpg" border="0"></a></div> </td> <td align="center" valign="top"> <div class="ssm_opcion"><a href="music.php"><img src="homeimgs/new/2.jpg" border="0"></a></div> </td> <td align="center" valign="top"> <div class="ssm_opcion"><a href="games.php"><img src="homeimgs/new/3.jpg" border="0"></a></div> </td> </tr> </table> </td> </tr> <tr align="center" valign="top"> <td height="271"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"> <div class="ssm_opcion"><a href="group-chat.php"><img src="homeimgs/new/4.jpg" border="0"></a></div> </td> <td align="center" valign="top"> <div class="ssm_opcion"><a href="help.php"><img src="homeimgs/new/5.jpg" border="0"></a></div> </td> <td align="center" valign="top"> <div class="ssm_opcion"><a href="basement.php"><img src="homeimgs/new/6-3.jpg" border="0"></a></div> </td> </tr> <tr> <td align="center" valign="top" colspan="3"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="center" valign="top"> <td colspan="3"> <div class="ssm_opcion"><img src="homeimgs/bottom.jpg" width="1920" height="278"></div> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr align="center" valign="top"> <td> </td> </tr> </table> </td> </tr> </table>
  23. @jodunno I just used your code and I'm still getting the same results. HOWEVER something you just said made me wonder... Does there have to be a statement somewhere that specifically says to make the 'salecheck' column a session? The last post I showed has all the pages and all of the scripting that exists as of now Edit: I have no doubt that gizmola has a better method, but I just don't know how to go about doing all that right now. I'll have to make a point to learn that. Right now I only know how to insert the word "yes" in that column for that user id Edit 2: I should have mentioned too, while my site isn't huge yet, with only 80 members, I don't want to have to enter a "no" in each persons "salecheck" column, and then have to do that for each person every time someone signs up. So it's just easier to leave it blank and enter a "yes" when someone gets that extra perk
  24. Yes it is coming from my database. I'm sorry I should have went more in depth. Here is the entire structure that I have now. It seems that all of these attempts are only checking if the user is logged in and not paying attention to if the column saying "yes" or if it's empty. I didn't choose the add "no" in because the column will either have "yes" in it, or it's empty. If it's yes, then they see the html page that I'm making that is under the php code. Here is a code that is on a different page that checks only if they are logged in, and if they are, then they can see the page <?php session_start(); include_once "config.php"; if(!isset($_SESSION['id'])){ header("location: login.php"); } ?> The original switch page I put in my first original post I scrapped completely because after reading the replies, I decided it wasn't the right way to go. Here is the complete everything I have Here is my config.php <?php $hostname = "localhost"; $username = "deleted for posting"; $password = "deleted for posting"; $dbname = "deleted for posting"; $conn = mysqli_connect($hostname, $username, $password, $dbname); if(!$conn){ echo "Database connection error".mysqli_connect_error(); } ?> And then on the extrasale.php page (including the most recent attempt) <?php session_start(); include_once "config.php"; if (!isset($_SESSION['salecheck']) && ($_SESSION['salecheck'] == "yes")) { header('Location: nosale.php'); exit; } ?> ///////// Below is what they will see if they have "yes" in the 'salecheck' column ////// <html> <title> Something </title> The sales stuff will be seen here for those that are logged in and have yes in the value </html> And here is the mysql database And here is the nosale.php <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> //// This will be the page that will be directed to, if "Yes" isn't in the 'salecheck' column //// </body> </html>
  25. @jodunno sorry I forgot to mention. Same thing. Regardless of what is in the column, it shows the content of the page. If it helps at all.... the column 'salecheck' is VARCHAR (255) not null
×
×
  • 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.