View Single Post
Old 09-06-2021, 08:46 PM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,058
A cleaner version. More my style. No camelcase shit ;p

<?php
error_reporting(E_ALL);

$id=0;
if ( ! isset($_GET['id'] ) )
{
header('Location: index.php');
}
else
{
$id=intval($_GET['id']);
}
if($id==0)
{
die('bad id passed in');
}

$pdo=hookitup();

$table = "recipes";
$sql = "select * from " . $table . " where id=?";

try
{
$stmt = $db->prepare($sql_str);
$stmt->execute(array($pdo->quote($id)));
}
catch( PDOException $e)
{
die($e-getMessage());
}

$row=$stmt->fetch(PDO::FETCH_ASSOC);

$title = $row['recipename'];
$description = $row['recipedescription'];

?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


<title><?php echo $title; ?> Recipe | Sitename</title>
<meta name="Description" content="<?php echo $description; ?>">
<meta name="Keywords" content="<?php echo $title; ?> Recipe Ingredients Make <?php echo $title; ?> Recipes">
<link rel="stylesheet" href="style.css" type="text/css"/>

<link rel="canonical" href="//siteurl/">
</head>

<body class="home page page-id-21 page-template-default ie et_includes_sidebar">

<?php
require_once('./templates/header.php');
?>

<div id="hd_logo0">
<p>
<a href="http://www.domain.com">
<img class="alignnone size-full wp-image-169" alt="" src="logo.png" style="width: 310px"/>
</a>
</p>
</div>

<?php
require_once('./templates/secondary.php');
?>

<center>
<div id="main-area">
<div class="container" style="left: 0px; top: 0px">
<div id="content-area" class="clearfix">
<div id="left-area">
<div id="breadcrumbs" class="clearfix">
<a href="http://www.domain.com" class="breadcrumbs_home">Home</a>
<span class="raquo">&raquo;</span>
</div>
<article id="post-21" class="post-21 page type-page status-publish hentry entry clearfix">
<div class="post_content clearfix">
<h1 class="title">Home</h1>
<?php
require_once('./templates/midbanner.php');

echo "<table>";
echo "<tr>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['ingredients'] . "</td>";
echo "<td>" . $row['method'] . "</td>";
echo "</tr>";
echo "</table>";
?>
</div>
</article>
</div>
<?php
require_once('./templates/sidebar.php');
?>
</div>
</div> <!-- end .container -->
</div> <!-- end #main-area --></center>

<?php
require_once('./templates/footer.php');
?>
<script type="text/javascript" src="jquery.form.min.js"></script>
<script type="text/javascript" src="superfish.js"></script>
<script type="text/javascript" src="jquery.fitvids.js"></script>
<script type="text/javascript" src="custom.js"></script>
</body>

</html>

<?php

function hookitup()
{
require_once('dbcreds.php');
return new PDO("mysql:host=$host;dbname=$dbname;charset=utf8" ,$user,$password,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}

In dbcreds.php would be:

<?php
$dbname='dbname';
$dbuser='dbusername';
$dbpass='dbpassword';
$dbhost='localhost';
?>

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote