PHP $_get method

I am redesigning my website and one of the things I’d like to do is something like deathsrepo.pw/themes.php?filename=YoseMetal but I’m not quit sure on how to go about doing it. I’m going to have multiple themes listed on the themes.php page for users to choose from. So I’d like any PHP code to work with what I’d like to it do. The user will click on a button that has the theme name on it to take them to the page that will tell them about the theme and how much it will cost or if it’s free. I hope I haven’t confused anyone on what I’m wanting to accomplish. I also appreciate any help I get even though I may end up confusing you guy’s because sometimes I don’t know how to put what I’m wanting to do into words.

You would save each theme in the database and use an ID in the URL to get that record and display it accordingly.

http://www.deathsrepo.pw/themes.php?id=232
[PHP]

<?php //Connect to your database require('yourdbconfig.php'); $statement = $dbconn->prepare(" SELECT id, title, theme_title, theme_body FROM themes WHERE id = :id "); $statement->execute([ ":id" => $_GET['id'] ]); $result = $statement->fetchAll(PDO::FETCH_ASSOC); if (!$result){ //404 error here }else { //There is a result, display your items } ?>

[/PHP]

So what would my connect to database php look like and how would I make it to where it will record every theme I add to my site?

Here is what I have for my database connection php:

[php]<?php
$servername = “localhost”;
$username = “username”;
$password = “password”;
$dbname = “dbname”;

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed please try again: " . $conn->connect_error);
}
echo “Connected successfully”;
?> [/php]

The code I provided was using PDO, here is a connection string:

[PHP]
$config[‘dbuser’] = ‘’;
$config[‘dbpass’] = ‘’;
$config[‘dbname’] = ‘’;
$config[‘dbhost’] = ‘’;

$dbconn = new PDO(‘mysql:host=’.$config[‘dbhost’].’;dbname=’.$config[‘dbname’], $config[‘dbuser’], $config[‘dbpass’],array(PDO::MYSQL_ATTR_INIT_COMMAND => “SET NAMES utf8”));

try
{
$dbPDO = new PDO(‘mysql:host=’.$config[‘dbhost’].’;dbname=’.$config[‘dbname’], $config[‘dbuser’], $config[‘dbpass’]);
$dbPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
//echo "Error!: " . $e->getMessage() . "

die();

}
[/PHP]

Ok I’m new so what do I need to put in my theme folders does it need to be a index.html/php? Also how will I get the database to record what I add to my site. Here’s my site if you’d like to see what I have going on http://test.deathsrepo.pw it’s a test subdomain because my site is under construction.

It sounds like you need to study a few tutorials on the basics of PHP and Mysql. People on the board are happy to help you with your code but they are not going to do it for you unless you hire them.

No I’m not asking for it to be done for me I just would like a point in the right direction.

Her is a start

http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html

Thank you guy’s I’m still lost so I’m going to do the old method deathsrepo.pw/YoseMetal/index.php that method.

Sponsor our Newsletter | Privacy Policy | Terms of Service