Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Is it possible to link column_id from table A with column_id from table B? For example: If column_id A has a value of 6, column_id B should not be able allow entries if the column_id B is more than the value of column id A. I am running the below function to extract data from these tables: function list_articles() { include('core/db/db_connection.php'); $sql = "SELECT blog.title, blog.content, blog.posted_by, blog.date, article_comments.comments, article_comments.comment_by FROM blog LEFT OUTER JOIN article_comments ON blog.content_id = article_comments.comment_id WHERE blog.content != '' ORDER BY blog.content_id DESC"; $result = mysqli_query($dbCon, $sql); while ($row = mysqli_fetch_array($result)) { echo "<h5 class='posted_by'>Posted by " . $posted_by = $row['posted_by'] . " on " . $row['date'] . "</h5>" . "<h1 class='content_headers'>" . $title = $row['title'] . "</h1>" . "<article>" . $content = $row['content'] . "</article>" . "<hr class='artline'>" . "<div class='commented_by'>" . $row['comment_by'] . "</div>" . "<div class='comments'>" . $row['comments'] . "</div>"; } } Thanks.
  2. Hallo! Ik heb net een cron job ingesteld via cpanel. Graag zou ik via php een timer willen hebben om te laten zien hoelang het duurt voordat de cronjob opnieuw word uitgevoerd. Ik heb gegoogled maar kon hier jammergenoeg niets over vinden. Heeft iemand van jullie een idee? Thanks!
  3. Hello I have a php script I actually got from Stackoverflow, on one of the questions asked. I'm not really sure where to apply it, I put it in some code that I had already that submits the data to be put in the text file. It downloads the file, but inside it has php errors. The errors are: Undefined variable: month in xxx.xxx.xxx on line 12 Undefined variable: res xxx.xxx.xxx on line 14 mysql_fetch_array() expects parameter 1 to be resource, null given in xxx.xxx.xxx on line 14 The script I have is: //Below is where you create particular month's text file $file = $month . '.txt'; $handle = fopen($file, "w"); while ($row=mysql_fetch_array($res)){ $writestring = $row['data_I_want'] . "\r\n"; fwrite($handle, $writestring); } fclose($handle); $data = file_get_contents($file); echo $data; //Now the file is ready with data from database //Add below to download the text file created $filename = $file; //name of the file $filepath = $file; //location of the file. I have put $file since your file is create on the same folder where this script is header("Cache-control: private"); header("Content-type: application/force-download"); header("Content-transfer-encoding: binary\n"); header("Content-disposition: attachment; filename=\"$filename\""); header("Content-Length: ".filesize($filepath)); readfile($filepath); exit;
  4. Hello! I know this seems like an easy task, using strval or casting to string, but the API I am using WON'T accept anything but a hard coded string "". I figure there has to be a way to get around this... What I have here is a method used to convert an array in to a YAML/String format for me to upload onto a server using JSONAPI, found here. I am using Spyc, as that is the only thing I have found that works for this, and it does pretty well. function pushArrayToServer($array, $api) { $yaml = Spyc::YAMLDump($array,4,60); $value = 0; while (strpos($yaml, "$value:") !== false) { $yaml = str_replace("$value:", "-", $yaml); $value = $value + 1; } $yaml = str_replace("---", "", $yaml); // Final YAML from Array var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml))); } Now the problem is that last $api->call I do. This call accepts the method type as a string(argument 1), and an array for argument two. For the method "files.write", the api requires an array being (file location, string). The string is what will be replacing the content of the file. But the only way I can get that line to work is if I do this: var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", "a string here"))); That works 100% fine, no errors. This is the dump I get when I run that. But as soon as I do one of these: var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml))); $yaml2 = $yaml . ""; var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml2))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", strval($yaml)))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", "$yaml2"))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", (string)$yaml))); These do not work. The dumps all return null. I haven't found a way yet to not do "". It almost worked once when I attempted some things, but I found out I was just converting a boolean into a string which caused an error. The server I am working with is a minecraft server with JSONAPi installed. It works great, except for this error. So I am assuming the string type has to be just like Java's, or pretty plain? I have no clue this is the first real issue I've had with this plugin. Thanks in advance, HeyAwesomePeople
  5. Having problems viewing pages of my codeigniter based hospital management system. Can only view the homepage, other pages missing, really dont know how to fix it. Uploaded it with the sql on google drive. https://drive.google.com/file/d/0B2NbxciE_vU6S29hZGl5OW1QbzQ/view?usp=sharing Only page uploaded is tthe homepage as see below, rest are missing -- -- Dumping data for table `pages` -- INSERT INTO `pages` (`id`, `title`, `slug`, `parent_id`, `order`, `template`, `body`) VALUES (1, 'Home', '', 0, 1, 'homepage', '');
  6. Good day, I have a task at hand, I was given an project where I need to combine 3 blogs into on site. I understand the simplistic answer to this but the doing is a bit confusing at this point and would like to get some input from a community. Is there software I can use for this, except for wordpress? Or is it best to design and develop each cms for each blog into a main CMS page. MAIN CMS PAGE -> Blog 1, blog 2, blog 3 and then settings for each blogs and add/edit and delete pages etc. The second problem is that I have briefly dealt with themes before and have found them to be a pain when it comes to trying to select a theme from a list of 3. I got fairly tilted results as some elements confused each other.. Is this fairly normal? Does php have a weakness towards themes? Any software suggestions and guidance would be so appreciated. Thanks in advance
  7. Hello everyone, Let me first say that I am a PHP beginner. With the use of online video tutorials I have setup a shopping cart for my online store that sells stainless steel jewelry. Everything is working well, but I want to add something and even though I know what needs to e done - I don't know how to go about it. Can someone please help me out? So I have a product page that gets the product's name, code, price and details from the database. This is the page's code: <?php // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php // Check to see the URL variable is set and that it exists in the database if (isset($_GET['id'])) { // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $id = preg_replace('#[^0-9]#i', '', $_GET['id']); // Use this var to check to see if this ID exists, if yes then get the product // details, if no then exit this script and give message why $sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { // get all the product details while($row = mysql_fetch_array($sql)){ $product_code = $row["product_code"]; $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; $category = $row["category"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); } } else { echo "The item does not exist."; exit(); } } else { echo "Data to render this page is missing."; exit(); } mysql_close(); ?> <!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> <title><?php echo $product_code; ?></title> <meta http-equiv="Content-type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <meta name="author" content="Susan Wiese" /> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <div id="page-container"> <div id="header"> <?php include "storescripts/header.php"; ?> </div> <div id="center-panel"> <div class="box1"> <?php include "storescripts/menu.php"; ?> </div> <div class="box1"> <table width="100%" border="0" cellspacing="0" cellpadding="15" align="center"> <tr> <td width="25%" valign="top"> <img src="inventory_images/<?php echo $id; ?>.jpg" width="200" height="200" alt="<?php echo $product_name; ?>" /><br /> <a href="inventory_images/<?php echo $id; ?>.jpg">View full size</a></td> <td width="75%" valign="top"> <h3><?php echo $product_code; ?></h3> <?php echo $product_name; ?><br /> <br /> <?php echo $details; ?><br /> <br /> <?php echo "R".$price; ?><br /> <br /> <form id="form1" name="form1" method="post" action="cart.php"> <label for="engraving">Engraving</label><br /> <input type="text" name="engraving" id="engraving" size="35" /><br /> <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" /><br /> <input type="submit" name="button" id="button" class="submit" value="Add to cart" /> </form> </td> </tr> </table> </div> <div class="box1"> <?php include "storescripts/order.php"; ?> </div> </div> <div id="footer"> <?php include "storescripts/footer.php"; ?> </div> </div> </body> </html> The product page looks like this: http://www.personalizedjewellery.co.za/store/product.php?id=3 You'll notice I've added an "Engraving" label to the form. I want a visitor to be able to add the engraving they want to be done on this product. This information should then be sent to the cart with all the other details when the person adds the item to their cart. I want the text to be engraved to be displayed in the cart's table with the image, price, etc. This output should be in the //Create the product array section of cart.php (where I have added $engraving) Cart.php <?php session_start(); // Start session first thing in script // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; ?> <?php /////////////////////////////////////////////////////////////////////////////////// //Section 1 (if user attempts to add something to the cart from the product page)// /////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['pid'])) { $pid = $_POST['pid']; $wasFound = false; $i = 0; // If the cart session variable is not set or cart array is empty if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { // RUN IF THE CART IS EMPTY OR NOT SET $_SESSION["cart_array"] = array(0 => array("item_id" => $pid, "quantity" => 1)); } else { // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $pid) { // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1))); $wasFound = true; } // close if condition } // close while loop } // close foreach loop if ($wasFound == false) { array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1)); } } header("location: cart.php"); exit(); } ?> <?php //////////////////////////////////////////////////////////// //Section 2 (if user chooses to empty their shopping cart)// //////////////////////////////////////////////////////////// if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") { unset($_SESSION["cart_array"]); } ?> <?php /////////////////////////////////////////////////////// //Section 3 (if user chooses to adjust item quantity)// /////////////////////////////////////////////////////// if (isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") { // execute some code $item_to_adjust = $_POST['item_to_adjust']; $quantity = $_POST['quantity']; $quantity = preg_replace('#[^0-9]#i', '', $quantity); // filter everything but numbers if ($quantity >= 100) { $quantity = 99; } if ($quantity < 1) { $quantity = 1; } if ($quantity == "") { $quantity = 1; } $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $item_to_adjust) { // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $item_to_adjust, "quantity" => $quantity))); } // close if condition } // close while loop } // close foreach loop } ?> <?php ///////////////////////////////////////////////////////// //Section 4 (if user wants to remove an item from cart)// ///////////////////////////////////////////////////////// if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") { // Access the array and run code to remove that array index $key_to_remove = $_POST['index_to_remove']; if (count($_SESSION["cart_array"]) <= 1) { unset($_SESSION["cart_array"]); } else { unset($_SESSION["cart_array"]["$key_to_remove"]); sort($_SESSION["cart_array"]); } } ?> <?php ///////////////////////////////////////////////////////////////// //Section 5 (render the cart for the user to view on the page)// ///////////////////////////////////////////////////////////////// $cartOutput = ""; $cartTotal = ""; $pp_checkout_btn = ''; $product_id_array = ''; if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { $cartOutput = "<h3 align='center'>Your shopping cart is empty</h3>"; } else { // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $item_id = $each_item['item_id']; $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { $product_code = $row["product_code"]; $product_name = $row["product_name"]; $price = $row["price"]; } $pricetotal = $price * $each_item['quantity']; $cartTotal = $pricetotal + $cartTotal; $pricetotal = money_format("%.2n", $pricetotal); // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].", "; // Dynamic table row assembly $cartOutput .= "<tr>"; $cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_code . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_code. '" width="75" height="75" border="1" /></td>'; $cartOutput .= '<td>R' . $engraving . '</td>'; $cartOutput .= '<td>R' . $price . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" /><br /> <br /> <input name="adjustBtn' . $item_id . '" type="submit" class="submit" value="Change" /> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form></td>'; //$cartOutput .= '<td>' . $each_item['quantity'] . '</td>'; $cartOutput .= '<td>R' . $pricetotal . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" class="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; $cartOutput .= '</tr>'; $i++; } $cartTotal = money_format("%.2n", $cartTotal); $cartTotal = "R".$cartTotal." "; } ?> <!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> <title>Your Cart</title> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <?php include_once("storescripts/analyticstracking.php") ?> <div id="page-container"> <div id="header"> <?php include "storescripts/header.php"; ?> </div> <div id="center-panel"> <div class="box1"> <?php include "storescripts/menu.php"; ?> </div> <div class="box1"> <center> <img src="images/cart.png" alt="Cart" title="Cart" border="0" /> <h3>Your Cart</h3> </center> <div style="margin:24px; text-align:left;"> <table width="80%" border="1" cellspacing="0" cellpadding="6" align="center"> <tr> <td width="20%" bgcolor="#FFFFFF"><strong>Product</strong></td> <td width="35%" bgcolor="#FFFFFF"><strong>Engraving</strong></td> <td width="10%" bgcolor="#FFFFFF"><strong>Price</strong></td> <td width="10%" bgcolor="#FFFFFF"><strong>Quantity</strong></td> <td width="10%" bgcolor="#FFFFFF"><strong>Total</strong></td> <td width="10%" bgcolor="#FFFFFF"><strong>Remove</strong></td> </tr> <?php echo $cartOutput; ?> </table> <br /> Cart Total: <?php echo $cartTotal; ?> | <a href="cart.php?cmd=emptycart">Empty your cart</a><br /> <br /> <h3>If you buy 6 items, you will receive the 6th item for free</h3> This adjustment will be made on your invoice before we send it to you.<br /> <br /> <h3>Postage</h3> The postage cost is to be added to the total above.<br /> • Post Office Registered Mail: R50<br /> • Fastway Couriers (Limited Service): R55<br /> • Speed Services: R90<br /> • Aramex Couriers (Full Service): R105<br /> </div> </div> </div> <div id="footer"> <?php include "storescripts/footer.php"; ?> </div> </div> </body> </html> Could someone please help me get the text to be engraved added to the cart? I would really appreciate it. It is probably very simple, but I'm completely stuck. Thanks Susan
  8. Hello so I have a simple code here that will check if a random number already exists in the database and will generate a new one: $rand = mt_rand(100000, 999999); $sid = array( ":sponsorID" => $rand ); $accounts = $db->select("accounts", "sponsorID = :sponsorID", $sid) while(count($accounts) > 0) { $newNum = mt_rand(100000, 999999); } What I wanted to do is to echo out $newNum. When I echo it out I get undefined index of that variable. How can I solve this?
  9. Best, I am currently working on a mafia crime game. But there is something wrong with my script. I have 1 error on my news. php, and will you even error + the script here. I know that my script is messy but am still but a novice It would be great if this solved hit! And sorry for my bad English. (IM a Belgian) Here the error + script: error: Parse error: syntax error, unexpected $end in C:\xampp\htdocs\_menu_l.php on line 881 and here the script: <?php $__admin = 16; $__gmod = 8; $__fmod = 4; $__help = 2; include("./includes/_mysql_connection.php"); include("./includes/_functions.php"); include("_functies.php"); if(!isset($_SESSION['__id'])){ header("location: index.php"); } define("ID", $_SESSION['__id']); $select = mysql_query("SELECT `username`, `ip`, `lastclick`, `id` FROM `users` WHERE `id` = ".ID." LIMIT 1") or die(mysql_error()); if(mysql_num_rows($select) == 0){ header("location: index.php"); } $res = mysql_fetch_assoc($select); $naam = $res['username']; $SESSID = $_COOKIE['PHPSESSID']; $s = mysql_query("SELECT `id` FROM `sessions` WHERE `id`=".ID." AND `SESSID`='".mr($SESSID)."' LIMIT 1") or die(mysql_error()); if(mysql_num_rows($s) == 0){ $sql = mysql_query("SELECT `id` FROM `sessions` WHERE `id`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_num_rows($sql) == 0){ mysql_query("INSERT INTO `sessions`(`id`, `SESSID`) VALUES (".ID.", '".mr($_COOKIE['PHPSESSID'])."')") or die(mysql_error()); } /* else { unset($_SESSION); header("location: index.php"); }*/ if(mysql_num_rows($s) > 0 AND !isset($_SESSION['logged'])) { unset($_SESSION); header("location: index.php"); } } mysql_query("UPDATE `sessions` SET `SESSID`='".$SESSID."' WHERE `id`=".ID." LIMIT 1") or die(mysql_error()); // Selecteer wat data $sql = mysql_query("SELECT `speldata`. * , `landen`.`land` , `familie`.`naam` FROM `speldata` LEFT JOIN `landen` ON ( `speldata`.`land_id` = `landen`.`id` ) LEFT JOIN `familie` ON ( `speldata`.`familie_id` = `familie`.`id` ) WHERE `speldata`.`id` =".ID." LIMIT 1 ") or die(mysql_error()); $res = mysql_fetch_assoc($sql); /* Data invullen */ if(!is_null($res['naam'])){ $hasfam = true; } else { $hasfam = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `baas_id`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $famboss = true; } else { $famboss = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `onderbaas_id`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $famunderboss = true; } else { $famunderboss = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `shoutboxmod`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $shoutmod = true; } else { $shoutmod = false; } $sql = mysql_query("SELECT COUNT(`id`) FROM `familie` WHERE `onderbaas_id2`=".ID." LIMIT 1") or die(mysql_error()); if(mysql_result($sql, 0) == 1){ $famunderboss2 = true; } else { $famunderboss2 = false; } $s = mysql_query("SELECT `misdaden_s`, `misdaden_g`, `auto_s`, `auto_g`, `wapenervaring`, `hoerenpimpen`, `kracht`, `fam_overvallen`, `bombaderen`, `stem`, `route66`, `computer` FROM `usertimes` WHERE `id`=".ID) or die(mysql_error()); $r = mysql_fetch_assoc($s); $sql_sd = mysql_query("SELECT `donateur`, `status` FROM `status` WHERE `id`=".ID) or die(mysql_error()); $rs = mysql_fetch_assoc($sql_sd); $__status = $rs['status']; $__dona = $rs['donateur']; $__rank = $rs['status']; if(isset($_COOKIE['banned']) && $__status > 0){ setcookie("banned", "true", time()); mysql_query("UPDATE `status` SET `status`=1 WHERE `id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `ip_banned` WHERE `ip`='".mr($_SERVER['REMOTE_ADDR'])."'") or die(mysql_error()); mysql_query("DELETE FROM `bans` WHERE `id`=".ID) or die(mysql_error()); } $v_id = array(); $v_ip = array(); $v_reden = "Hacken"; $v_names = array(""); if(in_array(ID, $v_id) || in_array($_SERVER['REMOTE_ADDR'], $v_ip) || in_array($naam, $v_names)){ die("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <link href='styles.css' rel='stylesheet' type='text/css' /> <title>Verbannen!</title> </head> <body style='background-color: #464646; text-align: center; margin-top: 7%'> <img src='IMG/ban.jpg' alt=''> <br><br> <font size='2'> <b> Je bent verbannen! <br><br> </font> Reden:</b> ".$v_reden."<br><br> </body> </html>"); } $_s = mysql_query("SELECT COUNT(`ip`) FROM `ip_banned` WHERE `ip`='".mr($_SERVER['REMOTE_ADDR'])."'") or die(mysql_error()); if($__status == 0 || isset($_COOKIE['banned']) || mysql_result($_s, 0) >= 1){ $sql = mysql_query("SELECT `reden` FROM `bans` WHERE `id`=".ID) or die(mysql_error()); $res = mysql_fetch_assoc($sql); if(!isset($_COOKIE['banned'])){ setcookie("banned", "true", (time() + (60*60*24*200))); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <link href='styles.css' rel='stylesheet' type='text/css' /> <title>Verbannen!</title> </head> <body style='background-color: #464646; text-align: center; margin-top: 7%'> <img src="IMG/ban.jpg" alt=""> <br><br> <font size='2'> <b> Je bent verbannen! <br><br> </font> Reden:</b> <?=$res['reden'];?><br><br> </body> </html> <? die(); } /* Zet er een nieuwe tijd in, om te zien dat ie online is */ if(!isset($_COOKIE['offline']) || $__status <= 1){ mysql_query("UPDATE `users` SET `lastclick`=".time()." WHERE `id`=".ID) or die(mysql_error()); } /*$poll = mysql_query("SELECT `user_id` FROM `poll_answers` WHERE `user_id`=".ID) or die(mysql_error()); if(mysql_num_rows($poll) == 0 AND $_SERVER['REQUEST_URI'] != "/poll.php"){ header("location: poll.php"); } */ $adminpagina = array("/famshoutbox.php", "/nieuws.php"); if($_SERVER['REQUEST_URI'] == $adminpagina){ header("location: nieuws.php"); } $st = cname(ID, $naam, true); $status = $st['status']; $familie = $res['naam']; $famID = $res['familie_id']; $staatID = $res['land_id']; $staat = $res['land']; if($staatID < 1 || $staatID > 11){ mysql_query("UPDATE `speldata` SET `land_id`=1 WHERE `id`=".ID) or die(mysql_error()); } $contant = $res['cashmoney']; $bank = $res['bankmoney']; /* Aantal hoeren, eerpunten, kills */ $hoeren = $res['hoeren_straat']; $hoeren_count = $res['count_hoeren']; $eerpunten = $res['eerpunten']; $killed = $res['kills']; mysql_query("UPDATE speldata SET cashmoney='0' WHERE cashmoney<'0'"); mysql_query("UPDATE speldata SET bankmoney='0' WHERE bankmoney<'0'"); /* Rank */ $leven = $res['leven']; if($leven == 0){ if(isset($_POST['reset'])){ $newname = trim($_POST['name']); $id = getid($newname); if(!is_name($newname)){ $msg = "Je hebt ongeldige tekens in je nieuwe naam gedaan!"; } elseif($id != false && $id != ID){ $msg = "Deze naam is al bezet!"; } else { cname(ID, $newname, false, true); mysql_query("UPDATE `speldata` SET `leven`=100, `hoeren_straat`=0, `rank`=0.5, `cashmoney`=2500, `bankmoney`=10000 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `status` SET `bescherming`=0 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `users` SET registerDate=NOW(),`username`='".$newname."' WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `vrienden_blokkeren` SET `who`='".$newname."' WHERE `who`=".ID) or die(mysql_error()); mysql_query("UPDATE `uitrust` SET `kogels`=10, `huizen_gehad`='', `woning`=0, `wapen`=0, `verd`=0, `vliegtuig`=0 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `userstats` SET `misdaden_s`=0, `misdaden_g`=0, `auto_s`=0, `auto_g`=0, `kracht`=0, `winst`=0, `verlies`=0, `wapenervaring`=0, `wapentraining`=0, `hacken`=0, `hack_s`=0, `program`=0, `program_s`=0, `beheer`=0, `beheer_s`=0 WHERE `id`=".ID); mysql_query("UPDATE `usertimes` SET `misdaden_s`=0, `misdaden_g`=0, `auto_s`=0, `auto_g`=0, `wapenervaring`=0, `hoerenpimpen`=0, `reizen`=0, `kracht`=0 WHERE `id`=".ID); mysql_query("DELETE FROM `hoeren_rld` WHERE `id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `hoeren_voorbereiding` WHERE `id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `gevangenis` WHERE `user_id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `garage` WHERE `user_id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `crusher_converter` WHERE `user_id`=".ID) or die(mysql_error()); mysql_query("DELETE FROM `drugs_drank` WHERE `user_id`=".ID) or die(mysql_error()); // mysql_query("UPDATE plattegrond SET owner='0',Gevangenis='0',Red_Light_District='0',Ziekenhuis='0',Casino='0' WHERE owner='".ID."'"); mysql_query("UPDATE speldata SET platte='0' WHERE id='".ID."'"); header("location: nieuws.php"); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <link href='styles.css' rel='stylesheet' type='text/css' /> </head> <body style='background-color: #303030; text-align: center; margin-top: 7%'> <form method='post' action='nieuws.php'> <img src="IMG/grave_rip.jpg" alt=""> <br><br> <font size='2'> <b> Je bent vermoord! <br><br> <?php if(isset($msg)){ echo $msg; } ?> Naam: <input type='text' name='name' value='<?=$naam;?>' maxlength='12' /><br><br> <input type='submit' name='reset' value='Opnieuw Beginnen!' /> </b> </font> </form> </body> </html> <? die(); } $rank = getRank($res['rank']); $rankID = $rank['rankID']; $gSql = mysql_query("SELECT `tijd` FROM `gevangenis` WHERE `user_id`=".ID." AND `tijd`>".time()." LIMIT 1") or die(mysql_error()); if(mysql_num_rows($gSql) == 1){ $gevangen = true; $gRes = mysql_fetch_assoc($gSql); $seconden = $gRes['tijd'] - time(); } else { $gevangen = false; } $rSql = mysql_query("SELECT `reizen` FROM `usertimes` WHERE `id`=".ID) or die(mysql_error()); $rRes = mysql_fetch_assoc($rSql); if($rRes['reizen'] > time()) { $reizen = true; $reistijd = $rRes['reizen'] - time(); } else { $reizen = false; } include("_mainMenus.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <meta name='author' content='$naam' /> <link href='styles.css' rel='stylesheet' type='text/css' /> <link rel='shortcut icon' href='favicon.ico'> <link rel='icon' href='favicon.ico'> <title>MyWay</title> </head> <body> <table width='100%' cellspacing='0' style='margin: 0px;'> <tr> <td width='14%' style='vertical-align: top;'> <table border='0' cellspacing='1' width='100%' bgcolor='#000'> <?php foreach($menuleft AS $cat => $subCats){ echo " <tr><td class='menutop'>".$cat."</td></tr>"; if(is_array($subCats)){ foreach($subCats AS $url => $name){ if($url == "donatieshop.php"){ echo " <tr><td class='menu'><img src='IMG/star.jpg' alt=''><a href='".$url."'>".$name."</a></td></tr>"; } else { echo " <tr><td class='menu'><a href='".$url."'> - ".$name."</a></td></tr>"; } } } } ?> </table> </td> <td width='72%' style='vertical-align: top; height: 0px; text-align:center;' align='center'> <table border='0' cellspacing='0' width='100%' align='center'> <tr> <td> <table border='0' cellspacing='1' width='96%' bgcolor='#000' align='center'> <tr> <td class='header' style='padding: 0px;'> <table style="margin:0px; padding:0px;vertical-align: bottom;" cellpadding="0" cellspacing="0" width="100%"> <tr> <td style="padding:0px; margin:0px;"> <img src="/IMG/header_image.jpg" alt="" /> </td> <td> <div class="counter_view"> <table cellpadding="0" cellspacing="0" style="margin: 0px; padding: 0px;"> <tr> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/gun.png' alt='' title='Misdaden/Familie misdaad' border='0'> </td> <td><?php if($r['misdaden_s'] < time()){ echo "<a href='misdaad.php'>Nu</a>"; } else { echo "<span id='cdmisdaad_s'>".($r['misdaden_s'] - time())."</span>".countDown("misdaad_s", ($r['misdaden_s'] - time())); } ?></td> </tr> </table> </td> <td style="width: 50px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/gun_anchor.png' alt='' title='Wapen Training' border='0'> </td> <td> <?php if($r['wapenervaring'] < time()){ echo "<a href='wapenervaring.php'>Nu</a>"; } else { echo "<span id='cdwapenervaring'>".($r['wapenervaring'] - time())."</span>".countDown("wapenervaring", ($r['wapenervaring'] - time())); } ?> </td> </tr> </table> </td> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/anchor.png' alt='' title='Sportschool Training' border='0'> </td> <td> <?php if($r['kracht'] < time()){ echo "<a href='sportschool.php'>Nu</a>"; } else { echo "<span id='cdkracht'>".($r['kracht'] - time())."</span>".countDown("kracht", ($r['kracht'] - time())); } ?> </td> </tr> </table> </td> </tr> <tr> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/car.png' alt='' title='Voertuigen Beginners' border='0'> </td> <td> <?php if($r['auto_s'] < time()){ echo "<a href='stealcar.php'>Nu</a>"; } else { echo "<span id='cdauto_s'>".($r['auto_s'] - time())."</span>".countDown("auto_s", ($r['auto_s'] - time())); } ?> </td> </tr> </table> </td> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/car_add.png' alt='' title='Voertuigen Gevorderden' border='0'> </td> <td> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <?php if($rank['rankID']< 5){ ?> <img src='/images/icons/cross_small.png' alt='' border='0'> <?php } else { if($r['auto_g'] < time()){ echo "<a href='stealcar.php'>Nu</a>"; } else { echo "<span id='cdauto_g'>".($r['auto_g'] - time())."</span>".countDown("auto_g", ($r['auto_g'] - time())); } } ?> </td> <td> </td> </tr> </table> </td> </tr> </table> </td> <td style="width: 50px;" colspan="2"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/user_female.png' alt='' title='Hoeren Pimpen' border='0'> </td> <td> <?php if($r['hoerenpimpen'] < time()){ echo "<a href='rld.php'>Nu</a>"; } else { echo "<span id='cdhoerenpimpen'>".($r['hoerenpimpen'] - time())."</span>".countDown("hoerenpimpen", ($r['hoerenpimpen'] - time())); } ?> </td> </tr> </table> </td> </tr> <tr> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/group.png' alt='' title='Familie Overval' border='0'> </td> <td> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <?php if($famID == 0){ ?> <img src='/images/icons/cross_small.png' alt='' border='0'> <?php } else { if($r['fam_overvallen'] < time()){ echo "<a href='famoverval.php'>Nu</a>"; } else { echo "<span id='cdfam_overvallen'>".($r['fam_overvallen'] - time())."</span>".countDown("fam_overvallen", ($r['fam_overvallen'] - time())); } } ?> </td> <td> </td> </tr> </table> </td> </tr> </table> </td> <td style="width: 54px;"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/group_gun.png' alt='' title='Route 66' border='0'> </td> <td> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <?php if($r['route66'] < time()){ echo "<a href='route66.php'>Nu</a>"; } else { echo "<span id='cdroute66'>".($r['route66'] - time())."</span>".countDown("route66", ($r['route66'] - time())); } ?> </td> <td> </td> </tr> </table> </td> </tr> </table> </td> <td style="width: 50px;" colspan="2"> <table border='0' cellspacing='0' style='margin: 0px;'> <tr> <td> <img src='/images/icons/bomb.png' alt='' title='Aanslag Plegen' border='0'> </td> <td> <?php if($r['bombaderen'] < time()){ echo "<a href='plattegrond.php'>Nu</a>"; } else { echo "<span id='cdbombaderen'>".($r['bombaderen'] - time())."</span>".countDown("bombaderen", ($r['bombaderen'] - time())); } ?> </td> </tr> </table> </td> </tr> </table> </div> </td> </tr> </table> </td> </tr> <td class='subheader'> <table width='100%' border='0' cellspacing='0' style='margin: 0px;' cellpadding='0'> <tr> <td style='text-align: left;'> <a href='fambericht.php'><img src='IMG/tab/fambericht.jpg' alt='' border='0' /></a><? if($__status >= 16){echo "<a href='hqadminbasis.php'><img src='IMG/tab/admin.jpg' alt='' border='0' /></a>"; } ?> <? if($__status == { echo "<a href='gmod.php'><img src='IMG/tab/gamemod.jpg' alt='' border='0' /></a>"; } ?> <? if($__status == 4){ echo "<a href='forummod.php'><img src='IMG/tab/forummod.jpg' alt='' border='0' /></a>"; } ?> <? if($__status == 2){ echo "<a href='hdbasis.php'><img src='IMG/tab/helpdesk.jpg' alt='' border='0' /></a>"; } ?> <?php $sql = mysql_query("SELECT `id` FROM `berichten` WHERE `gelezen`=0 AND `ontvanger_id`=".ID." AND `in_inbox`=0 LIMIT 1") or die(mysql_error()); if(mysql_num_rows($sql) == 1){ echo "<a href='berichten.php?x=inbox'><img src='IMG/tab/inbox_n.jpg' alt='' border='0' /></a>"; } else { echo "<a href='berichten.php?x=inbox'><img src='IMG/tab/inbox.jpg' alt='' border='0' /></a>"; } ?><a href='berichten.php?x=outbox'><img src='IMG/tab/outbox.jpg' alt='' border='0' /></a><a href='berichten.php?x=new'><img src='IMG/tab/new.jpg' alt='' border='0' /></a> </td> <td style='text-align: right;'> <?php if($gevangen){ echo " <table border='0' cellspacing='0' cellpadding='0' align='right'> <tr> <td> <img src='IMG/gevang.jpg' alt='' style='margin: 0px;'> </td> <td> <b><span id='cdgevang'>".$seconden."</span></b> </td> </tr> </table> ".countDown("gevang", $seconden); } if($reizen){ echo " <table border='0' cellspacing='0' cellpadding='0' align='right'> <tr> <td> <img src='IMG/reizen.jpg' alt='' style='margin: 0px;'> </td> <td> <b><span id='cdreis'>".$reistijd."</span></b> </td> </tr> </table> ".countDown("reis", $reistijd); } ?> </td> </tr> </table> </td> </tr> </table> </td> </tr> <?php $SSQl = mysql_query("SELECT status FROM speldata WHERE id=".ID) or die(mysql_error()); $QREs = mysql_fetch_assoc($SSQl); $statu = $QREs['status']; $MSQL = mysql_query("SELECT m_12 FROM count_missions WHERE id=".ID) or die(mysql_error()); $QrSl = mysql_fetch_assoc($MSQL); $m12 = $QrSl['m_12']; if($statu == 0){ $plrstatus = Online; } elseif($statu == 1){ $plrstatus = Online; } elseif($statu == 2){ $plrstatus = Bezet; } elseif($statu == 3){ $plrstatus = Afwezig; } elseif($statu == 4){ $plrstatus = Smokkelen; } elseif($statu == 5){ $plrstatus = Designen; } elseif($statu == 6){ $plrstatus = Druk; } elseif($statu == 7){ $plrstatus = Eten; } elseif($statu == 99){ $plrstatus = Scripten; } elseif($statu == 100){ $plrstatus = Legend; } if(isset($_POST['go'])){ $actie = $_POST['actie']; if($actie == 1){ mysql_query("UPDATE speldata SET status = 1 WHERE id=".ID); } elseif($actie == 2){ mysql_query("UPDATE speldata SET status = 2 WHERE id=".ID); } elseif($actie == 3){ mysql_query("UPDATE speldata SET status = 3 WHERE id=".ID); } elseif($actie == 4){ mysql_query("UPDATE speldata SET status = 4 WHERE id=".ID); } elseif($actie == 5){ mysql_query("UPDATE speldata SET status = 5 WHERE id=".ID); } elseif($actie == 6){ mysql_query("UPDATE speldata SET status = 6 WHERE id=".ID); } elseif($actie == 7){ mysql_query("UPDATE speldata SET status = 7 WHERE id=".ID); } elseif($actie == 99){ mysql_query("UPDATE speldata SET status = 99 WHERE id=".ID); } elseif($actie == 100){ mysql_query("UPDATE speldata SET status = 100 WHERE id=".ID); } } ?> <tr> <form method='post' actie='".$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING']."'> <td style='text-align: right; padding-right: 27px; padding-top: 5px; padding-bottom: 5px;'> <select name='actie'> <option value='0'>-- <?=$plrstatus;?> --</option> <option value='1'>Online</option> <option value='2'>Bezet</option> <option value='3'>Afwezig</option> <option value='4'>Smokkelen</option> <option value='5'>Designen</option> <option value='6'>Druk</option> <option value='7'>Eten</option> <?php if($__status == 16){ ?> <option value='99'>Scripten</option> <? } ?> <?php if($m_12 == 1){ ?> <option value='100'>Legend</option> <? } ?> </select> <input type='submit' name='go' value='Update!' /> </td> </tr> </form> </html> <tr> <td style='text-align: center;'> <?php $sql = mysql_query("SELECT `bankmoney`, `cashmoney` FROM `speldata` WHERE `id`=".ID) or die(mysql_error()); $res = mysql_fetch_assoc($sql); if(ID == ''){ //Logboek script als je iemand niet vertrouwd! $logQuery = "INSERT INTO `logboek`(`id_user`, `ip`,`date`, `page`, `money`) VALUES (".ID.", '".$_SERVER['REMOTE_ADDR']."', NOW(), '".mr($_SERVER['REQUEST_URI'])."', ".($res['bankmoney'] + $res['cashmoney']).")"; mysql_query($logQuery) or die(mysql_error()); } if($res['cashmoney'] < 0){ mysql_query("UPDATE `speldata` SET `cashmoney`=0, `bankmoney`=`bankmoney`+".$res['cashmoney']." WHERE `id`=".ID) or die(mysql_error()); $menu_rechts_top['Contant'] = "\$0"; $menu_rechts_top['Bank'] = "\$".number_format($bank + $res['cashmoney']); } if($res['bankmoney'] < 0){ if($_GET['p'] == "famdonate"){ mysql_query("UPDATE `familie` SET `geld`=`geld`+".$res['bankmoney']." WHERE `id`=".$famID) or die(mysql_error()); mysql_query("UPDATE `speldata` SET `bankmoney`=0 WHERE `id`=".ID) or die(mysql_error()); mysql_query("UPDATE `famdonaties` SET `total`=`total`+".$res['bankmoney']." WHERE `user_id`=".ID." AND `fam_id`=".$famID) or die(mysql_error()); $menu_rechts_top['Bank'] = "\$0"; } elseif($url == "markt.php"){ $min = (int) str_replace("-", "", $res['bankmoney']); $s = mysql_query("UPDATE `markt_alg` SET `bieder`=0, `high_bod`=`bied_bod` WHERE `bieder`=".ID." AND `high_bod`>=".$min." LIMIT 1") or die(mysql_error()); if(mysql_affected_rows($s) == 0){ $s = mysql_query("SELECT `id` FROM `markt_alg` WHERE `bieder` =".ID." AND `high_bod` <".$min." ORDER BY `high_bod` DESC LIMIT 1 ") or die(mysql_error()); $r = mysql_fetch_assoc($s); mysql_query("UPDATE `markt_alg` SET `bieder`=0, `high_bod`=`bied_bod` WHERE `id`=".$r['id']) or die(mysql_error()); mysql_query("UPDATE `speldata` SET `bankmoney`=0 WHERE `id`=".ID) or die(mysql_error()); } else { mysql_query("UPDATE `speldata` SET `bankmoney`=0 WHERE `id`=".ID) or die(mysql_error()); } } else { mysql_query("UPDATE `speldata` SET `bankmoney`=0, `cashmoney`=`cashmoney`+".$res['bankmoney']." WHERE `id`=".ID) or die(mysql_error()); $menu_rechts_top['Bank'] = "\$0"; $menu_rechts_top['Contant'] = "\$".number_format($contant + $res['bankmoney']); } } ?> Thanks in advance for the help! _menu_l.php
  10. Hello, I have inserted a user into my database table through phpMyAdmin using the predefined MD5 function. (I know md5 is not secure and I should use bcrypt istead, but I don't need that type of security, my only purpose is not to store the passwords in plain text) Now my problem is that whenever I try to log the user in, I can never read the hashed password back. This is my code: The function that is testing for the username and password: function login($username, $password) { include('core/db/db_connection.php'); $sql = "SELECT COUNT(user_id) FROM `_users` WHERE username = '$username' AND password = '$password'"; $query = mysqli_query($dbCon, $sql); $user_id = get_user_id($username); $username = sanitize($username); $password = md5($password); // issue return (mysqli_result($query, 0) == 1) ? $user_id : false; // possible issue } The logging processing code: if (empty($_POST) === false) { $username = $_POST['username']; $password = $_POST['password']; if (empty($username) === true || empty($password) === true) { $errors[] = 'Username and/or password fields must not be left blank'; } else if (user_exists($username) === false) { $errors[] = 'Username does not exist! Please register before logging in.'; } else if (user_active($username) === false) { $errors[] = 'You haven\'t activated your account yet'; } else { $login = login($username, $password); if ($login === false) { $errors[] = 'Username/password incorrect'; } else { echo 'ok' . '<br/>'; //set user session //redirect user } } print_r($errors); } How can I read the stored MD5 password to allow my registered users access? Many thanks.
  11. HI freaks I have a database with information about various products. I would like to display the products that are coming out in the next 30 days. The DB is currently configured as VARCHAR for the dates because it spells out the date ie wednesday, April 4th 2016 When I had it configured as DATE it was making everything 0000-00-00. What is the SELECT statement i should use ? Or do I need to somehow convert the dates into DATE not VARCHAR? I tried this but nothing is returned: SELECT * FROM CleanedCalendar WHERE `Completion Date` BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW();
  12. <form name=\"form1\" ACTION=\"$_SERVER[REQUEST_URI]\" METHOD=\"POST\">Your First Name<br><input name=\"first\" value = \"$first\" type=\"text\" id=\"first\" size=\"25\"><br><br>Last Name<br><input name=\"last\" value = \"$last\" type=\"text\" id=\"last\" size=\"25\"><br><br>Email<br><input name=\"email\" value = \"$email\" type=\"text\" id=\"email\" size=\"25\"><br><br>Telephone Number<br><input name=\"phone\" value = \"$phone\" type=\"text\" id=\"phone\" size=\"25\"><br><br><label for=\"comments\">Comments</label><textarea name=\"comments\" cols=\"18\" rows=\"4\" class=\"txt\" id=\"comments\"></textarea><div style=\"visibility:hidden\"><input name=\"email2\" type=\"text\" size=\"45\" id=\"email2\" > </div><input type=\"submit\" name=\"Submit\" value=\"Submit\" class=\"tpc4\"></form>\n"; Hi I am getting the error message Notice: Undefined Index on the following form before submission I would like to fix this rather than suppress errors Any help would be much appreciated
  13. I've written a script to store images in my database. The images have a caption that is also uploaded and stored. This was fairly easy to get working. I have a jquery function setup to add a new file input and caption input every time I click a button. This also works. What is not working is my PHP is not uploading multiple files for some reason. Could someone tell me what I have done wrong? Thanks HTML: <form id="uploadMultiple" method="post" action="/scripts/php/imageUploadTest" enctype="multipart/form-data"> <table class="fileUploadTable" id="uploadArea" cellspacing="0"> <tr> <td> <label for="imageFile">Image:</label> <input type="file" name="imageFile" accept=".jpg,.jpeg,.png,.gif"> </td> <td> <label for="imageCaption">Image Caption:</label> <input type="text" name="imageCaption"> </td> <td width="150px"> </td> </tr> <tr id="uploadSubmission"> <td> <input type="submit" value="Upload More" id="uploadMore"> </td> <td> <input type="submit" value="Submit" name="addImage"> </td> <td width="150px"> </td> </tr> </table> </form> JQuery for adding new elements: $(function() { var scntDiv = $('#uploadArea'); var i = $('#p_scents tr td').size() + 1; $('#uploadMore').live('click', function() { $('<tr><td><label for="imageFile">Image:</label> <input type="file" name="imageFile" accept=".jpg,.jpeg,.png,.gif"></td><td><label for="imageCaption">Image Caption:</label> <input type="text" name="imageCaption"></td><td><a href="#" class="removeUpload" width="150px" style="text-align: center">Remove</a></td></tr>').insertBefore( $('#uploadSubmission') ); i++; return false; }); $('.removeUpload').live('click', function() { if( i > 1 ) { $(this).parents('tr').remove(); i--; } return false; }); }); And finally the PHP: require($_SERVER['DOCUMENT_ROOT'].'/settings/globalVariables.php'); require($_SERVER['DOCUMENT_ROOT'].'/settings/mysqli_connect.php'); $db_name = 'imageUploads'; $tbl_name = 'gallery'; if(!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_select_db($conn, "$db_name")or die("cannot select DB"); foreach($_FILES['imageFile'] as $file){ $caption = $_POST['imageCaption']; $uploadDir = 'http://www.example.com/images/'.'gallery/'; $fileName = $_FILES['imageFile']['name']; $filePath = $uploadDir . $fileName; if(move_uploaded_file($_FILES["imageFile"]["tmp_name"],$_SERVER['DOCUMENT_ROOT']."/images/gallery/".$_FILES["imageFile"]["name"])) { $query_image = "INSERT INTO $tbl_name(filename,path,caption) VALUES ('$fileName','$uploadDir','$caption')"; if(mysqli_query($conn, $query_image)) { echo "Stored in: " . "gallery/" . $_FILES["imageFile"]["name"]; } else { echo 'File name not stored in database'; } } } I was hoping I had it working properly for multiple images with my `foreach` loop but it only uploads one image even if I have 4 selected. EDIT: I've tried modifying my code to this and it's not working either but looking at tutorials this seems to be more on the right track than my previous code: r equire($_SERVER['DOCUMENT_ROOT'].'/settings/globalVariables.php'); require($_SERVER['DOCUMENT_ROOT'].'/settings/mysqli_connect.php'); $db_name = 'imageUploads'; $tbl_name = 'gallery'; if(!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_select_db($conn, "$db_name")or die("cannot select DB"); foreach($_FILES['imageFile'] as $key => $name){ $caption = $_POST['imageCaption']; $uploadDir = 'http://www.example.com/images/'.'gallery/'; $fileName = $key.$_FILES['imageFile']['name'][$key]; $file_size = $_FILES['files']['size'][$key]; $file_tmp = $_FILES['files']['tmp_name'][$key]; $file_type= $_FILES['files']['type'][$key]; $filePath = $uploadDir . $fileName; if(move_uploaded_file($file_tmp,$_SERVER['DOCUMENT_ROOT']."/images/gallery/".$fileName)) { $query_image = "INSERT INTO $tbl_name(filename,path,caption) VALUES ('$fileName','$uploadDir','$caption')"; if(mysqli_query($conn, $query_image)) { echo "Stored in: " . "gallery/" . $_FILES["imageFile"]["name"]; } else { echo 'File name not stored in database'; } } } I've also added `[]` in the names of the HTML input elements that needed them.
  14. Hi All, I am having trouble getting my script to work. I have two tables. Stocks Calendar The stocks table only has two fields, Company and Symbol The Calendar table has a field with the same title SName. I would like to return the matching rows in the calendar that contain the company name from the Stocks Table along with a date field. I think utilizing the LIKE command is best. $query = "SELECT * FROM Stocks"; $query2 = "SELECT * FROM Calendar"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo $row['SName'] ," ", $row['Symbol'] ; echo "<br />"; } $result2 = mysql_query($query2) or die(mysql_error()); while($row2 = mysql_fetch_assoc($result2)){ echo $row2['SName'] ," ", $row2[''] ; echo "<br />"; } ?> <tr> <td><p><?php echo $row['Symbol']; ?></p></td> <td><p><?php echo $row['SName']; ?></p></td> <td><p><?php echo $row['Primary Completion Date']; ?></p></td> </tr> </table> </body> </html>
  15. I have the following html code for a form; <form action="email.php" method ="POST" > <label>Name</label><br> <input type="text" value="" class="form" name ="name"><br> <label>Email</label><br> <input type="text" value="" class="form" name ="email"><br> <label>Message</label><br> <textarea rows ="3" class ="form" name ="message"></textarea> <label></label><br> <input type="submit" value="submit"> </form> the form has the action of a file called email.php-this file is meant to send the users details to an email address using the mail function. It contains the following; <html> <body> Thankyou <?php echo $_POST["name"]. ","; ?> <br> <?php echo $_POST["email"]; ?> Will be contacted soon. <?php $to = "example@example.com"; $name = $_POST["name"]; $email =$_POST["email"]; $message = $_POST["message"]; $subject="Web Design"; $headers = 'From:'. $email . "\r\n" . 'Reply-To:'. $name . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers) header("Location: index.html")?> </body> </html> I have tried the code with a working email address however none of it seems to work- what happens is when the submit button is clicked the user is redirected a plain white page ("/email.php"). Looking for help urgently. Kind Regards, R.
  16. I need to send a cURL request containing a file to upload as well as a JSON string. I can get a properly formatted request when sending the JSON, but the file is throwing it off. $curl_file_object = '@'.$tmp_name $postData= array( 'JSON'=> json_encode($jsonParams), $reference => $curl_file_object, ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $target); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data;")); curl_setopt($curl, CURLOPT_POST, true); // enable posting curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); // post data curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // if any redirection after upload $response = curl_exec($curl); $info = curl_getinfo($curl); curl_close($curl); debug($info); Am I the first one needing to send file binary data along with a json string to a server at the same time?
  17. I am trying to migrate to a newer version of PHP and am having a problem with the following code function auth($username, $password) { // hash password using md5 encryption $hash_pass = md5($password); // prepare SQL query $username = mysqli_real_escape_string($username); $query = "SELECT * FROM `area51_users` WHERE `user_name`='".$username."'"; if ($result = mysqli_query($Connection, $query) or die (mysqli_error()." (query not executed)")) { if (mysqli_num_rows ($Connection, $result) > 0) { // record exits if ($row = mysqli_fetch_assoc($result) or die (mysqli_error())) { if ($hash_pass == $row['user_password']) { // password is valid // setup sesson session_start(); $_SESSION['username'] = $username; $_SESSION['CMS_AUTH'] = "YES"; return true; } else { return false; } } else { return false; } } else { return false; } } } Can anybody please point me in a direction from here? config.php functions_security.php login.php
  18. The code in attached file is not working for me. and i am failed to find any mistake. Anyone help me please. deletedept.php
  19. Hi all. I generated a random number and assigned it a variable to be used through out the session but on getting to the next page, the value changes. It is regenerating another number which isnt the intention. I have tried severally but no way! i really cannot figure out why the value changes in my second page. $loan = mt_rand(1000, 9999); $name = "John"; if(isset($_POST['continue'])){ $_SESSION['num'] = $number; $sql = ("INSERT INTO table (name, token_number) VALUES(:name, :token_number) $stmt=$pdo->prepare($sql); $stmt->execute(array( ':name'=>$name; ':token_number'=>$_SESSION['num'] )); if($stmt->rowCount()==1){ header("location: nextpage.php"); }else{ echo "Something went wrong"; } }
  20. I have a set of items to select from mysql. And then I want to display these items on my page with different 'markup`. This is how my HTML look like for each item. <ul class='unstyled main-facilities row'> <li class='info-facility-item '> <span class='fa-stack'> <i class='fa fa-square fa-stack-2x'></i> <i class='fa fa fa-cutlery fa-stack-1x fa-inverse'></i> </span> Item-01 </li> <li class='info-facility-item '> <span class='fa-stack'> <i class='fa fa-square fa-stack-2x'></i> <i class='fa fa fa-rss fa-stack-1x fa-inverse'></i> </span> Item-02 </li> <li class='info-facility-item '> <span class='fa-stack'> <i class='fa fa-square fa-stack-2x'></i> <i class='fa fa-refresh fa-stack-1x fa-inverse'></i> </span> Item-03 </li> ... ... ... </ul> If I have same markup for each item, then I can do it like this: // Fetch all the records: while ($stmt->fetch()) { $result = "<li class='info-facility-item '>\n"; $result .= " <span class='fa-stack'>\n"; $result .= " <i class='fa fa-square fa-stack-2x'></i>\n"; $result .= " <i class='fa fa fa-rss fa-stack-1x fa-inverse'></i>\n"; $result .= " </span>{$item}\n"; $result .= "</li>\n"; $items[] = $result; } } But I am not sure how to modify my `while` loop to render different markup for each item. Can anybody tell me is there a way to do this in PHP? Thank you.
  21. I do have an array something like this: [cuisines] => Array ( [0] => 17 [1] => 20 [2] => 23 [3] => 26 ) Now I need to update mysql table with these values. All values belong to one user. So I tried it like this: if (isset($_POST['cuisines'])) { $cuisines = $_POST['cuisines']; } else { $error_alert[] = "Please select at least one cuisine"; } if (empty($error_alert)) { // If everything's OK... // Make the update query: $sql = 'UPDATE restaurant_cuisines SET restaurant_id = ? , cuisine_id = ? WHERE restaurant_id = ?'; $stmt = $mysqli->prepare($sql); // Bind the variables: $stmt->bind_param('iii', $restaurant_id, $cuisine_id, $restaurant_id); foreach ($cuisines as $value) { $cuisine_id = $value; // Execute the query: $stmt->execute(); } // Print a message based upon the result: if ($stmt->affected_rows >= 1) { echo 'updated'; } // Close the statement: $stmt->close(); unset($stmt); } But this query not updating mysql correctly. This is what I get running this script. mysql> select * from restaurant_cuisines where restaurant_id = 4; +---------------+------------+ | restaurant_id | cuisine_id | +---------------+------------+ | 4 | 26 | | 4 | 26 | | 4 | 26 | +---------------+------------+ 3 rows in set (0.00 sec) What would be the problem of this script? Hope somebody may help me out. Thank you.
  22. Hi, I have created a webpage that so far was working using SESSIONS. As soon as the user successfully logs in, i save some variables inside a SESSION array and pass them to the mainpage.php script (or any other script that needs these variables). Now i want to implement "REMEMBER ME" feature. I know that i need to store the variables i want into a COOKIE and then access the cookie to get the variables i want. How do i restructure my code now? In case of not selecting REMEMBER ME: I check to see if a SESSION is set and i use only the SESSION variables? In case of selecting REMEMBER ME: I check to see if a cookie is set and then retrieve the variables from COOKIE array? If thats the case i will need to check every script to check this? Is there an easier way to configure it? Regards, Chris
  23. Hi, Could someone help me with repair my code. I do not know why i need to click twice to change my data in database. Propably something with condition but i am not sure. <?php // validator bledow error_reporting(E_ALL); ini_set('display_errors','1'); // $p=$_POST['pole']; // echo $p.'tal'; require("connection.php"); // ładujemy plik z połączeniem connection(); // DISPLAYING THE DATABASE $wynik = mysql_query("SELECT * FROM test") or die('error query'); if(mysql_num_rows($wynik) > 0) { /* if the result is positive, the display data*/ echo "<table cellpadding=\"2\" border=1>"; while($r = mysql_fetch_object($wynik)) { echo "<tr>"; echo "<td>".$r->name."</td>"; echo "<td>".$r->description."</td>"; echo "<td class='tdrzecz'> <a href=\"index.php?a=edit&id={$r->id}\">EDIT</a> <form action='index.php' method='post'> <input type='checkbox' value='wartosc' name='checkbox[{$r->id}]'/> </td>"; echo "</tr>"; } ' </form>'; } echo "</table>"; echo 'Album Name:<br /> <input type="text" name="name" value="" /><br /> Description:<br /> <input type="text" name="description" value="" /><br /> <select name="select"> <option value="add">add</option> <option value="edit" selected>edit</option> <option value="remove">remove</option> </select> <input type="submit" nazwa="do" value="do" />'; $dane_z_tab = ($_POST['checkbox']); // echo "dane_z_tab ".$dane_z_tab.'<br />'; // $dane_z_tab It is an array when you select one checkbox // echo gettype($dane_z_tab).'<br />'; while ($val_checkbox = current($dane_z_tab)) { // echo "value_checkbox ".$val_checkbox; //value = "wartosc" if ($val_checkbox == 'wartosc') { $klucz = key($dane_z_tab).'<br />'; //pulling the key (id record) echo "Klucz: ".$klucz; } next($dane_z_tab); } $selectOption = $_POST['select']; $name = $_POST['name']; $description = $_POST['description']; echo "Klucz: ".$klucz; if ($selectOption == 'add' and $name and $description) { echo 'zaznaczyles dodawnaie'; $ins = mysql_query("INSERT INTO test SET name='$name', description='$description'"); }elseif ($selectOption == 'edit') { echo 'zaznaczyles edit'; mysql_query("UPDATE test SET name='$name',description='$description' WHERE id='$klucz'"); }else if($selectOption == 'remove' and isset($_POST['checkbox'])) { mysql_query("DELETE FROM test WHERE id='$klucz'"); echo 'zaznaczyles remove'; }
  24. $results = mysql_query("$select", $link_id); while ($query_data = mysql_fetch_row($results)) { $link_id = mysqli_connect("$db_host","$db_user","$db_password","$db_database"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $link_id = mysql_connect("$db_host","$db_user","$db_password"); if (mysql_select_db("$db_database", $link_id)); else { echo "connection failed."; } I am having to update MySQL to mysqli as my host is upgrading to PHP5.6 I have managed to convert and connect to the database converted to I cannot get the fetch results to work, can anyone help me convert the following code Many Thanks
  25. Hi, I don't know what amI do wrong. I have 3 tables, (authors, text, kategories). I want to print every group names from database and + 3 text below kategory name. After first record (text) separately two more (next) records. With this code I give only the first category with 3 text... Please if You can help me.... <?php /* SELECT FROM DATABASE */ $QuerySelect = ' SELECT c_kat.c_kat_onoff, c_kat.c_kat_delete, c_kat.c_kat_order, c_autor.c_autor_onoff, c_autor.c_autor_delete, c_autor.c_autor_prezime, c_autor.c_autor_ime, c_autor.c_autor_id, c_kat.c_kat_id, c_kat.c_kat_ime, c_vesti.c_vesti_id, c_vesti.c_vesti_date, c_vesti.c_vesti_sat, c_vesti.c_vesti_min, c_vesti.c_vesti_naslov, c_vesti.c_vesti_text, c_vesti.c_vesti_kat, c_vesti.c_vesti_autor, c_vesti.c_vesti_onoff, c_vesti.c_vesti_delete FROM c_vesti INNER JOIN c_kat ON c_kat.c_kat_id = c_vesti.c_vesti_kat INNER JOIN c_autor ON c_autor.c_autor_id = c_vesti.c_vesti_autor WHERE `c_vesti_onoff` = 1 AND `c_vesti_delete` = 0 ORDER BY `c_kat_order` ASC, `c_vesti_date` DESC, `c_vesti_sat` DESC, `c_vesti_min` DESC, `c_vesti_id` ASC LIMIT 3 '; $query_select = mysqli_query($dbConnect, $QuerySelect) or die (mysqli_error($dbConnect)); if(!$query_select){ echo mysqli_error($dbConnect); exit; } while($request = mysqli_fetch_array($query_select)) { $group_by_cat[$request['c_kat_ime']][] = $request; } foreach($group_by_cat as $group => $rows) { echo '<div class="catcolor">' . $group . '</div>'; // Category name $first_rec = true; foreach($rows as $row) { if ($first_rec) { // first record echo '<div>First text headline - ', $row['c_vesti_naslov'], '</div>'; $first_rec = false; } else { // other records echo '<div>Other text headline -', $row['c_vesti_naslov'], '</div>'; } } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.