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. Hi I'm trying to run a cron here to remove profile pictures delete users delete private messages delete messages but I need some help to make my code more clean and effective <?php include("chat_code_header.php"); //// Delete profile pictures and users id older than 30 days//// $querybd = "SELECT Username, last_online, pprofilepic FROM Users2 WHERE last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"; $resultbd = mysql_query($querybd) or die(mysql_error()); $users = array(); while($rowbd = mysql_fetch_array($resultbd)){ if ($rowbd['Username'] != '') $users[] = $rowbd['Username']; if($rowbd['pprofilepic'] == ""){}else{ $pprofilepic = realpath($rowbd['pprofilepic']); print "\n Pictures Removed:\n" . $pprofilepic . "\n"; unlink($pprofilepic); } } $list = implode('; ', $users); if($list == ""){printf ("Nobody Removed\n");}else{ print "\n Users Removed:\n" . $list . "\n"; } printf("Users Deleted: %d\n", mysql_affected_rows()); $sqldel = "DELETE Users2, StringyChat, pm, namechanges, kicksamount, broadcast, timeban FROM Users2 LEFT JOIN StringyChat ON Users2.mxitid = StringyChat.StringyChat_ip LEFT JOIN pm ON Users2.mxitid = pm.mxitid LEFT JOIN namechanges ON Users2.mxitid = namechanges.userid LEFT JOIN kicksamount ON Users2.mxitid = kicksamount.mxitid LEFT JOIN broadcast ON Users2.mxitid = broadcast.mxitid LEFT JOIN timeban ON Users2.mxitid = timeban.mxitid WHERE Users2.last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"; mysql_query($sqldel) or die("Error: ".mysql_error()); //// end of removal/// //// removal of messages//// $query = "DELETE FROM StringyChat WHERE StringyChat_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))"; mysql_query($query); printf("Messages deleted: %d\n", mysql_affected_rows()); //// removal of private messages//// $query1 = "DELETE FROM pm WHERE time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))"; mysql_query($query1); printf("Private Messages deleted: %d\n", mysql_affected_rows()); ?>
  2. So i made a login page, but whenever i enter right, wrong, or no password at all, it always displays wrong password. I've been trying to fix it for hours, but I just can't seem to find the error. It's like it's skipping if the password is right statement and goes straight through the else statment. <?php $connection = mysql_connect("com-db-02.student-cit.local","***","***") or die (mysql_error()); if ($connection) echo "Connection successful"; else echo "Connection failed"; $db = mysql_select_db("TEAM20") or die (mysql_error()); ?> <?php $_SESSION['customeremail'] = $_POST['user']; $_SESSION['password'] = $_POST['password']; function signIn() { session_start(); if(!empty($_POST['user'])) { $query = mysql_query("SELECT * FROM customer where customeremail = '$_POST[user]' AND password = '$_POST[password]'"); $row = mysql_fetch_array($query); if(!empty($row['customeremail']) AND !empty($row['password'])) { $_SESSION['customeremail'] = $row['customeremail']; getCustDetails(); echo "Successfully login to user profile page.."; echo "<a href=userlogin.php>Profile</a>"; } else { echo "Sorry... YOU ENTERED WRONG ID AND PASSWORD"; echo "<a href=login.html>Try Again</a>"; } } } function getCustDetails() { $queryId = mysql_query("SELECT customerID, firstname FROM Customer WHERE customeremail = '$_POST[user]'"); while($rowId = mysql_fetch_array($queryId)) { $_SESSION['customerID'] = $rowId['customerID']; $_SESSION['firstname'] = $rowId['firstname']; } echo "Code: ".$_SESSION['customerID']; echo "Name: ".$_SESSION['firstname']; } if(isset($_POST['submit'])) { signIn(); } ?>
  3. I'm trying to out put all Crelly Slider Alias's within Redux Framework Options in a Dropdown Select. I must confess i'm a novice at PHP ... I've attached the code from within Crelly Slider to show how it outputs the Alias names and i've also attached the Redux Code for the dropdown with an existing select .. I somehow need to output a list of all Crelly Alias's into 'options' => array( 'asc' => 'Ascending', 'desc' => 'Descending' ), Obviously replacing the exisiting options. Here is the full Crelly Output <?php global $wpdb; $sliders = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'crellyslider_sliders'); if(!$sliders) { echo '<div class="cs-no-sliders">'; _e('No Sliders found. Please add a new one.', 'crellyslider'); echo '</div>'; echo '<br /><br />'; } else { ?> <table class="cs-sliders-list cs-table"> <thead> <tr> <th colspan="5"><?php _e('Sliders List', 'crellyslider'); ?></th> </tr> </thead> <tbody> <tr class="cs-table-header"> <td><?php _e('ID', 'crellyslider'); ?></td> <td><?php _e('Name', 'crellyslider'); ?></td> <td><?php _e('Alias', 'crellyslider'); ?></td> <td><?php _e('Shortcode', 'crellyslider'); ?></td> <td><?php _e('Actions', 'crellyslider'); ?></td> </tr> <?php foreach($sliders as $slider) { echo '<tr>'; echo '<td>' . $slider->id . '</td>'; echo '<td><a href="?page=crellyslider&view=edit&id=' . $slider->id . '">' . $slider->name . '</a></td>'; echo '<td>' . $slider->alias . '</td>'; echo '<td>[crellyslider alias="' . $slider->alias . '"]</td>'; echo '<td> <a class="cs-edit-slider cs-button cs-button cs-is-success" href="?page=crellyslider&view=edit&id=' . $slider->id . '">' . __('Edit Slider', 'crellyslider') . '</a> <a class="cs-delete-slider cs-button cs-button cs-is-danger" href="javascript:void(0)" data-delete="' . $slider->id . '">' . __('Delete Slider', 'crellyslider') . '</a> </td>'; echo '</tr>'; } ?> </tbody> </table> <?php } ?> <br /> <a class="cs-button cs-is-primary cs-add-slider" href="?page=crellyslider&view=add"><?php _e('Add Slider', 'crellyslider'); ?></a> And my Redux Option array( 'id' => 'alias_select', 'type' => 'select', 'title' => __( 'Alias Select', 'ultra-web-admin' ), 'desc' => __( 'Select Slider Alias.', 'ultra-web-admin' ), 'options' => array( 'asc' => 'Ascending', 'desc' => 'Descending' ), 'default' => 'asc' ), I would be really grateful if anyone could assist me . Thank you !
  4. I am making a Railway Search website for University Project and i want to implement advanced Search functionality but as i am new to this field i need help from you guys please help me to create that function here i am describing : I have 3 Database with relevant fields one is Station db one is Train db and third is train timetable Db, Trains i have added using Station ID with arrival departure timings. now how can i implement search code to get In-between all trains results which user queried for example we have 5 stations A B C D E, 3 train going to A to E one is without any stopping between A to E second is stopping only C and third is stopping all. if any one have queried about A to E then all 3 trains should be displayed, if A to C queried then 2 trains should be displayed and if A to D then only one train should be displayed. Please help me to sort out this search Thanks.
  5. Hello, I'm having a bit of trouble interpolating Bootstrap HTML from database rows. It's coming out kind of right, but I have font-awesome flags popping up everywhere, and my footer doesn't stretch the entire screen. Kind of like a div isn't being closed. I'd appreciate any help offered. Every three items is a row. There are three columns per row. PHP CODE foreach($retrievedListings as $key => $val) { if($key === 0) { echo '<div class="row"> <div class="col-lg-4"> <div class="column-1"> <h4 style="color:darkblue;"><i style="color:yellow;" class="fa fa-star"></i> '.htmlentities($retrievedListings[$key]['title']).'</h4> <p>By <strong>'.$retrievedListings[$key]['username'].'</strong><br/> '.htmlentities($retrievedListings[$key]['intro']).'</p> <p class="word"><i class="fa fa-flag flag-button"></i>'; $tagsArr = explode(',', $retrievedListings[$key]['tags']); foreach($tagsArr as $tag) { echo '<span class="label label-default label-buffer"><a>'.htmlentities($tag).'</a></span>'; } echo '</p> </div> </div>'; }elseif($key % 3 != 0) { echo '<div class="col-lg-4"> <div class="column-1"> <h4 style="color:darkblue;"><i style="color:yellow;" class="fa fa-star"></i> '.htmlentities($retrievedListings[$key]['title']).'</h4> <p>By <strong>'.$retrievedListings[$key]['username'].'</strong><br/> '.$retrievedListings[$key]['intro'].'</p> <p class="word"><i class="fa fa-flag flag-button">'; $tagsArr = explode(',', $retrievedListings[$key]['tags']); foreach($tagsArr as $tag) { echo '<span class="label label-default label-buffer"><a>'.htmlentities($tag).'</a></span>'; } echo '</p> </div> </div>'; }else{ echo '</div> <div class="row"> <div class="col-lg-4"> <div class="column-1"> <h4>'.htmlentities($retrievedListings[$key]['title']).'</h4> <p>By <strong>'.$retrievedListings[$key]['username'].'</strong> <br/> '.htmlentities($retrievedListings[$key]['intro']).'</p> <p class="word"><strong>Tags :</strong> <span>One,Two,Three</span></p> </div> </div>'; } } What I'm trying to interpolate: <div class="row"> <div class="col-lg-4"> <div class="column-1"> <h4 style="color:darkblue;"><i style="color:yellow;" class="fa fa-star"></i> Lorem Ipsum</h4> <p>By <strong>Ipsum is simply</strong><br/> dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took.</p> <p class="word"><i class="fa fa-flag flag-button"></i><span class="label label-default label-buffer">playstation 4</span> <span class="label label-default label-buffer">playstation 4</span><span class="label label-default label-buffer">playstation 4</span> </p> </div> </div> <div class="col-lg-4"> <div class="column-1"> <h4 style="color:darkblue;"><i style="color:yellow;" class="fa fa-star"></i> Lorem Ipsum</h4> <p>By <strong>Ipsum is simply</strong><br/> dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took.</p> <p class="word"><i class="fa fa-flag flag-button"></i><span class="label label-default label-buffer">playstation 4</span> <span class="label label-default label-buffer">playstation 4</span><span class="label label-default label-buffer">playstation 4</span> </p> </div> </div> <div class="col-lg-4"> <div class="column-1"> <h4 style="color:darkblue;"><i style="color:yellow;" class="fa fa-star"></i> Lorem Ipsum</h4> <p>By <strong>Ipsum is simply</strong><br/> dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took.</p> <p class="word"><i class="fa fa-flag flag-button"></i><span class="label label-default label-buffer">playstation 4</span> <span class="label label-default label-buffer">playstation 4</span><span class="label label-default label-buffer">playstation 4</span> </p> </div> </div> </div> Thanks, Jeremy.
  6. Hi Mate, i need help with my mysql query.. SELECT * FROM `schedules` WHERE `clientID`=''; it doesn't select any values having an empty clientID... there are rows on my database that i need to select that has an empty clientID and using this statement does not return any value... but if i use `clientID`!='' it works fine, it returns all the data having clientID. Any help is highly appreciated. Thank you in advance. Neil
  7. I am getting this error: syntax error, unexpected '}' @extends('layouts.master') @section('scripts') <script type="text/javascript" src="{!! asset('js/status.min.js') !!}"></script> @stop @section('content') {!! csrf_field() !!} @if (count($errors) > 0) <div class="alert alert-danger"> <strong>Whoops!</strong> There were some problems with your input.<br><br> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif <!-- Using laravel session --> @if(Session::has('message')) <!-- Checking if session has a variable called message. --> <div class="alert alert-info"> <li> {{ Session::get('message') }} </li> <!--if true -print the message from the insert_posts variable. --> </div> @endif {{-- You have a $user variable available representing the current Auth::user(); --}} <p>Hello, {{ $user->name }}.</p> {{-- This user has a profile whose properties you can also display --}} <p>Goals: {{ $user->profile->goals }}</p> {{-- You can also drill down to the profile's expectations --}} <p>Expectations</p> <ul class="profile-list"> @foreach($user->profile->expectations as $expectation) <li class="profile-list-item">{!! $expectation->name !!}</li> @endforeach </ul> <p><b> this is other users you may want to follow: </br></p> <ul> @foreach($mutuals as $mutual) <!-- hub/{{$mutual->user->id}} It goes to the user that matches the value of $mutual criteria. and then it goes and gets its id.This is sent to the controller for further handling.Check page source to see id's numbers. --> <!-- In the href - Passing the user to your controller --> <br><li><a href="{{URL::to('hub', [$mutual->user->id])}}" class="button button-3d" name="make_follow">Follow User</a> {!! $mutual->user->name; !!} <!-- I access the user's name property --> </li> @endforeach </ul> <form action="{{ route('createPost') }}" method="post"> <!--the form action is the method in a route called createPost --> @if(isset($message)) <!-- if the var exist and have a value it would be printed. It is used for all the notifications in this page.--> {{ $message }} @endif <br> <!-- only when a post has been submitted the varible value will show. --> <!-- telling the form the info go to this route (url). almost equal form action ="samePage" --> {!! Form::hidden('post') !!} {!! csrf_field() !!} <div class=contentWrap> <div class="test" placeholder="How's your fitness going?..." contenteditable="true"></div> </div> <div class=icons> <img alt="heart" src="http://icons.iconarchive.com/icons/succodesign/love-is-in-the-web/512/heart-icon.png"> </div> <button> Post to profile </button> <div class="errors"> </div> </form> <!-- script to check if user typed anything in the textbox before submit. both .text() and .html() return strings. It's testing if the string length is zero. trim is for removing whitespaces before and after a string. the 'submit' event is needed since it's a submit button. --> <div class="own_posts"> <p> here are your latest posts:</p> <!-- I think I should create foreach loop to iterate over each post and show it here. --> </div> <br><br> <div class="following_posts"> <p> Posts from people you're following: <p> <!-- Iterate over the followee's posts with a foreach loop: the first parameter the foreach gets is the array expression. Second element: On each iteration, the value of the current element (which is a post) is assigned to $value (second element) and the internal array pointer is advanced by one. Next: within these: {{!! !!}} --> @foreach ($get_followee_posts as $post) <form action="/html/tags/html_form_tag_action.cfm" method="post"> <textarea name="comments" id="comments" style="width:96%;height:90px;background-color:white;color:black;border:none;padding:2%;font:22px/30px sans-serif;"> {!! $post->full_post !!} </textarea> </form> @endforeach </div> @stop I tried with 2 editors and netbeans to figure why. I also use blade syntax of laravel.
  8. Trying to add a product search bar to Wordpress admin bar backend that will do Woocommerce product search. It will be located in the backend Admin Menu bar a top so that no matter where you are in back end it will allow to search woo's products. I am close but faulting at small stumbling block. When trying to use the search it is defaulting to post search instead of products. //Add Search To Admin Bar function boatparts_admin_bar_form() { global $wp_admin_bar; $wp_admin_bar->add_menu(array( 'id' => 'boatparts_admin_bar_form', 'parent' => 'top-secondary', 'title' => '<form method="get" action="'.get_site_url().'/wp-admin/edit.php?post_type=product"> <input name="s" type="text" style="height:20px;margin:5px 0;line-height:1em;"/> <input type="submit" style="height:18px;vertical-align:top;margin:5px 0;padding:0 2px;" value="Search Products"/> </form>' )); } add_action('admin_bar_menu', 'boatparts_admin_bar_form'); Have it in my child theme's function.php. Driving me nuts trying to figure it out.
  9. Hello there.. I have a problem when loading comment from my database.. Here are working scripts which does not query the message/comment from database.. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "responder"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //query the user table $sql = "SELECT * FROM user"; $result = $conn->query($sql); //get comment from array $comment = $_GET['comment'] + 1; //I want to replace below array comment with my database comment $ar = array( "Hello there.", "How are you?" ); require_once("facebook.php"); $config = array(); $config['appId'] = 'myapp'; $config['secret'] = 'mysecret'; $config['fileUpload'] = false; $fb = new Facebook($config); if ($result->num_rows > 0) { foreach ($result as $key) { $params = array( //long-live-token "access_token" => $key['offense_token'], //comment //need to replace this from database "message" => $ar[$comment], ); if($comment<10) { try { $ret = $fb->api('/my-comment-id/comments', 'POST', $params); echo 'Successfully posted to Facebook'; sleep(5); header('Location: set-comment.php?comment='.$comment); } catch(Exception $e) { echo $e->getMessage(); } } else{ echo "done"."<br>"; } } } ?> Above scripts working fine without querying from my database So my issues now, how do I query and loop each comment from database? Here my comment/message table.. TQ
  10. I am building a website about Doctor who, and I want to post various quotes from a database, when I wrote the select-query, I got the following error: Quotes Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /customers/e/a/c/doctorwhofans.be/httpd.www/test/Content/Quotes.php on line 106 (which is the one with the while expression). <?php //verbinding met de database require("./connect.php"); //select-query schrijven en uitvoeren $sql = " select * from QuotesTabel"; $result = mysql_query($sql); //alle records weergeven (terwijl er rijen gevonden worden. while ($row = mysql_fetch_assoc($result)) { //toon foto met info require("./ToonFoto.php"); } ?> Can someone help me please?
  11. Hi! i want show my project designed as a ORM that directly manipulate Database Schema aim a class as model https://github.com/Javanile/SchemaDB please give me more feedback and test reports thkx
  12. Edit: upload blob not blog I would like to use the following code to crop images that will be uploaded to mySql with PHP. I just cannot figure out how to call the blob so I can use it. Can someone help me with this? Using the code from here: http://hongkhanh.github.io/cropbox/ HTML <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Crop Box</title> <link rel="stylesheet" href="style.css" type="text/css" /> <style> .container { position: absolute; top: 10%; left: 10%; right: 0; bottom: 0; } .action { width: 400px; height: 30px; margin: 10px 0; } .cropped>img { margin-right: 10px; border:1px solid green: } </style> </head> <body> <script src="../cropbox.js"></script> <div class="container"> <div class="imageBox"> <div class="thumbBox"></div> <div class="spinner" style="display: none">Loading...</div> </div> <div class="action"> <input type="file" id="file" style="float:left; width: 250px"> <input type="button" id="btnCrop" value="Crop" style="float: right"> <input type="button" id="btnZoomIn" value="+" style="float: right"> <input type="button" id="btnZoomOut" value="-" style="float: right"> </div> <div class="cropped"></div> <script type="text/javascript"> window.onload = function() { var options = { imageBox: '.imageBox', thumbBox: '.thumbBox', spinner: '.spinner', imgSrc: 'avatar.png' } var cropper = new cropbox(options); document.querySelector('#file').addEventListener('change', function(){ var reader = new FileReader(); reader.onload = function(e) { options.imgSrc = e.target.result; cropper = new cropbox(options); } reader.readAsDataURL(this.files[0]); this.files = []; }) document.querySelector('#btnCrop').addEventListener('click', function(){ var img = cropper.getDataURL(); document.querySelector('.cropped').innerHTML += '<img src="'+img+'">'; }) document.querySelector('#btnZoomIn').addEventListener('click', function(){ cropper.zoomIn(); }) document.querySelector('#btnZoomOut').addEventListener('click', function(){ cropper.zoomOut(); }) }; </script> </body> </html> /** * Created by ezgoing on 14/9/2014. */ 'use strict'; var cropbox = function(options){ var el = document.querySelector(options.imageBox), obj = { state : {}, ratio : 1, options : options, imageBox : el, thumbBox : el.querySelector(options.thumbBox), spinner : el.querySelector(options.spinner), image : new Image(), getDataURL: function () { var width = this.thumbBox.clientWidth, height = this.thumbBox.clientHeight, canvas = document.createElement("canvas"), dim = el.style.backgroundPosition.split(' '), size = el.style.backgroundSize.split(' '), dx = parseInt(dim[0]) - el.clientWidth/2 + width/2, dy = parseInt(dim[1]) - el.clientHeight/2 + height/2, dw = parseInt(size[0]), dh = parseInt(size[1]), sh = parseInt(this.image.height), sw = parseInt(this.image.width); canvas.width = width; canvas.height = height; var context = canvas.getContext("2d"); context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh); var imageData = canvas.toDataURL('image/png'); return imageData; }, getBlob: function() { var imageData = this.getDataURL(); var b64 = imageData.replace('data:image/png;base64,',''); var binary = atob(b64); var array = []; for (var i = 0; i < binary.length; i++) { array.push(binary.charCodeAt(i)); } return new Blob([new Uint8Array(array)], {type: 'image/png'}); }, zoomIn: function () { this.ratio*=1.1; setBackground(); }, zoomOut: function () { this.ratio*=0.9; setBackground(); } }, attachEvent = function(node, event, cb) { if (node.attachEvent) node.attachEvent('on'+event, cb); else if (node.addEventListener) node.addEventListener(event, cb); }, detachEvent = function(node, event, cb) { if(node.detachEvent) { node.detachEvent('on'+event, cb); } else if(node.removeEventListener) { node.removeEventListener(event, render); } }, stopEvent = function (e) { if(window.event) e.cancelBubble = true; else e.stopImmediatePropagation(); }, setBackground = function() { var w = parseInt(obj.image.width)*obj.ratio; var h = parseInt(obj.image.height)*obj.ratio; var pw = (el.clientWidth - w) / 2; var ph = (el.clientHeight - h) / 2; el.setAttribute('style', 'background-image: url(' + obj.image.src + '); ' + 'background-size: ' + w +'px ' + h + 'px; ' + 'background-position: ' + pw + 'px ' + ph + 'px; ' + 'background-repeat: no-repeat'); }, imgMouseDown = function(e) { stopEvent(e); obj.state.dragable = true; obj.state.mouseX = e.clientX; obj.state.mouseY = e.clientY; }, imgMouseMove = function(e) { stopEvent(e); if (obj.state.dragable) { var x = e.clientX - obj.state.mouseX; var y = e.clientY - obj.state.mouseY; var bg = el.style.backgroundPosition.split(' '); var bgX = x + parseInt(bg[0]); var bgY = y + parseInt(bg[1]); el.style.backgroundPosition = bgX +'px ' + bgY + 'px'; obj.state.mouseX = e.clientX; obj.state.mouseY = e.clientY; } }, imgMouseUp = function(e) { stopEvent(e); obj.state.dragable = false; }, zoomImage = function(e) { var evt=window.event || e; var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta; delta > -120 ? obj.ratio*=1.1 : obj.ratio*=0.9; setBackground(); } obj.spinner.style.display = 'block'; obj.image.onload = function() { obj.spinner.style.display = 'none'; setBackground(); attachEvent(el, 'mousedown', imgMouseDown); attachEvent(el, 'mousemove', imgMouseMove); attachEvent(document.body, 'mouseup', imgMouseUp); var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; attachEvent(el, mousewheel, zoomImage); }; obj.image.src = options.imgSrc; attachEvent(el, 'DOMNodeRemoved', function(){detachEvent(document.body, 'DOMNodeRemoved', imgMouseUp)}); return obj; };
  13. /* process_login.php*/ 2. 3.<?php 4.include_once 'db_connect.php'; 5.include_once 'functions.php'; 6. 7.sec_session_start(); // Our custom secure way of starting a PHP session. 8. 9.if (isset($_POST['email'], $_POST['p'])) { 10. $email = $_POST['email']; 11. $password = $_POST['p']; // The hashed password. 12. 13. if (login($email, $password, $mysqli) == true) { 14. // Login success 15. header('Location: ../protected_page.php'); 16. } else { 17. // Login failed 18. header('Location: ../index.php?error=1'); 19. } 20.} else { 21. // The correct POST variables were not sent to this page. 22. echo 'Invalid Request'; 23.} /*INDEX>PHP*/ 2. 3.<?php 4.error_reporting(E_ALL); 5.ini_set("display_errors",1); 6. 7.include_once 'includes/db_connect.php'; 8.include_once 'includes/functions.php'; 9. 10.sec_session_start(); 11. 12.if (login_check($mysqli) == true) { 13. $logged = 'in'; 14.} else { 15. $logged = 'out'; 16.} 17.?> 18.<!DOCTYPE html> 19.<html> 20. <head> 21. <title>Secure Login: Log In</title> 22. <link rel="stylesheet" href="styles/main.css" /> 23. <script type="text/JavaScript" src="js/sha512.js"></script> 24. <script type="text/JavaScript" src="js/forms.js"></script> 25. </head> 26. <body> 27. <?php 28. if (isset($_GET['error'])) { 29. echo '<p class="error">Error Logging In!</p>'; 30. } 31. ?> 32. <form action="includes/process_login.php" method="post" name="login_form"> 33. Email: <input type="text" name="email" /> 34. Password: <input type="password" 35. name="password" 36. id="password"/> 37. <input type="button" 38. value="Login" 39. onclick="formhash(this.form, this.form.password);" /> 40. </form> 41. 42.<?php 43. if (login_check($mysqli) == true) { 44. echo '<p>Currently logged ' . $logged . ' as ' . htmlentities($_SESSION['username']) . '.</p>'; 45. 46. echo '<p>Do you want to change user? <a href="includes/logout.php">Log out</a>.</p>'; 47. } else { 48. echo '<p>Currently logged ' . $logged . '.</p>'; 49. echo "<p>If you don't have a login, please <a href='register.php'>register</a></p>"; 50. } 51.?> 52. </body> 53.</html> hi I have been building this secure login system but for some reson the submit button on my index page juust is not working once an email and password is entered and you click on submit absolutely nothing happens no form reset no login no errors nothing can anyone see why at all please........
  14. <?php include_once 'psl-config.php'; function sec_session_start() { $session_name = 'sec_session_id'; // Set a custom session name $secure = true; // This stops JavaScript being able to access the session id. $httponly = true; // Forces sessions to only use cookies. if (ini_set('session.use_only_cookies', 1) === FALSE) { header("Location: ../error.php?err=Could not initiate a safe session (ini_set)"); exit(); } // Gets current cookies params. $cookieParams = session_get_cookie_params(); session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); // Sets the session name to the one set above. session_name($session_name); session_start(); // Start the PHP session session_regenerate_id(true); // regenerated the session, delete the old one. } function login($email, $password, $mysqli) { // Using prepared statements means that SQL injection is not possible. if ($stmt = $mysqli->prepare("SELECT id, username, password FROM members WHERE email = ? LIMIT 1")) { $stmt->bind_param('s', $email); // Bind "$email" to parameter. $stmt->execute(); // Execute the prepared query. $stmt->store_result(); // get variables from result. $stmt->bind_result($user_id, $username, $db_password); $stmt->fetch(); if ($stmt->num_rows == 1) { // If the user exists we check if the account is locked // from too many login attempts if (checkbrute($user_id, $mysqli) == true) { // Account is locked // Send an email to user saying their account is locked return false; } else { // Check if the password in the database matches // the password the user submitted. We are using // the password_verify function to avoid timing attacks. if (password_verify($password, $db_password) { // Password is correct! // Get the user-agent string of the user. $user_browser = $_SERVER['HTTP_USER_AGENT']; // XSS protection as we might print this value $user_id = preg_replace("/[^0-9]+/", "", $user_id); $_SESSION['user_id'] = $user_id; // XSS protection as we might print this value $username = preg_replace("/[^a-zA-Z0-9_\-]+/", "", $username); $_SESSION['username'] = $username; $_SESSION['login_string'] = hash('sha512', $db_password . $user_browser); // Login successful. return true; } else { // Password is not correct // We record this attempt in the database $now = time(); $mysqli->query("INSERT INTO login_attempts(user_id, time) VALUES ('$user_id', '$now')"); return false; } } } else { // No user exists. return false; } } } I have been working on a secure login system for my site, I feel that I have been doing well so far but now I am getting a parse error coming from my functions.php include file, the error code I am getting is: so here is the code from functions.php i have included everything from line 1 of the functions.php file to the end of the problem funxtion
  15. Hi, I am absolutly beginner in PHP, AJAX. In my Wordpress page I have following scene: 1. input box for name 2. combobox from country-> combo for cities depend of selected country Button for search in MySQL database After submit the database return result in a table (user, country, city, mobile, email, etc.) with 2 editable (mobile, email) input column and I put Update button in every row. My questions: 1) If I change one data on the editable column how can I know the number of row? 2) How can I run the update script without refresh page? Thanks for your answer. //UserInfo-modify.php <?php include_once('db.php'); $name = $_POST['nev']; $country = $_POST['megye']; $error = ""; $city = ""; $nodata = ""; $ID = 0; if (($country=="Bács-Kiskun")||($country=="Baranya")||($country=="Békés")||($country=="Borsod-Abaúj-Zemplén")||($country=="Csongrád")|| ($country=="Fejér")||($country=="Győr-Moson-Sopron")||($country=="Hajdú-Bihar")||($country=="Heves")||($country=="Jász-Nagykun-Szolnok")|| ($country=="Komárom-Esztergom")||($country=="Nógrád")||($country=="Pest")||($country=="Somogy")||($country=="Szabolcs-Szatmár-Bereg")|| ($country=="Tolna")||($country=="Vas")||($country=="Veszprém")||($country=="Zala")) { $city = $_POST['telepules']; if ($city=="---") $error = "-city"; } else { $error = "-country-city"; } mysqli_set_charset($conn,"utf8"); if (($city!="") AND ($name!="")) { $query = mysqli_query($conn,"SELECT nev,kor,megye,telepules,utca,mobil,email FROM `nrqadatr` WHERE nev='$name' AND telepules='$city'") or die("userinfo-modify-36 ".mysqli_error($conn));} else if (($city=="") AND ($name=="")) { $nodata = '1'; echo "Name and city = 0!"; } else if (($city!="") AND ($name=="")) { $query = mysqli_query($conn,"SELECT nev,kor,megye,telepules,utca,mobil,email FROM `nrqadatr` WHERE telepules='$city'") or die("userinfo-modify-45 ".mysqli_error($conn));} else if (($city=="") AND ($name!="")) {$query = mysqli_query($conn,"SELECT nev,kor,megye,telepules,utca,mobil,email FROM `nrqadatr` WHERE nev='$name'") or die("userinfo-modify-49 ".mysqli_error($conn));} if ($nodata!='1') { $rowcount=mysqli_num_rows($query); if ($rowcount>0) { echo '<table>'; $arrayofrows = array(); echo ' <table border=1> <tr style="background-color:#EFFBFB; font-weight:bold; border: 1px solid black;"> <td style="font-size:14px;">ID</td> <td style="font-size:14px;">Name</td> <td style="font-size:14px;">City</td> <td style="font-size:14px;">Age</td> <td style="font-size:14px;">Address</td> <td style="font-size:14px;">Mobil</td> <td style="font-size:14px;">E-mail</td> <td style="font-size:14px;">Operation</td> </tr>'; } else echo "\r\n<B><font color='red'>No data //my_script.js $("#sub").click( function() { $.post( $("#myForm").attr("action"), $("#myForm :input").serializeArray(), function(info) { $("#result").html(info); }); clearInput(); }); $("#myForm").submit( function() { return false; }); function clearInput() { $("#myForm :input").each( function() { $(this).val(''); }); } ."; while ($data = mysqli_fetch_array($query)) { $ID = $ID+1; $data_nev=$data["nev"]; echo ' <tr style="background-color:#EFFBFB; border: 1px solid black;"> <td><input type="radio" name="$kivalasztott_sor" value="AG"></td> <td style="font-size:14px;">'.$data["nev"].'</td> <td style="font-size:14px;">'.$data["telepules"].'</td> <td style="font-size:14px;">'.$data["kor"].'</td> <td style="font-size:14px;">'.$data["utca"].'</td> <td><input type="text" value='.$data["mobil"].'></td> <td><input type="text" value='.$data["email"].'></td> <td onclick="cellOnclick()"><a href="#" onclick="linkOnclick()" style="text-decoration: none;"> <input type=button value="UPDATE" myFunction(this); return false;"></button></td> </tr>'; } echo '</table>'; } unset($name); unset($kor); unset($country); unset($error); unset($city); unset($nodata); unset ($data_nev); ?> //Wordpress (main) page [insert_php] include '/select_list_cities.php'; [/insert_php] <html><head><meta charset="utf-8" /><script src="/ajax_select_cities.js" type="text/javascript"></script> </head><body><form id="myForm" action="/userInfo-modify.php" method="post"> Name*:<br><input type="text" name="nev"> <p> [insert_php] echo $re_html;[/insert_php]<br class="clear" /> <br class="clear" /> <button id="sub">Search</button> <br><br></form> <span id="result"></span> <div id="data"><?php echo $result; ?></div> <script type="text/javascript" src=" http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.1.min.js"></script> <script src="/my_script.js" type="text/javascript"></script> </body> </html>
  16. webdevdea

    Json help

    at my link http://dandewebwonders.com/BBProject%204/index.php when you click on players you see the error.. this is what i need to do .. change data type from html to json, fix the controller error, and change it to parse the data.data object. case "listPlayers_Data" : $response = null; $results = array(); $players = new PlayersClass(); foreach ($players -> RetrieveAll() as $row) { $results[] = new PlayerListModel($row -> Id); } $response -> data = $results; echo json_encode($response); break; and a link to the project on github https://github.com/deannariddlespur/bb_Project/blob/master/Controllers/Controller.php
  17. Hi there, I have a simple question to ask: Say i have a PHP script: <?php var_dump($undeclaredVariable); /* The output is NULL */ if($a==$b) { if($c == $d) { $undeclaredVariable = TRUE; } else { $undeclaredVariable = FALSE; } } if($undeclaredVariable == TRUE) { echo 'the undeclared variable is TRUE'; } if($undeclaredVariable == FALSE) { echo 'the undeclared variable is FALSE'; } ?> Reading the PHP Type Comparison Table: $x = null; boolean if($x) = FALSE Using the code above, I see the "the undeclared variable is FALSE", which is OK since it proves the PHP documentation. But as you can see, if $a !=$b then the $undeclaredVarable will not be declared(defined). Is this an "OK" way to work this out? Or should I find a way to declare the variable whatever the case? Thanks in advance, Christos
  18. Hi, I've created a page that adds a product to our database, one of the fields is a 'slug' which i usually create by running a mysql snippet once the product has been added (please see attached file). I was hoping if someone might be able to tell me if there is a way to do the same thing but in php when the user has entered the product name then tabs or clicks into slug the script automatically populates the field based on the product name entered and the rules as per the sql file. Hope i've explained clearly. thanks, MsKazza create slug.txt
  19. Hi, I have the attached page that uploads files to the server and then emails the intended recipient, however I can't figure out how to include the link to the uploaded files. Everything else works just fine, so any help on this would be much appreciated. thanks, MsKazza P.s. if anyone could point me in the direction of how to make my upload section like the attach files portion of these forum posts would love to upgrade mine. thanks. index.php
  20. I am reading an RSS feed and sometimes I pull in duplicates of data. $citable= "INSERT INTO TableName (Company, Form, Date, Link) VALUES ('" . $FnumI ."',' " . $Form ."','" . $msqldate ."','" . $Flink ."') ON DUPLICATE KEY UPDATE Company='" . $FnumI ."', Form='" . $Form ."', Date='" . $msqldate ."', Link='" . $Flink ."'"; Is there a way I can only record the data if Link does not exist?
  21. Im developing a trading card game in unity and need some help with the php and mysql side of things. My database structure is something like this. This is set up when the player registers. Each player has 60 rows inside of player_deck because the decks limit is 60. players player_id/email/password/username player_deck player_id/card_id/card_amount Now this is where I need help. Im trying to update these rows when the player saves the deck. From Unitys end im calling a URL that looks something like this. "localhost/saveplayerdata/saveplayerdeck.php?playerid=&deckcardids=&deckcardamounts=" The PHP page stores the deckcardids and deckcardamounts into two arrays. Now here is where im stuck. I need to get all the rows that belong to that player and update them with our data sent from Unity. This is what i have so far. Im able to select the rows I need but how would I go about updating them with the data in my arrays? Thanks for reading. <?php $playerId=$_GET['playerid']; $playerDeckCardIds=$_GET['deckcardids']; $playerDeckCardAmounts=$_GET['deckcardamounts']; $deckCardIds = explode(" ", $playerDeckCardIds); array_pop($deckCardIds); $deckCardAmounts = explode(" ", $playerDeckCardAmounts); array_pop($deckCardAmounts); //This is the new array of cardIds sent from Unity //foreach ($deckCardIds as $value) //{ //echo "Deck Card Id $value <br>"; //} //This is the new array of cardAmounts sent from Unity // foreach ($deckCardAmounts as $value) //{ //echo "Deck Card Amount $value <br>"; //} try { #Connect to the db $conn = new PDO('mysql:host=localhost;dbname=tcg', 'root', ''); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn->prepare('SELECT card_id, card_amount FROM player_deck WHERE player_id = :player_id'); $stmt->execute(array('player_id' => $playerId)); $r = $stmt->fetchAll(PDO::FETCH_OBJ); #If we have a result if ( count($r) ) { foreach($r as $row) { //echos the current database information. I need to update this data with the data inside $deckCardIds and $deckCardAmounts. echo $row->card_id; echo $row->card_amount; } } #We did not any rows that matched our id else { echo 'No match'; } } catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } ?>
  22. Hello everyone.. I have a question to delete comment based from user-id itself. I use PHP SDK to delete any comment to my facebook page and it was success as long as I specify the comment-id.. Below are my codes to delete a comment from comment-id $request = new FacebookRequest( $session, 'DELETE', '/{comment-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); Is it possible to delete comment based on user-id itself? I know that I just need to query the graph api to get the comment-id from A but each comment have different id`s so its hard to query the comment-id everytime.. For example: A, B, and C comment to my facebook post and I want to delete the comment where the user-id is from A? So, if the api scan and found out that A is commenting to my post, it will be deleted instead deleting B and C I really appreciate for any help from you guys.. Thanks
  23. I am trying to read an RSS feed and the way my code is written, it is only repeating the first result. the xml looks like this: <?xml version="1.0" encoding="ISO-8859-1" ?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Latest Filings - Thu, 18 Feb 2016 14:52:36 EST</title> <link rel="alternate" href="/cgi-bin/browse-edgar?action=getcurrent"/> <link rel="self" href="/cgi-bin/browse-edgar?action=getcurrent"/> <id>http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent</id> <author><name>Webmaster</name><email>webmaster@sec.gov</email></author> <updated>2016-02-18T14:52:36-05:00</updated> <entry> <title>4 - YABUKI JEFFERY W (0001207371) (Reporting)</title> <link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/1207371/000120919116099734/0001209191-16-099734-index.htm"/> <summary type="html"> <b>Filed:</b> 2016-02-18 <b>AccNo:</b> 0001209191-16-099734 <b>Size:</b> 13 KB </summary> <updated>2016-02-18T14:51:18-05:00</updated> <category scheme="http://www.sec.gov/" label="form type" term="4"/> <id>urn:tag:sec.gov,2008:accession-number=0001209191-16-099734</id> </entry> <entry> <title>4 - FISERV INC (0000798354) (Issuer)</title> <link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/798354/000120919116099734/0001209191-16-099734-index.htm"/> <summary type="html"> <b>Filed:</b> 2016-02-18 <b>AccNo:</b> 0001209191-16-099734 <b>Size:</b> 13 KB </summary> <updated>2016-02-18T14:51:18-05:00</updated> <category scheme="http://www.sec.gov/" label="form type" term="4"/> <id>urn:tag:sec.gov,2008:accession-number=0001209191-16-099734</id> and my code is like this: $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml'))); $url = 'http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent&CIK=&type=4&company=&dateb=&owner=include&start=100&count=20&output=atom'; $xml = file_get_contents($url, false,$context); $xml = simplexml_load_string($xml); print_r($xml); foreach ($xml->entry as $entry){ $FnumI=$xml->entry->title; //$FnumC=$xml->entry->title; $Fdate=$xml->entry->updated; $Flink=$xml->entry->link->attributes()->href; $Form=$xml->entry->category->attributes()->term; echo "<tr>"; echo "<td><p>".$FnumI."</p></td>"; //echo "<td><p>".$FnumC."</p></td>"; echo "<td><p>".$Fdate."</p></td>"; echo "<td><p><a href='".$Flink."'> ". $Flink."</p></td>"; echo "<td><p>".$Form."</p></td>"; echo "</tr>"; }
  24. Hi Everyone, I am currently building a new website and the last big thing I need to finish is the PHP handling the forms we have built. Whenever I go to the page and submit the form, it seems to get into a never ending loop. I am not sure if the problem is in the code or if it is server side. Any assistance would be appreciated. I do not have much experience with PHP at all. I am going to attach the code below. The first file will contain the form and the second will be the PHP. Again, thank you for any suggestions you can provide. I am hoping the solution is simple. If I need to provide more information, let me know. form.html requestdemo.php
  25. Hi Guys, I have a application, once the button is trigger, the php mailer will send outlook meeting to participant and block their calendar. Like This: My question is, how can i attach excel spreadsheet in this calendar? This is the expected result from user end: As you can see there is a excel spreadsheet attached in the appointment email. Above are my codes: $text = "BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN METHOD:REQUEST BEGIN:VTIMEZONE TZID:Singapore Standard Time BEGIN:STANDARD TZOFFSETFROM:+0800 TZOFFSETTO:+0800 END:STANDARD END:VTIMEZONE BEGIN:VEVENT UID:" . md5(uniqid(mt_rand(), true)) . "example.com DTEND:". $date . "T" . $endTime . "00 DTSTAMP:" . gmdate('Ymd') . 'T' . gmdate('His') . "Z DTSTART:". $date . "T" . $startTime . "00 SUMMARY:" . $subject . " ORGANIZER;CN=" . $organizer . ":mailto:" . $organizer_email . " LOCATION:" . $location . " DESCRIPTION:" . $desc . " TRANSP:TRANSPARENT BEGIN:VALARM TRIGGER:-PT30M ACTION:DISPLAY DESCRIPTION:Reminder END:VALARM END:VEVENT END:VCALENDAR"; I have tested this line of code: ATTACH;ENCODING=BASE64;VALUE=BINARYXFILENAME=iq.xlsx:????? //<-- Not sure what to code here. But i cant get what i want. Please Help.
×
×
  • 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.