PNewCode
Members-
Posts
331 -
Joined
-
Last visited
Everything posted by PNewCode
-
@requinixNo errors are showing up. I almost suspect it could be something to do with the new PHP upgrade that my server forced on my hosting plan. I can't see a single thing different with what is on my site, and what I have on the computer that I haven't changed at all.
-
Hello. I have six files (I'll show the scripts below except for the delete.php because that doesn't matter in this). This was a project that I paid someone to do a year ago, so I can't tell you why "this or that" was put in any of the coding because I didn't create it. While I've learned a lot since then, I can't figure out why all of the sudden last week it stopped working. How it used to work... 1: A website user would fill out a form and click send 2: The information would go to the database and in the alert database 3: The view page to see the messages would give an alert sound and make the page flash a color when a new entry was added to the database Please don't ask why I want this. Thats not important. Also please don't ask why I'm doing this way instead of "that" way. Because I paid someone to make this, and this is what I got. I worked for a long time and suddenly stopped. I didn't make any changes. Any help on why this no longer works is greatly appreciated ❤️ What does work: The entry gets added to the database from the form, and is visible as needed. And delete function works as well. What doesn't work: The alert sound and making the page flash red. Form (msgform.php) <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <style type="text/css"> body {background:none transparent; } </style> <body bgcolor="#FFFFFF" marginwidth="0" marginheight="0" text="#000000" leftmargin="0" topmargin="0" link="#FF0000" vlink="#FF0000" alink="#FF0000"> <form action="insertmsg.php" method="post" autocomplete="off"> <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"> <b><font color="#FFFF00">Name</font></b> <input type="text" name="name" size="17" required /> <b><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"> <font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><font color="#FFFF00"><font face="Verdana, Arial, Helvetica, sans-serif" size="4"> <input type="hidden" name="reply" size="20" required value="https://www.peredy1.com/mods/msg/noall.php"/> </font></font></font></font></font></font> </font></font></font></font></font></font></font></font></font></b> <b><font color="#FFFF00"><br> Link</font></b> <font color="#FFFF00"> <input type="text" name="band" size="20" /> <br> <font face="Verdana, Arial, Helvetica, sans-serif" size="4"><b>Message</b></font></font><font size="3"><i><br> </i></font> <textarea name="extra" cols="34" rows="4" required></textarea> </font><font face="Verdana, Arial, Helvetica, sans-serif" size="4"><br> <input type="image" class="alertclick" src="redsend.jpg" name="image" /> <img src="cancel.jpg" border="0" onClick="window.history.go(-1)"></font> </p> </form> <div id="test"></div> <div id="test"></div> <script type="text/javascript"> $(".alertclick").click(function(){ $('#test').load('alert.php'); }) </script> Insert to DB (insertmsg.php) <?php $servername = "localhost"; $database = "removed for public view"; $username = "removed for public view"; $password = "removed for public view"; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "."; $name1 = $_POST['name']; $band1 = $_POST['band']; $song1 = $_POST['song']; $extra1 = $_POST['extra']; $reply1 = $_POST['reply']; $name = mysqli_real_escape_string($conn , $name1); $band = mysqli_real_escape_string($conn , $band1); $song = mysqli_real_escape_string($conn , $song1); $extra = mysqli_real_escape_string($conn , $extra1); $reply = mysqli_real_escape_string($conn , $reply1); $sql = "INSERT INTO nametable (name, band, song, extra, reply) VALUES ('$name', '$band', '$song', 'Message: $extra', '$reply')"; if (mysqli_query($conn, $sql)) { echo " "; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); ?> <style type="text/css"> body {background:none transparent; } </style> <meta http-equiv = "refresh" content = "2; url = msgform.php" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <body bgcolor="#FF6600" text="#000000" link="#FF0000" vlink="#FF0000" alink="#FF0000"> <div align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" height="84" colspan="7"> <div align="right"> <p><br> </p> </div> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFF00"><b>Completed</b></font><font color="#FFFFFF"><b></b></font><font face="Verdana, Arial, Helvetica, sans-serif"><br> <br> </font></div> </td> </tr> </table></div> Alert Generator (alert_generate.php) <?php $servername = "localhost"; $username = "removed for public view"; $password = "removed for public view"; $db="removed for public view"; $conn = mysqli_connect($servername, $username, $password,$db); // $sql = "INSERT INTO `number`( `number`) // VALUES ('$qty')"; $sql = "SELECT alert_status FROM alert"; $result = $conn->query($sql); $alertvar = 0; if ($result->num_rows) { // output data of each row while($row = $result->fetch_assoc()) { if($row["alert_status"] == 1){ echo '<div class="redalert3"></div>'; $alertvar = 1; }else{ } } } if($alertvar == 1){ echo '<script>var x = document.getElementById("myAudio3"); x.play(); </script>'; $qty=3; // $sql = "INSERT INTO `number`( `number`) // VALUES ('$qty')"; $sql = "UPDATE alert SET alert_status=$qty WHERE id=1"; if (mysqli_query($conn, $sql)) { echo json_encode(array("statusCode"=>200)); } else { echo json_encode(array("statusCode"=>201)); } mysqli_close($conn); } $conn->close(); ?> The Alert (alert.php) <?php $servername = "localhost"; $username = "removed for public view"; $password = "removed for public view"; $db="removed for public view"; $conn = mysqli_connect($servername, $username, $password,$db); $qty=1; // $sql = "INSERT INTO `number`( `number`) // VALUES ('$qty')"; $sql = "UPDATE alert SET alert_status=$qty WHERE id=1"; if (mysqli_query($conn, $sql)) { echo json_encode(array("statusCode"=>200)); } else { echo json_encode(array("statusCode"=>201)); } mysqli_close($conn); ?> View messages (view.php) <html> <head> <style> .redalert3:after { background-color: red; content: ""; height: 100%; width: 100%; position: absolute; top: 0; left:0; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <title>Peredy Host Tool</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="Author" content="Peredy Izhere" /> <meta name="copyright" content="© 2009-2021, All Rights Reserved" /> <meta name="revisit-after" content="7 days" /> <meta http-equiv="refresh" content="7" > <link rel="apple-touch-icon" sizes="57x57" href="/fi/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/fi/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/fi/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/fi/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/fi/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/fi/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/fi/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/fi/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/fi/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/fi/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/fi/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/fi/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/fi/favicon-16x16.png"> <link rel="manifest" href="/fi/manifest.json"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/fi/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff"> </head> <body text="#FFFFFF" link="#FF6600" vlink="#FF6600" alink="#FF6600"> <font face="Verdana, Arial, Helvetica, sans-serif" size="3"> <div class="alertadd"></div> <audio id="myAudio3"> <source src="alertsound3.mp3" type="audio/mpeg"> </audio> </font> <script> document.addEventListener('contextmenu', event => event.preventDefault()); </script> <style type="text/css"> body {background:none transparent; } </style> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> <td height="180"> <p> <font face="Verdana, Arial, Helvetica, sans-serif"> <?php $servername = "localhost"; $username = "removed for public view"; $password = "removed for public view"; $dbname = "removed for public view"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, name, band, song, extra, reply FROM nametable"; $result = $conn->query($sql); $resultt = mysqli_query($conn, "select COUNT(id) AS count FROM `nametable`"); if(!$result) { die('Error: ' . mysqli_error($link)); } else { $num_rows = mysqli_fetch_assoc($resultt); // echo it echo "<font color='yellow'>Total Messages</font>: <font color='red'><b>" . $num_rows['count']."</font></b></br>"; } if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { ; ?><br> <font color='orange'>Message From: </font></font><font color="aqua" face="Verdana, Arial, Helvetica, sans-serif"><?php echo htmlspecialchars($row["name"]); ?><br> <font color='lightblue'>Link From Viewer: </font><a target="_blank" href='<?php echo $row["band"] ; ?> ' ><?php echo htmlspecialchars($row["band"]); ?></a></font> <font color="aqua" face="Verdana, Arial, Helvetica, sans-serif"> <br> <font color='white'> <?php echo nl2br(htmlspecialchars($row["extra"]). "<br><br><a href='delete.php?id=".$row['id']."'>Delete</a> | <a href='".$row['reply']."'>Reply</a><br>___________<br>",60); } } else { echo "0 Messages"; } $conn->close(); ?> </font></font></p> <pre> </pre> <audio id="myAudio3"> <source src="alertsound3.mp3" type="audio/mp3"> </audio> <script type="text/javascript"> setInterval(function(){ $('.alertadd').load('alert_generate.php'); },300); </script> </td> </tr> </table> </body> </html>
-
The reason for having 2 pages is to view both databases. Yes they are on the same server. One page displays one database, the other page displays content on the other database. One is current, the other is a backup Thank you for the example of the script I'll work with that to see what I can do
-
One has entries deleted from it, the other does not and serves as a backup
-
Hello, I've searched around but I think I must not know how to phrase the question because I cannot find a solution. OBJECTIVE: I have a page where an image that acts like a button sends the information to another php page. And that page that gets the information is inserted to a database. I need to have this one button send it to TWO php pages, as each of them perform the same function, but different databases. Summary of what I am wanting to do: Make this one button post to 2 different php files. Here is my code that works perfectly for just one php file: echo " <form class='leftf' action='process2.php' method='post'><input type='hidden' name='actionType' value='order_change'><input type='hidden' name='update_id' value='$updateID'><input type='hidden' name='current_postion' value='$order_change'><input type='hidden' name='order_change' value='$order_change_up' required><button type='submit'><img src='up.jpg'></button></form>";
-
@Barand sorry I didn't see it. My apologies. Table Users has the id as unique_id Table Messages has the id as user_id Somehow one user has both of those. But I just needed to delete all from the table messages under user_id="user id here" and grab it from the unique_id from the other table. But I know it can't work anyways unless I change the name of the column in one of the tables, which would end up with over 60+ pages of editing so it's just going to be easier to make 2 different files that each have their own query and include each on one page. Thank you all for the time anyways
-
@ginerjm after looking into this, it appears what I want to do is impossible without having completely different php sections. So I am going to just make 2 smaller php files and link to each one instead of making a mess of one page lol Thanks for your time everyone
-
@ginerjm As to WHY it works, that I can't tell you. I had a page already made that works for one query and I just added the extra stuff to try for a different table in the same DB. The ID's can't be the same in both tables because one is for a user id, the second is for a message id. So the first one deletes the user from the DB, and the second one just clears all their messages. I cannot change the column names because it would break the whole build and I would rather make 2 delete pages than to rewrite 60+ other pages that are using the same databases. So this is why I'm trying to get both to work in the same page
-
@ginerjm I stated what is "The first link". It says it specifically in my second post on this. See this from that post... The first link does grab the id (from table "users") <a href='delete-user.php?id=".$row['unique_id']."'>Remove User</a> But the second one does not (from table "messages") <a href='delete-messages.php?id=".$row['user_id']."'>Clear User Chat</a> Now, the problem using the comas is that the first table users has multiple columns to choose from named unique_id, fname, lname and the second table messages only has one I am using, named user_id So if I just split them up in comas, then there is nothing to sort which results are from just the two tables. If I put it as you did with the u and m, then the links (see above) wont pull those id's from the tables. I'm not sure why you don't know why you don't know what I mean by first link when I said it directly above that line of code So the objective, is for the first link, it grabs the id from users and the second link, it grabs the id from messages NOTE: the first link works just fine by the way
-
@ginerjmhere is the break down. The two tables are "users" and "messages" The first link does grab the id (from table "users") <a href='delete-user.php?id=".$row['unique_id']."'>Remove User</a> But the second one does not (from table "messages") <a href='delete-messages.php?id=".$row['user_id']."'>Clear User Chat</a> So I'm guessing, like you said is in the $sql = "SELECT unique_id, fname, lname AND user_id FROM users, messages"; But I'm not sure how to change that to work for that second link <a href='delete-messages.php?id=".$row['user_id']."'>Clear User Chat</a>
-
Hello. A little guidance if you don't mind and with my great appreciation. The objective is to have to links, that use 2 different functions, selecting from 2 different tables. Each link goes to a different page. So far, this is able to grab the id for the first link but not the second. Any thoughts of what I need to do different? NOTE: To be specific, it's the line to delete messages that isn't grabbing the id <?php // database info here // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT unique_id, fname, lname AND user_id FROM users, messages"; $result = $conn->query($sql); $resultt = mysqli_query($conn, "select COUNT(unique_id) AS count FROM `users`"); if(!$result) { die('Error: ' . mysqli_error($link)); } else { $num_rows = mysqli_fetch_assoc($resultt); // echo it echo "<font color='yellow'>Total Users</font>: <font color='aqua'><b>" . $num_rows['count']."</font></b></br></br>"; } if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { ; ?> <font color='orange'>User Name: </font><font color='black'><?php echo htmlspecialchars($row["fname"]); ?> <?php echo htmlspecialchars($row["lname"]); ?> <br> <font color='orange'>ID: </font><font color='black'> <?php echo nl2br(htmlspecialchars($row["unique_id"]). " <a href='delete-user.php?id=".$row['unique_id']."'>Remove User</a> <a href='delete-messages.php?id=".$row['user_id']."'>Clear User Chat</a> ___________<br><br>",60); } } else { echo "0 Users"; } $conn->close(); ?> Any help is very much appreciated
-
@kickenThank you much for your time. I appreciate it. I tried that one too and I got a huge list of errors. I would post them but I can see from the previous answer that even being told what is wrong, I can't seem to figure out where or what to fix, or really... how to fix it. What is frustrating me the most is I can almost always see the codes and if I get help then it makes sense, then I learned from it, then I can build again from that. But this one... has me about ready to put my forehead in the monitor. I really do appreciate everyones help though. I just hate that this time I can't make heads or tales of it all
-
Yup... I give up haha. At least for today. I'm normally very good at "Ohhhh okay that makes sense" but this has my head feeling like spaghetti where the noodles have been boiled too long and then turned into mashed potatos, and then mixed with dog food and thrown at a wall haha.
-
@BarandThank you for that info. I moved the session to the bottom so it is after it but now I get Which is the second line in this
-
@mac_gyverI hope that I'm not a nuesence at this point. I tried like crazy to put in your example on the page that is being used itself. And I get the following errors. Any thoughts? And thank you again btw for all the guidance Here is what I have now in the top of the script down to where the page begins it's normal look You may notice some of the URL is different than my orginal post, this is because this index page is in the same folder now so I didn't need to put a full URL in <?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php // this sets the lifetime to zero and the rest of the values to null session_set_cookie_params(0); session_start(); // login check code if(!isset($_SESSION['unique_id'])) { // if not logged in, go elsewhere header("location: logintool.php"); die; } // at this point there's a logged in user, get the user's current status // note: use 'require' for things your code must have for it to work require "php/config.php"; $sql = "SELECT status from users WHERE unique_id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param('i', $_SESSION['unique_id']); $stmt->execute(); $stmt->bind_result($user_status); $stmt->fetch(); if($user_status === "Offline now") { // force a log-out // note: you should only unset() $_SESSION['unique_id'] since a session can contain other pieces of data session_unset(); session_destroy(); header("location: logintool.php"); die; } // at this point the user is logged in and can access the rest of the code on the protected page ?> <?php include_once "header.php"; ?>
-
@mac_gyverthank you very much for all your help. I'm going to use this and go at it till it works. I really appreciate your time. Thank you.
-
@mac_gyveryup I'm officially lost now. I was looking for something that would list all the data that I could do some sort of clear script or something. Are there people (maybe you?) on here that can be for hire to do things like this? Or is that not allowed to ask. I don't want to break any rules.
-
Hey @mac_gyverI did find this page called data.php do you think it answers where I need to look? EDIT: Actually this looks like the functioning for the chat messages only <?php while($row = mysqli_fetch_assoc($query)){ $sql2 = "SELECT * FROM messages WHERE (incoming_msg_id = {$row['unique_id']} OR outgoing_msg_id = {$row['unique_id']}) AND (outgoing_msg_id = {$outgoing_id} OR incoming_msg_id = {$outgoing_id}) ORDER BY msg_id DESC LIMIT 1"; $query2 = mysqli_query($conn, $sql2); $row2 = mysqli_fetch_assoc($query2); (mysqli_num_rows($query2) > 0) ? $result = $row2['msg'] : $result ="No message available"; (strlen($result) > 28) ? $msg = substr($result, 0, 28) . '...' : $msg = $result; if(isset($row2['outgoing_msg_id'])){ ($outgoing_id == $row2['outgoing_msg_id']) ? $you = "You: " : $you = ""; }else{ $you = ""; } ($row['status'] == "Offline now") ? $offline = "offline" : $offline = ""; ($outgoing_id == $row['unique_id']) ? $hid_me = "hide" : $hid_me = ""; $output .= '<a href="chat.php?user_id='. $row['unique_id'] .'"> <div class="content"> <img src="php/images/'. $row['img'] .'" alt=""> <div class="details"> <span>'. $row['fname']. " " . $row['lname'] .'</span> <p>'. $you . $msg .'</p> </div> </div> <div class="status-dot '. $offline .'"><i class="fas fa-circle"></i></div> </a>'; } ?>
-
@mac_gyverthank you for that. I'm clearly in way over my head. I truly thought it would be as easy as making one button that sends to multiple pages that I could just put in the id in but I can see that it's not. I just tried to put in the session_save_path() in the logout page and it came back as page isn't working haha. So yeah, sigh... this is way beyond my understanding. I spent all my money having this made but maybe I can save a couple more months and hire someone to fix all this for me
-
@ginerjmthe logout.php script is in my original post. Right under where I typed "And here is the logout page php"
-
@mac_gyverI'll have to go the first route. Maybe it's in one of the js files. I'm not sure. I wont need any functions like promoting, demoting, suspending, or banning a user because they can't even get in unless I register them manually (it's a private chat thing) so if I wanted them out I would just delete them from the database completely. I don't have any folders that look to be storing anything like that so I'm thinking it might be written to a file? (session log)
-
@ginerjmlike I said I don't know what the function is that makes that happen. I just know that is the link on the button, and it goes to that logout.php page. The only thing that changes in the database that you see is the status to appear offline when they click it. I'm sorry but that is all I know. Like I said I paid for someone to make this, I didn't write it. And unfortunately he said he doesn't know how to make what I'm wanting to happen, happen
-
@mac_gyverI think you're onto something. Would you be willing to elaborate on how to delete all the session files? I'm the admin so I don't mind if it logs me out too
-
@ginerjmthat is the only thing that changes in those records, correct. But my point of the screen shot was to show how the unique_id column is
-
Since most of them just refuse to click that Logout button, there has to be a way to force a logout so that wondering eyes on their computer don't get nosey (other people in their houses, etc) So if they wont click the button, then I need an ability to do it for them without logging into each account one by one and logging them out