-
Posts
174 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by terryds
-
-
See my code first
<?php
include(dirname(dirname(__FILE__)) . "/pathdefiner.php");include_once (BASEPATH . INC . "logged.php");if (!isLoggedIn()) {include ("templates/login.html.php");exit();}if (isset($_GET['addp'])) {$title = "Add post";$desc = "Type down what your post want to be";$action = "?addpost";$id = '';$titlepost = '';$button = 'Add post';$editmode = FALSE;include "templates/form.html.php";die();}if (isset($_GET['addpost'])) {if (empty($_POST['post']) || empty($_POST['title'])) {echo 'Please fill and set the post entry' . '<br>' . '<p><a href=".">Go Back</a></p>';die();}include_once (BASEPATH . INC . "connect.php");try {$sql = "INSERT INTO `posts` SET`title` = :title,`posttext` = :post,`posttime` = :time";$s = $pdo->prepare($sql);$s->execute(array(':title' => $_POST['title'],':post' => $_POST['post'],':time' => time()));}catch(PDOException $e) {die("Error adding post. Error: " . $e->getMessage());}header('Location: .');die();}include "templates/admin.html.php";include "templates/logout.inc.html.php";After executed, it generates an error that the $pdo variable is not set...But, if i change the include_once to include, it will work well...And, if i change the $pdo variable in my connect.php to a global scope, it will work well too...Can you tell me why this happens?Why if i change include_once to include, it will work ?Why if i set the $pdo variable to global, it will work ?Which's better ? Change include_once to include or set the global scope for $pdo ?This is my connect.php<?phprequire_once (dirname(__FILE__) . '/config.php');define("DSN", 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME);try{$pdo = new PDO(DSN, DB_UN, DB_PW);$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);$pdo->exec('SET NAMES "utf8"');}catch (PDOException $e){echo DB_PW . "<br>";die('Error: ' . $e->getMessage());} -
Hi, i want know how to make a quick installation CMS ....
I mean installing the CMS without editing the code...
So, when i set the host, database username,password,and name into a variable in a php file...
Can you tell me how to do that ?
I wonder so much how MyBB CMS can do this...
-
Take a look at my code :
access.inc.php
<?php function isLoggedIn() { if (isset($_POST['action']) and $_POST['action'] == 'login') {if (empty($_POST['un']) || empty($_POST['pw'])) {$GLOBALS['loginError'] = "Please fill in both fields";return FALSE;} $pw = crypt($_POST['pw'], '$2a$07$427fyb79223423423acgLosdillYs$l7$'); if (dbConstainsUser($_POST['un'], $pw)) { session_start(); $_SESSION['loggedIn'] = true; $_SESSION['un'] = $_POST['un']; $_SESSION['pw'] = $pw; return TRUE; } else { session_start(); unset($_SESSION['loggedIn']); unset($_SESSION['un']); unset($_SESSION['pw']); $GLOBALS['loginError'] = "Invalid username or password"; return FALSE; }} session_start();if (isset($_SESSION['loggedIn'])) {return dbContainsUser($_SESSION['un'], $_SESSION['pw']);}} function dbContainsUser($username, $password) {include dirname(dirname(dirname(__FILE__))) . '/inc/connect.php'; try {$sql = "SELECT COUNT(`id`) FROM `users` WHERE `username` = :un AND `password` = :pw";$s = $pdo->prepare($sql);$s->execute(array(':un' => $username,':pw' => $password ));} catch (PDOException $e) {$error = "SQL ERROR = Error searching for user";echo $error;die();} $row = $s->fetch(PDO::FETCH_ASSOC); if ($row[0] > 0) {return TRUE;} else {return FALSE;}}
And, my controller code :
<?phpinclude(dirname(dirname(__FILE__)) . "/pathdefiner.php");include_once ("inc/access.inc.php");if (!isLoggedIn()) {include ("template/login.html");exit();}echo "Under Construction";But, if i execute the controller code, it generates an errorNotice: Undefined index: un in C:xampphtdocsterrytestadmininclogged.php on line 32Notice: Undefined index: pw in C:xampphtdocsterrytestadmininclogged.php on line 32My 32nd line is : return dbContainsUser($_SESSION['un'], $_SESSION['pw']);Please help me fix this error so it'll work as expected ... -
I don't know when to use include_once ..
For every connect to the database server, should i use include/require_once or just include/require ?
If not, why ?
-
-
Yeah, i have opened that link.... But, i still wonder why i should make it display as table...
In http://www.w3schools.com/cssref/pr_pos_vertical-align.asp , it says when the vertical-align:middle, it will make it placed in the middle of parent element.
But, if i just use vertical-align : middle without displaying it as a table, it doesn't work...
Can you tell me why i should use display:table ?
-
Do you know the difference between double and triple equation ?
I'm so confused... I often see triple equations in some functions ( like if (md5($a)===1) ) and others....
-
Thanks for the answer.... It works well....
But, i want to ask something..
Does vertical-align just work for table ?
-
Can you tell me why vertical-align:middle doesn't work ?
-
Sorry for my bad English skill ...
I mean, in http://terryds.net63.net/ , then i inspect the elements , then i change the #page_header to 200px ...
So, the #page_header height becomes 200px , but the #title doesn't automatically moved to the middle of the page header ...
Can you tell me how to make the #title get to the middle of page header automatically even if the page header's height changes ?
-
Look at : http://terryds.net63.net/
I want my #title Terry Djony Official Website get to the middle when the page-header becomes 200px or larger ( like the one in http://terryds.net63.net/ )
I want my #title get to the middle of the page-header no matter how high the page-header is...
Any solutions ?
-
Look at my website : http://terryds.net63.net/
The "Terry Djony's Official Website" gets stacked with the nav...
But, if i apply padding : 30 px to the #title, it's no longer stacked...
But, the next problem happens if i change the "Facebook" with a facebook icon....
The welcome text ("Terry Djony's Official Website") gets stacked again....
Can you tell me how to make it nice without using padding ?
What i think now is to make the #title position is 20px below the nav... But, as i know, using the position method can make the text no longer centered...
Any ideas so my #title gets 20px below the nav and keep its text-align ?
-
See : http://line25.com/tutorials/how-to-create-a-pure-css-dropdown-menu first...
I don't understand this section :
nav ul:after { content: ""; clear: both; display: block; }
I think that code is useless right ? What's the use of clear:both on that property ? It's useless right ?
And, when i practiced that in my page... It's not working.. Can you tell me what's wrong ?
my style.css
body,h1 {margin: 0px;}body {background-color: #FFFFFF;font-family: Helvetica Neue, Helvetica, Verdana, Arial, sans-serif;font-size: small;}#page_header {background-color: #7EA4FC;margin : 10px 10px 0px 10px;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;padding: 10px;}#title {text-align: center;}#page_nav {margin: 100px auto;text-align: center;}#page_nav ul ul {display: none;}#page_nav ul li:hover > ul {display: block;}#page_nav ul {background: #efefef;background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%);box-shadow: 0px 0px 9px rgba(0,0,0,0.15);padding: 0 20px;border-radius: 10px;list-style: none;position: relative;display: inline-table;}#page_nav ul:after {content: ""; clear: both; display: block;}#page_nav ul li {float: left;}#page_nav ul li:hover {background: #4b545f;background: linear-gradient(top, #4f5964 0%, #5f6975 40%);background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);}#page_nav ul li:hover a {color: #fff;}#page_nav ul li a {display: block; padding: 25px 40px;color: #757575; text-decoration: none;}#page_nav ul ul {background: #5f6975; border-radius: 0px; padding: 0;position: absolute; top: 100%;}#page_nav ul ul li {float: none;border-top: 1px solid #6b727c;border-bottom: 1px solid #575f6a; position: relative;}#page_nav ul ul li a {padding: 15px 40px;color: #fff;}#page_nav ul ul li a:hover {background: #4b545f;}#page_nav ul ul ul {position: absolute; left: 100%; top:0;}my html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Me - A Web Developer</title>
<meta name="description" content="A web developer who has started a long journey">
<link rel="stylesheet" type="text/css" href="content/themes/style.css">
</head>
<body>
<header id="page_header">
<h1 id="title">My Official Website</h1>
<nav id="page_nav">
<ul>
<li><a href="#">Home</a></li>
</ul>
<ul>
<li><a href="#">Sample Page</a></li>
<ul>
<li><a href="#">My Page 1</a></li>
<li><a href="#">My Page 2</a></li>
</ul>
</li>
</ul>
</nav>
</header>
<section id="post">
<article class="post">
<header>
<h2>This Website Is Under Construction</h2>
<p>Posted by Terry on
<time datetime="2010-10-01T14:39">October 1st, 2010 at 2:39PM</time>
</p>
</header>
<aside>
<p>
"Please be patient and come back later."
</p>
</aside>
<p>Please come back one week later.</p>
<footer>
<p>No comment</p>
</footer>
</article>
</section>
</body>
</html>
Can you tell me what's wrong ?
-
// Create a value for the notice variablevar notice = "I live in a variable!";$("p.foo").bind("click", { n:notice }, function(event){console.log(event.data.n);});Look at the function(event) ! Where does the parameter event come from ? I don't understand... Is it a special parameter ?Please explain me about the parameter.... And, i don't understand what { n:notice } means .... Can you tell me what's that ?I don't understand why the result is "I live in a variable" ?I'm also confused with the parameter of this function below... Are they special parameters too ?$("p,.foo").map(function(index, ele){$(this).append(" "+ele.tagName+" #"+index);});
-
$("p:first").data("test","This is some data.");var p = $("p:first").detach();console.log("Data stored: "+p.data("test"));
What does the "+p.data("test"))" mean ?
-
Can you tell me how to make the google search result like this ?
Is it can be done by using meta attribute ? How to do that?
Sorry for posting in HTML/XHTML (because there is no SEO forum)
-
How to make the file not publicly published?
-
This is the fix for yours...
<?phpsession_start();?><!doctype html><html><head><title>php scripting</title></head><body><center><?php if(!isset($_SESSION['mistake'])): ?><form method="post" action="check.php">Name:<br /><input type="text" name="name" value="<?phpif (isset($_SESSION['name'])) {echo $_SESSION['name'];} ?>" /><br /><input type="submit" name="submit" value="submit" /><?php endif; ?></form></center><p>If you see a blank page, it means you entered a wrong name </p></body></html><?phpif(isset($_POST['submit'])){$name = $_SESSION['name'] = $_POST['name'];}?>And, this is for the check.php<?php/** If the mistake is when the user type 'mistake' in the form */if ($_POST['name'] == 'mistake') {session_start();$_SESSION['mistake'] = 1;}header('Location: session.php');I dont think that that's the best code but it works- 1
-
Can you tell me Which is better between reading xml from a string or external file?
Is it unsecure if i store database password to an external xml file?
Is it slow to read xml from a string ?
-
PHP scrypt ?
in PHP
I get an error installing it...
Can you give me a solution?
-
If i make a folder with index.php inside it and place it to the themes directory in Wordpress.... The admin panel detects that there is a new theme...
How does it do that ? Can you tell me how to do that ?
-
PHP scrypt ?
in PHP
Can you tell me how to install through PECL ? Is it using php command line ? I'm using Windows 7 ....
-
What's the difference between
require_once( dirname(__FILE__) . '/file.php');
and
require_once('file.php');
Any difference ?
-
PHP scrypt ?
in PHP
Hey, do you know how to use php scrypt? How to install them?
I see the php scrypt is at https://github.com/DomBlack/php-scrypt
The first instruction is to build the project... Can you tell me how to ?
Error querying sql (undefined var)
in PHP
Posted
So, what should i do ? Make it global scoped or change the include_once with include ?
I think that the file including connect.php is my logged.php