Search found 314 matches

by Strider64
Tue Nov 21, 2017 4:59 am
Forum: PHP coding => General
Topic: style php results in html and css
Replies: 4
Views: 60

Re: style php results in html and css

Twig ( https://twig.symfony.com/ ) or Smarty ( https://www.smarty.net/ ) -> I use Smarty. Templating makes it easier to develop secure pages and give people with little programming to help with the design portion of the website. Here's just a small example of what I mean taking from my cms template ...
by Strider64
Sun Nov 05, 2017 8:17 am
Forum: Your Scripts
Topic: OPINION: Make/Accessible, a lightweight PHP package that let you test singleton and encapsulated classes.
Replies: 1
Views: 47

Re: OPINION: Make/Accessible, a lightweight PHP package that let you test singleton and encapsulated classes.

First of all I have been told by PHP gurus that one should not be using too many singleton classes and second if one writes a class that the class should be able to be UNIT tested without using a PHP package.
by Strider64
Thu Nov 02, 2017 4:05 am
Forum: PHP General
Topic: datetime-local input will not pull php echo
Replies: 2
Views: 61

Re: datetime-local input will not pull php echo

You could had simply done this -> $myDate = new DateTime($currentstartdate, new DateTimeZone("Europe/London")); echo $myDate->format("d/m/Y H:i"); though I don't think that is your problem, I think you need to look into using sessions for the variable $row['start_date']; for when you refresh you pag...
by Strider64
Sat Oct 21, 2017 1:21 pm
Forum: PHP coding => Mail
Topic: SMTP failure when posting contact form
Replies: 2
Views: 116

Re: SMTP failure when posting contact form

I was having a similar problem and came across this fix for PHPMailer -> if (filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_URL) == "localhost") { $mail->isSmtp(); // Local Host: $mail->Port = EMAIL_PORT; // Local Host Port: (Usually 587) } else { $mail->isSendMail(); // Remote Host: } Fo...
by Strider64
Fri Oct 06, 2017 1:39 pm
Forum: Your Scripts
Topic: PHP PDO Read and Write Tutorial
Replies: 0
Views: 142

PHP PDO Read and Write Tutorial

A simple tutorial to help you create a small cms blog using PHP, PDO and MySQL I always wanted to create a tutorial on how to insert data to a database table, so here it is. You first must modify the config.php file to set your connection strings in order to get the rest of the files to run properly...
by Strider64
Sun Oct 01, 2017 10:30 am
Forum: mySQL & php coding
Topic: My script has stopped connecting to a database
Replies: 2
Views: 150

Re: My script has stopped connecting to a database

Looks like you `might` be using a local connection instead of the remote server credentials? What I do is this in a configuration file: if (filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_URL) == "localhost") { define('DATABASE_HOST', 'localhost'); // usually localhost define('DATABASE_NAM...
by Strider64
Tue Sep 26, 2017 8:29 am
Forum: PHP General
Topic: Keep track of login tries
Replies: 5
Views: 240

Re: Keep track of login tries

You could also store the login attempts in a MySQL Database Table. If you are attempting to write a script prevent a brute force attack, I'll just say that is a tough task and I gave up on it for the attackers have the upperhand on this one. That is why I tell people to use tougher passwords than th...
by Strider64
Fri Sep 22, 2017 3:16 am
Forum: mySQL & php coding
Topic: php mysql login function
Replies: 3
Views: 550

Re: php mysql login function

Here's a better way of doing it , doesn't use obsolete mysql and is more secure: <?php session_start(); $db_options = array( /* important! use actual prepared statements (default: emulate prepared statements) */ PDO::ATTR_EMULATE_PREPARES => false /* throw exceptions on errors (default: stay silent)...
by Strider64
Thu Sep 21, 2017 4:15 am
Forum: PHP Scripts
Topic: password_verify returning false
Replies: 1
Views: 177

Re: password_verify returning false

I don't know why you are using FETCH_ALL to get a single user? I would do something like the following: <?php $db = DB::getInstance(); $pdo = $db->getConnection(); // This is just my connection string setup: /* Setup the Query for reading in login data from database table */ $query = 'SELECT * FROM ...
by Strider64
Tue Sep 19, 2017 8:23 pm
Forum: PHP coding => General
Topic: php 7.0 beta and session_start
Replies: 1
Views: 128

Re: php 7.0 beta and session_start

I don't know if this will help you but all I do when I end a session is the following -> // Function to forcibly end the session function end_session() { // Use both for compatibility with all browsers // and all versions of PHP. session_unset(); session_destroy(); } Sorry I'm not much help for I'm ...
by Strider64
Thu Sep 14, 2017 2:35 pm
Forum: PHP General
Topic: How would I add to a dropmenu using php?
Replies: 2
Views: 274

Re: How would I add to a dropmenu using php?

Here's how I go about doing something like this. I first try to keep the PDO and the HTML separated as much as possible. First I grab all the records that I want by calling function: <?php use Library\Database\Database as DB; function getUserInfo() { $db = DB::getInstance(); $pdo = $db->getConnectio...
by Strider64
Thu Sep 07, 2017 7:50 am
Forum: mySQL & php coding
Topic: Getting a simple php script to display results
Replies: 14
Views: 498

Re: Getting a simple php script to display results

Do you have error reporting turned on? /* Turn on error reporting */ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); if (filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_URL) == "localhost") { error_reporting(-1); // -1 = on || 0 = off } else { error_reporting(0); // -1 ...
by Strider64
Wed Sep 06, 2017 3:24 am
Forum: Your Scripts
Topic: Simple PHP Class to put images into HTML slider format
Replies: 0
Views: 168

Simple PHP Class to put images into HTML slider format

This simple class will enable you to put all the images of a particular directory into HTML format so that you can use it for a slider or rotator. I'm only providing the PHP, for you should be able to create your own slider from the HTML that is generated. Here's my index.php of my website: <?php re...
by Strider64
Wed Aug 30, 2017 5:22 am
Forum: PHP General
Topic: Setting NetBeans environment for debugging PHP files outside of the htdocs subtree
Replies: 2
Views: 197

Re: Setting NetBeans environment for debugging PHP files outside of the htdocs subtree

You should be able to set that in your php.ini file to the correct directory; however, I don't know personally for I have always used htdocs as the default directory.
by Strider64
Sun Aug 13, 2017 4:51 am
Forum: mySQL & php coding
Topic: PDO double results
Replies: 7
Views: 417

Re: PDO double results

Maybe doing this way and it even uses prepared statements <?php $query = 'SELECT * FROM collection WHERE name LIKE :name_search'; // I suggest to lose the ` ticks: $stmt = $db->prepare($query); $stmt->execute(array(':name_search' => '%' . $name_search . '%')); $result = $stmt->fetchAll(PDO::FETCH_AS...
by Strider64
Tue Aug 01, 2017 8:39 am
Forum: PHP coding => Mail
Topic: integrating Google reCaptcha into mail.php
Replies: 2
Views: 308

Re: integrating Google reCaptcha into mail.php

Here's how I do it -> $submit = filter_input(INPUT_POST, 'submit', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if (isset($submit) && $submit === 'submit') { /* The Following to get response back from Google Recaptcha */ $url = "https://www.google.com/recaptcha/api/siteverify"; /* Remote Server */ $remoteSe...
by Strider64
Mon Jul 31, 2017 3:54 am
Forum: mySQL & php coding
Topic: PDO double results
Replies: 7
Views: 417

Re: PDO double results

Have you run phpinfo() to see what version of php the server(s) are running?
by Strider64
Mon Jul 17, 2017 1:32 pm
Forum: PHP coding => General
Topic: What have i missed with setting up this simple class?
Replies: 2
Views: 193

Re: What have i missed with setting up this simple class?

<?php Class parseClass { public function ReplaceTag($tag, $replacement, $content) { $content = str_replace($tag, $replacement, $content); return $content; } } /* * Create an instance of the class. */ $myclass = new parseClass(); $tag = "{replace}"; $replacement = "Bob"; $content = "My animal runs a...
by Strider64
Sat Jul 08, 2017 5:15 am
Forum: PHP coding => General
Topic: PHP Function to Prevent Javascript Tampering?
Replies: 1
Views: 172

Re: PHP Function to Prevent Javascript Tampering?

This is how I would tackle the problem. Get whatever you are working on to run using only PHP. I know it isn't going to look pretty or have the bells & whistles that javascript throws into the mix. However, once you getting the script working to your satisfaction then adding AJAX and Javascript shou...
by Strider64
Wed Jul 05, 2017 1:39 pm
Forum: PHP coding => General
Topic: Noob form is not working
Replies: 3
Views: 306

Re: Noob form is not working

Here's my contact form Email class using swiftmailer that I just setup on my website -> <?php namespace Library\Email; /* * In order to use swiftmailer the below is needed.... */ use Swift_SmtpTransport; use Swift_Message; use Swift_Mailer; class Email { public $result = \NULL; public function __con...
by Strider64
Sun Jul 02, 2017 5:53 pm
Forum: PHP coding => General
Topic: My first php project
Replies: 2
Views: 250

Re: My first php project

Simple answer is that is NOT the way you write a PHP class. That doesn't look like php. Are you sure you're in the right category / forum?

My advice is to stick to procedural PHP until you have the fundamentals down pat.
by Strider64
Wed Jun 07, 2017 3:19 am
Forum: PHP coding => General
Topic: PHP namespaces
Replies: 1
Views: 215

Re: PHP namespaces

Namespaces can be tricky, so I give you an example from my own website: I'll use my Database Class for it's the simplest to explain: <?php namespace Library\Database; # PDO database: only one connection is allowed. use PDO; class Database { private $_connection; // Store the single instance. private...
by Strider64
Wed Jun 07, 2017 2:45 am
Forum: PHP coding => General
Topic: Data back to a form.
Replies: 4
Views: 399

Re: Data back to a form.

When you read you data from PHP just before you return a true value put some like this in your true portion of the if statement: $_SESSION['result'] = "The value you requested"; then upon return if (isset($_SESSION['result']) { header("Location: samepage.php"); exit(); } and at the very top of the p...
by Strider64
Sun May 28, 2017 5:20 am
Forum: Free time
Topic: How To increased your rank in forum
Replies: 1
Views: 580

Re: How To increased your rank in forum

Reported - Obviously you didn't get the point and all you are doing is spamming websites. I never understand why people do this, for I would never ever do business with you. Have a nice day! :D
by Strider64
Wed Apr 12, 2017 7:14 am
Forum: PHP & MySQL Security
Topic: php session logout/login button
Replies: 1
Views: 633

Re: php session logout/login button

Here's how I do it: <?php if (isset($_SESSION['user']->id) && ( $_SESSION['user']->security === 'member' || $_SESSION['user']->security === 'admin' )) { echo '<li><a href="addTrivia.php">Add Trivia</a></li>'; echo '<li><a href="logout.php">Logout</a></li>'; } else { echo '<li><a href="login.php">Log...