PHP - Database Content Not Displaying After Deleting Login Code
Hello -
I'm opening my website up to visitors for free, and trying to bypass a login screen to go straight into the data content that was appearing after a user logged in. I have an index.php file that included the following code at the beginning: <?php session_start(); include("database.php"); include("login.php"); include("/vservers/skyranks/db_connect.php"); ?> <?header("Cache-control: private"); ?> <html> I deleted the "include("login.php"); line, and was successful at bypassing the username and login screen. However, the page that is supposed to display the data content is incomplete. In fact, it only displays my company's logo. Any ideas as to why the data content is not showing up? Thank you for any help with this, as my php is quite novice at this point. Regards - Joe Similar TutorialsHello everyone, When I submit my login form to go to my login page it goes to a white page and does not display an error. Code: [Select] <?php include("../secure/database.php"); if(!empty($_POST['loginsubmit'])){ if(!empty($_POST['email'])){ $email = securevar($_POST['email']); if(!empty($_POST['passconf'])){ $pass = securevar($_POST['passconf']); $q = "SELECT * FROM `accountinfo_db` WHERE `email` = '$email' AND `password` = '$pass'"; $res = mysql_query($q) or die(mysql_error()); $login = mysql_fetch_array($res); $id = $login['id']; $active = $login['active']; if($id>=1){ if($active==1){ $_SESSION['logged'] = $login['id']; $q = "UPDATE `accountinfo_db` SET `loggedtimes` = `loggedtimes`+'1' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); $user = $login['username']; header("Location: ../mainframe.php?strmsg=Welcome Back $user"); }else{ header("Location: activate.php"); } }else{ header("Location: ../index.php?strmsg=Login Information Incorrect!"); } }else{ header("Location: ../index.php?strmsg=You did not enter a valid password!"); } }else{ header("Location: ../index.php?strmsg=You did not enter a valid email!"); } }else{ header("Location: ../index.php?strmsg=We are sorry but you are not allowed viewance of that directory!"); } ?> any help would be great. Brian Hi I have a text area, that I want to display info pulled from a database. I can get the data to show, But can get each entry of the table to display on it's own line. Example: ob1ob2ob3ob4ob5 Should be: ob1 ob2 ob3 ob4 ob5 CODE: Code: [Select] <textarea id="interest" onfocus="clearInterest()" class="textareacss" style="height:212px;overflow:auto;"><?PHP $newInterestSub = Admin_interests_sub::find_by_cat_id($id); foreach($newInterestSub as $newInterestSubs){ echo $newInterestSubs->interest_sub.'\n'; } ?></textarea> Any help would be great. Hi, I am hoping I have posted my current problem in the right part of this forum. As it relates to the php code, I presume this is the right place, although it also relates to a mysql database I have too. Ok, here is my problem.... I have two websites, one is a non members site and one is a paid members area site. I had a directory style script made for the non members site and want to use the same script within the members site. I paid for the script to be made and set up, which cost me quite a bit, hence the reason I am copying it all over to my other site too. The script displays thumbnials from the database, 4 across and 3 down (total of 12 thumbs per page), each linking to a URL and each thumb has a title. On the left of the webpage is categories, which when clicked, shows thumbs relating to that specific category, or all etc. The CMS forms allow us to add categories etc. Ok, now my problem is this.. I backed up the original database and created a new database on the members site where I also want this functionality. I copied all the scripts over then chenged the content of the database. On the members site I only want it to display three categories, All, Photos and Videos. So this is quite simple compared to the first site. All seemed to display fine, until I moved all the scripts into the members folder (which is accessed via ccbill). The page displays ok, but it just states "No updates found" as in, no content in the database is found. The base url in the configuration script is set to the top domain, but I have renamed the folders where the thumbs are saved to members/thumbs, but still it isnt working. I also want to change the folder name from its original name of www.domain.com/sites to the new domain.com/updates but nothing works when I try to change it. If anyone can help me out with this, I would be extremely grateful, as the workings of this script are all there, and it seems pointless having to spend hundreds on a new script to be made when the functionality is already there, but just not working right. Thanks so much! Does anyone have a code that will automatically delete stuff out of the database after 30 days of being in there...? Hi. What am I doing wrong he Code: [Select] mysql_query("DELETE FROM availability WHERE id = '$_POST['id']'"); I am able to echo the id but I must be entering the post item incorrectly into the delete string. Can anyone show me my mistake? Thanks Hi Everyone, Im trying to add a delete button to the message inbox page of my website, where when delete is clicked, the checked messages get deleted from the database. After a bit of research on google i have come up with the code below however i cant get it to work. I have replaced the mysql delete query with echo "checked"; just for debugging. $query = mysql_query("SELECT * FROM users WHERE id='$id'"); $row = mysql_fetch_assoc($query); $submit = $_POST['submit']; $username = $row['username']; $checked = $_POST['message']; $messages_query = mysql_query("SELECT * FROM messages WHERE recipient='$username'"); if (mysql_num_rows($messages_query) > 0) { while ($messages_row = mysql_fetch_array($messages_query)) { if ($messages_row['message_read'] == 0) { echo "<div style='background-color:#FFCCCC;'>"; } $message_id = $messages_row['id']; echo "<a href='message.php?id=$message_id'>"; echo "From: " . $messages_row['sender']; echo "Subject: " . $messages_row['subject'] . "<br />"; echo "</a>"; echo "<form method='POST'><input type='checkbox' name='message[]' value='1' /></form>"; if ($messages_row['message_read'] == 0) { echo "</div>"; } } } else { echo "No messages"; } if ($submit) { if ($checked == "1") { echo "checked"; } } ?> <html> <form method="POST"> <input type="submit" name="submit" value="Delete" /> </form> </html> I have also tried the following but i still cant get it to work: if (isset($checked)) { echo "checked"; } Can anybody see where iv gone wrong? Thanks i trying to delete messages out of my message database but im not sure if i'm using this code right or there stuff missing to it :S delete.php <?php require_once('settings.php'); checkLogin('1 2'); $id=$_GET["msgs"]; mysql_query("DELETE messages FROM messages WHERE message_id='$id'"); ?> link usages to delete <a href="delete.php?msgs=<? echo $row['message_id'] ?>">[X]</a> I'm trying to delete rows in the database, based on what checkboxes are left empty by the user... What i have is small application in which a user can add an item to the database and give it tags... for example there is "apple" and it has the tags of "fruit, red, round" What i want is for the user to be able to edit those tags, so the user can remove "fruit" and add "sweet" instead or just remove "fruit" all at the same time. The code i have, somewhat works... This code below loops through the checkboxes and should remove the items that are no longer checked, by going through the database and grabbing all the tags and them checking it against those that are still checked and remove the ones that it didn't find checked...?? However whats happening is when i unchecked say "red" it removes all the other items..so if i had "red, fruit, round' and i want to remove "red" it leaves red but removes the rest. foreach($_POST['tag'] as $r=>$n){ $t = mysql_real_escape_string($_POST['tag'][$r]); $get_tag2 = mysql_query("SELECT * FROM file_cats WHERE fileID='$fileID'") or die(mysql_error()); while($t2 = mysql_fetch_assoc($get_tag2)){ $tmp_tag1 = $t2['category']; if($t==$tmp_tag1){ $remove_tag = mysql_query("DELETE FROM file_cats WHERE fileID='$fileID' AND category='$t' LIMIT 1") or die(mysql_error()); } } } This following piece of code just adds a new tag...however i want it to check to see if that tags already exist in the database, if it does then don't add it just add the new ones.. foreach($_POST['tag'] as $k=>$l){ $tag = mysql_real_escape_string($_POST['tag'][$k]); $add_tag = mysql_query("INSERT into file_cats (fileID, category) VALUES('$fileID', '$tag')") or die(mysql_error()); } My final problem is that i can't remove items if the second snippet of code is there, i have to remove those lines of code in order to remove items, however i can add items with both loops there. I'm basically stuck and hope that someone here can shed some light on what i'm doing wrong, because i know i'm doing something wrong i just can't find it Anyway thank you in advanced I've tried reading through some of the threads but couldnt understand some of them. I've made a newsfeed script which works how i want it to. Now i want to add the function to delete a row from the database from an "admin panel" on the website. So far i have this: <?php include("includes.php"); doConnect(); $get_news = "SELECT id, title, text, DATE_FORMAT(datetime, '%e %b %Y at %T') AS datetime FROM newsfeed ORDER BY datetime DESC"; $result= mysqli_query($mysqli, $get_news) or die(mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { echo '<strong><font size="3">'. $row['title'] .' </font></strong><br/><font size="3">'. $row['text'] .'</font><br/><font size="2">'. $row['datetime'] .'</font><br/><br/><a href="delnews.php?del_id=' .$row['id']. '"> <strong>DELETE</strong></a>';} ?> then my delnews.php is: <?php include("includes.php"); doConnect(); $query = "DELETE FROM newsfeed WHERE id = "$_POST['id']""; $result = mysql_query($query); echo "The data has been deleted."; ?> I believe the problem is $_POST['id']. i've tried different things in there but none work. It displays the echo line but doesnt actually delete anything. I am new to php so this may be a stupid mistake, but try and play nice! Thanks i am trying to delete files for a user, and then update the database with the new bandwhitch/free space. here is my code: http://pastebin.com/J2XE9Fip i just can't figure out where i'm going wrong... thanks in advance I'm creating a newsletter and the unsubscribe isn't deleting the database entry like I'm asking it to. Everything else works fine, it even successfully says the user has been removed, but it doesn't actually delete the database entry. I've spent two days trying to figure out why. Here's the code:
Newsletter sign up: <?php //DB Connect Info $servername = ""; $database = ""; $username = ""; $password = ""; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } /*$createTable = $conn->prepare ("CREATE TABLE IF NOT EXISTS email_user ( id int(11) NOT NULL AUTO_INCREMENT, email varchar(200) NOT NULL, hash varchar(250) NOT NULL, PRIMARY KEY (id) )"); $createTable->execute(); */ function input_security($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $email = input_security($_POST['email']); $insertData = input_security($insertData); if(isset($_POST['submit'])) { extract($_POST); if($email!="") : $email=mysqli_real_escape_string($conn,$email); $emailval = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/'; if(preg_match($emailval, $email)) : $db_check=$conn->query("SELECT * FROM email_user WHERE email='$email'"); $count=mysqli_num_rows($db_check); if($count< 1) : $hash=md5($email.time()); $link = '/unsubscribe.php?key='.$hash; // Change your domain $fetch=$conn->query("INSERT INTO email_user(email,hash) VALUES('$email','$hash')"); $to="$email"; //change to ur mail address $strSubject="Maintenance Fee Relief, LLC | Email Subscription"; $message = '<p>Thank you for subscribing with us.</p>' ; $message .= '<p>Click here to unsubscribe your email : <a href="'.$link.'">unsubscribe</p>' ; $headers = 'MIME-Version: 1.0'."\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n"; $headers .= "From: info@"; $mail_sent=mail($to, $strSubject, $message, $headers); $msg_sucess="Your request has been accepted!."; else : $msg="This $email email address is already subscribe with us."; endif; else : $msg="Please enter your valid email id"; endif; else : $msg="Please fill all mandatory fields"; endif; } ?> <div class="newsletter-sign-up-header-form"> <div id="logerror"><?php echo @$msg; ?><?php echo @$msg_sucess; ?></div> <form method="post"> <span><input type="email" name="email" placeholder="Email Address - Join Newsletter" class="newsletter-sign-up-header-email" required></span> <span><button name="submit" value="submit" title="Submit" class="newsletter-sign-up-header-submit-button">Submit</button></span> </form> </div> <?php //DB Connect Info $servername = ""; $database = ""; $username = ""; $password = ""; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } ?> <?php if(@$_GET['key']!=""): $hash=mysqli_real_escape_string($conn,$_GET['key']); $fetch=$conn->query("SELECT * FROM email_user WHERE hash = '$hash'"); $count=mysqli_num_rows($fetch); if($count==1) : $row=mysqli_fetch_array($fetch); $conn->query("DELETE email_user WHERE id='$user_id'"); $msg="Your email id unsubscribe with us"; else : $msg="Please click valid link."; endif; else : header("Location:404.php"); endif; ?> <!doctype html> <html lang="en"> <head> <title>Unsubscribe</title> </head> <body> <div align="center"> <h2><?php echo $msg; ?></h2> <a href="https://www.--.com">--.com</a> </div> Quote
Hi, guys. I am a php newb and stuck (see title). I it will only send the value of 1 tick box over to the page "delete_message.php" This is what i have so far: Code: [Select] <?php // get messages $result = mysql_query("SELECT * FROM tbl_pvt_msg WHERE to_UID='$UID'"); if (!$result) die("Query to show fields from table failed"); while ($data=mysql_fetch_array($result)) { $_SESSION['from_UID']=$data['1']; UIDtoemail(); $from_email=$_SESSION['from_email']; $contents=$data['3']; $timesent=$data['4']; $msg_ID=$data['0']; echo "<form action='scripts/delete_message.php' method='POST' >"; echo "<tr><td>$from_email</td><td>$contents</td><td>$timesent</td><td><input type='checkbox' value='$msg_ID' name='msg_ID' /></td> </tr>"; } // turn uid into email function UIDtoemail(){ $from_UID=$_SESSION['from_UID']; $result = mysql_query("SELECT * FROM tbl_usr WHERE UID='$from_UID'"); if (!$result) die("Query to show fields from table failed"); $data=mysql_fetch_array($result); $_SESSION['from_email']=$data['7']; } ?> </table> <input type="submit" value="Delete" id="delete" /> </form> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=334042.0 I have a bad way with words, so if the title doesnt make much sense nor my post, I apolagize! But I am using a while loop and mysql_fetch_array to echo all information in a table in mysql. With each entry, I have included a button that executes a delete query for that entry. Code: [Select] $delquery="DELETE FROM requests WHERE user = '".$row['user']."'"; mysql_query($delquery,$link2); echo "<font size='19px' color='#009933'>User deleted from request database.When I click the button, the message is echod in every entry listed on the page, and nothing happens. I figured Id use delete from the username, so that way mysql will know which one to delete... but Idk when I think about it thats dumb and makes no sense. Im stuck. This side of the application im trying to make is the admin side where I can process requests. After I process the request I delete it from the database so I know I processed it. I have no idea what query to use for this. Anybody know how I could do this? Thanks Hi guys, I was just wondering if anyone could help me. I've got a My_SQL database containing articles, a summary for the article and a date. I have a basic CMS system set-up, but I want to create a script that when users sign up to a mail list it forwards the summary and dates of the articles database. If that makes sense? But I only want it to forward the most recent 5 rows. I'm pretty new to PHP and I've been mostly following tutorials thus far, but this is quite specific. Thanks in advance! Hello! Looking for some advice regarding displaying content from my databases on my members websites via an iframe. Here's what I want to do; Members on my site are rated and reviewed, what I wanted to do was create a piece of code that they could embed on their website to show their reviews. My first instincts where to create an iframe and use the source to pass get variables to my server to identify the member and then use these in a query to select member reviews. Here is the code; For their site; Code: [Select] <iframe frameborder="0" height="250px" width="700px" scrolling="auto" src="http://www.mysite.co.uk/reviews.php?ID=9999&aKey=123456"></iframe> Passes the member ID and a unique access key for that member. The page on my site; (reviews.php) include_once $_SERVER['DOCUMENT_ROOT'] . // path to script files $ID=mysql_real_escape_string($_GET['ID']); $aKey=mysql_real_escape_string($_GET['aKey']); if(empty($aKey) || empty($ID)){ die("Key or ID not set,Selection Error"); exit;} $reviewresult = mysql_query("SELECT Name,Review,Date FROM Reviews WHERE ID='$ID' AND aKey='$aKey' Order by RAND() Limit 10"); //if there is at least one review if($reviewresult && mysql_num_rows($reviewresult) > 0) { while($review = mysql_fetch_array($reviewresult)) { // output reviews } } Are there any security risks with this script? Do you think it is the best method to accomplish what I want? Are there better alternatives? Any suggestions or room for improvement? Thanks! Hi all, I'm not sure if this is a PHP question or javascript, so if it needs to be moved can an admin please do so... Anyway, basically I have the following code: Code: [Select] <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">View Availability</a> This pops up a divs with a black alpha background, so that it appears the new content is displaying over the top of the current content. This all works fine, however the content I am displaying in the top level div is (or should be) dynamic. In order for the content to be useful I need to grab the id. Normally I would simply do this: Code: [Select] <a href = "[b]url.php?uniqueidentifier=<?php echo $row['id'];?>[/b]" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">View Availability</a> However what happens in this instance is that the page loads with the javascript and the id in the url but it then disappears... Has anyone got any ideas on how I might be able to get around this? Many thanks, Greens85 Hi! So I have got some code that looks like this: Code: [Select] if (isset($_GET['view_log'])) { // show content (text from db) } When I click the button named "view_log" everything displays just fine, however I would like to be able to click the button again and make the content disappear. Is this possible using only PHP?? Thanks for the help!:) It is greatly appreciated! Hi! I'm a total stupid newbie. Please humor me. So, I'm trying to make a guestbook, just as practice. So far I have a form that writes entries to a file, each entry on a new line. Entries look like this: Code: [Select] 11:11 am, Oct 12th, 2010|name|website|message My dividing character between parts of the entries is the vertical bar. I don't know if that's a bad idea. As I said, I'm a newb. I should probably find out how to make a code that makes it so people can't use that character in the form. Anyway, this is my code so far trying to display the entries. So far, I just want to show the date of the first entry. $file = fopen("posts.txt", 'rb'); while(!feof($file) && fgetc($file) != "|"){ $date = $date.fgetc($file); } echo $date; fclose($file); I already have a problem. The code does stop at the vertical bar, but instead of showing the date as "11:11 am, Oct 12th, 2010" it shows "11 m c 2h 00". I'm just super confused, and I don't know what to do. Thanks. (: Hi Guys what I need to do is display data from two different tables that equal the same value in a specific field Table one has ID Title Course content table two has ID Title Start date End date I need a query that says if title from table one matches title from table 2 then will display the start and end date from table two sorry if this is really simple I am a newbie thanks inadvance |