Jump to content

konetch

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

konetch's Achievements

Member

Member (2/5)

0

Reputation

  1. okay never ming I got it working changed it to if (isset($_GET["post"]) && $_GET["post"] == 1) {
  2. Thanks for the reply, but this didn't work, for some reason. I'm still new, but I can see the logic behind for code. Perhaps it's an issue with this line of code if (isset($_GET["page"]) && $_GET["page"] == 1)
  3. I have two files: newlink.php and index.php IN newlink.php I have a class where I want it so that when one function is excecuted the other one will display. TO make myself clearer I want it so that when I click a link like localhost/index.php?post=1 it will come up with HELLO World Understand. Here are the two files newlink.php <?php class newlink { public function displayLink () { ?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?post=1">Read my first page!!!</a> <?php } public function displayPage () { ?> <h2>Hello World</h2> <p>This is a test post</p> <?php } } ?> index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Home</title> </head> <body> <?php require_once("newlink.php"); $obj = new newlink(); echo $obj->displayLink(); ?> </body> </html> I've got most of it down I think I just need something that will diplay the post when I click the link. Can you tell me how to do this. Thanks If I'm not clear enough jsut ask. I'll reply quickly
  4. I have a form that allows users to add articles to the site. So far the code I have with the form is. newarticle.php <?php include 'C:\xampp\htdocs\konetcms\administrator\_class\wysiwyg\fckeditor\fckeditor.php'; class simpleCMS { var $host; var $username; var $password; var $table; public function display_public() { $q = "SELECT * FROM testDB ORDER BY created DESC LIMIT 3"; $r = mysql_query($q); if ( $r !== false && mysql_num_rows($r) > 0 ) { while ( $a = mysql_fetch_assoc($r) ) { $title = stripslashes($a['title']); $bodytext = stripslashes($a['bodytext']); $entry_display .= <<<ENTRY_DISPLAY <div class="post"> <h2> $title </h2> <p> $bodytext </p> </div> ENTRY_DISPLAY; } } else { $entry_display = <<<ENTRY_DISPLAY <h2> <span style="color:red;">Error!</span> No Entries Were Made! </h2> <p> Please write some articles for your site quickly. Failure to do so could cause visitors to leave! </p> ENTRY_DISPLAY; } $entry_display .= <<<ADMIN_OPTION <p class="admin_link"> <a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a> </p> ADMIN_OPTION; return $entry_display; } public function display_admin() { return <<<ADMIN_FORM <form action="{$_SERVER['PHP_SELF']}" method="post"> <label for="title">Title:</label><br /> <input name="title" id="title" type="text" maxlength="150" /> <div class="clear"></div> <label for="bodytext">Body Text:</label><br /> <textarea name="bodytext" id="bodytext"></textarea> <div class="clear"></div> <input type="submit" value="Create This Entry!" /> </form> <br /> <a href="index.php">Back to Home</a> ADMIN_FORM; } public function write($p) { if ( $_POST['title'] ) $title = mysql_real_escape_string($_POST['title']); if ( $_POST['bodytext']) $bodytext = mysql_real_escape_string($_POST['bodytext']); if ( $title && $bodytext ) { $created = time(); $sql = "INSERT INTO testDB VALUES('$title','$bodytext','$created')"; return mysql_query($sql); } else { return false; } } public function connect() { mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error()); mysql_select_db($this->table) or die("Could not select database. " . mysql_error()); return $this->buildDB(); } private function buildDB() { $sql = <<<MySQL_QUERY CREATE TABLE IF NOT EXISTS articles ( title VARCHAR(150), bodytext TEXT, created VARCHAR(100) ) MySQL_QUERY; return mysql_query($sql); } } ?> This works but I want a wysiwyg editor with it. I downloaded fckeditor and plan to use it with this form. They give me a sample <?php /* * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or later (the "GPL") * http://www.gnu.org/licenses/gpl.html * * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * http://www.gnu.org/licenses/lgpl.html * * - Mozilla Public License Version 1.1 or later (the "MPL") * http://www.mozilla.org/MPL/MPL-1.1.html * * == END LICENSE == * * Sample page. */ include("../../fckeditor.php") ; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>FCKeditor - Sample</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="robots" content="noindex, nofollow"> <link href="../sample.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>FCKeditor - PHP - Sample 1</h1> This sample displays a normal HTML form with an FCKeditor with full features enabled. <hr> <form action="sampleposteddata.php" method="post" target="_blank"> <?php // Automatically calculates the editor base path based on the _samples directory. // This is usefull only for these samples. A real application should use something like this: // $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. $sBasePath = $_SERVER['PHP_SELF'] ; $sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ; $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = $sBasePath ; $oFCKeditor->Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ; $oFCKeditor->Create() ; ?> <br> <input type="submit" value="Submit"> </form> </body> </html> I tried taking the php code within the form and tried to use it, but it doesn't work. Does anybody know how I could use the fckeditor with my submit form? Thanks for your help. Alex
  5. Okay I changed it to <html> <body> <? mysql_connect ("localhost","root"); mysql_select_db ("cms"); $sql = "select * from mohdatabase"; $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) or die(mysql_error()); { $field1= $row["pageid"]; $field2= $row["quote"]; $field3= $row["author"]; echo "$field1<br>"; echo "$field2<br>"; echo "$field3<p>"; } ?> </body> </html> Is that correct. Now it says there is a parse error on line 10 Thanks
  6. I have a contant form that submits some quotes into my database. To display the quotes from the database I have written a little code. <html> <body> <? mysql_connect ("localhost","root"); mysql_select_db ("cms"); $sql = "select * from mohdatabase"; $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) { $field1= $row["pageid"]; $field2= $row["quote"]; $field3= $row["author"]; echo "$field1<br>"; echo "$field2<br>"; echo "$field3<p>"; } ?> </body> </html> When I look at the page that this is on it shows the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\konetcms\test\a\display.php on line 10 Would you know why? Thanks, I'm still new and couldn't find an answer. Alex
  7. Okay, I've done some more work and have created a new user. the user is alex@localhost with the password: alex . and the code I have <?php class simpleCMS { var $host; var $username; var $password; var $table; public function display_public() { $q = "SELECT * FROM testDB ORDER BY created DESC LIMIT 3"; $r = mysql_query($q); if ( $r !== false && mysql_num_rows($r) > 0 ) { while ( $a = mysql_fetch_assoc($r) ) { $title = stripslashes($a['title']); $bodytext = stripslashes($a['bodytext']); $entry_display .= <<<ENTRY_DISPLAY <div class="post"> <h2> $title </h2> <p> $bodytext </p> </div> ENTRY_DISPLAY; } } else { $entry_display = <<<ENTRY_DISPLAY <h2> This Page Is Under Construction </h2> <p> No entries have been made on this page. Please check back soon, or click the link below to add an entry! </p> ENTRY_DISPLAY; } $entry_display .= <<<ADMIN_OPTION <p class="admin_link"> <a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a> </p> ADMIN_OPTION; return $entry_display; } public function display_admin() { return <<<ADMIN_FORM <form action="{$_SERVER['PHP_SELF']}" method="post"> <label for="title">Title:</label><br /> <input name="title" id="title" type="text" maxlength="150" /> <div class="clear"></div> <label for="bodytext">Body Text:</label><br /> <textarea name="bodytext" id="bodytext"></textarea> <div class="clear"></div> <input type="submit" value="Create This Entry!" /> </form> <br /> <a href="display.php">Back to Home</a> ADMIN_FORM; } public function write($p) { if ( $_POST['title'] ) $title = mysql_real_escape_string($_POST['title']); if ( $_POST['bodytext']) $bodytext = mysql_real_escape_string($_POST['bodytext']); if ( $title && $bodytext ) { $created = time(); $sql = "INSERT INTO testDB VALUES('$title','$bodytext','$created')"; return mysql_query($sql); } else { return false; } } public function connect() { mysql_connect($localhost,alex@localhost,$alex) or die("Could not connect. " . mysql_error()); mysql_select_db($this->table) or die("Could not select database. " . mysql_error()); return $this->buildDB(); } private function buildDB() { $sql = <<<MySQL_QUERY CREATE TABLE IF NOT EXISTS testDB ( title VARCHAR(150), bodytext TEXT, created VARCHAR(100) ) MySQL_QUERY; return mysql_query($sql); } } ?> And the main display page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- ********************************************************************************* * * File: display.php | For retrieving and displaying data from the DB. * * * Created by Jason Lengstorf for Ennui Design. Copyright (C) 2008 Ennui Design. * * www.EnnuiDesign.com | answers@ennuidesign.com | (406) 270-4435 * * ----------------------------------------------------------------------------- * * This file was created to accompany an article written for CSS-Tricks.com * ********************************************************************************* --> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Simple CMS with PHP</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="page-wrap"> <?php include_once('_class/simpleCMS.php'); $obj = new simpleCMS(); /* CHANGE THESE SETTINGS FOR YOUR OWN DATABASE */ $obj->host = 'localhost'; $obj->username = 'alex@localhost'; $obj->password = 'alex'; $obj->table = 'alex'; $obj->connect(); if ( $_POST ) $obj->write($_POST); echo ( $_GET['admin'] == 1 ) ? $obj->display_admin() : $obj->display_public(); ?> </div> </body> </html> Is anything wrong with this thanks? I'm still getting the parse error and the content that I want displayed doens't show up. Sorry, since these are probably easy questions, but I'm just trying to get the feel for it so I can start using PHP in some of my pages.
  8. Okay, I was searching and found that the user was 'root' . Do you know what should go in the password field? Thanks Alex
  9. I have a xxamp server set up on my local machine, and was building a simple CMS. In the phpmyadmin I have a database called CMS set up. I'm trying to conenct to it. However, there is not a password protecting it. When I set up databases on the internet I protect them with passwords. But on my local machine none of them are protected with a password. So I have the code that connets to it and it looks like this public function connect() { mysql_connect($localhost,$ ,$ ) or die("Could not connect. " . mysql_error()); mysql_select_db($this->table) or die("Could not select database. " . mysql_error()); return $this->buildDB(); } It says there is a parse error on this line (i.e. Parse error: parse error, expecting `T_VARIABLE' or `'$'' in C:\xampp\htdocs\SimpleCMS\_class\simpleCMS.php on line 93) Could you please let me know what is wrong with it. Heres the whole simpleCMS.php file <?php class simpleCMS { var $host; var $username; var $password; var $table; public function display_public() { $q = "SELECT * FROM testDB ORDER BY created DESC LIMIT 3"; $r = mysql_query($q); if ( $r !== false && mysql_num_rows($r) > 0 ) { while ( $a = mysql_fetch_assoc($r) ) { $title = stripslashes($a['title']); $bodytext = stripslashes($a['bodytext']); $entry_display .= <<<ENTRY_DISPLAY <div class="post"> <h2> $title </h2> <p> $bodytext </p> </div> ENTRY_DISPLAY; } } else { $entry_display = <<<ENTRY_DISPLAY <h2> This Page Is Under Construction </h2> <p> No entries have been made on this page. Please check back soon, or click the link below to add an entry! </p> ENTRY_DISPLAY; } $entry_display .= <<<ADMIN_OPTION <p class="admin_link"> <a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a> </p> ADMIN_OPTION; return $entry_display; } public function display_admin() { return <<<ADMIN_FORM <form action="{$_SERVER['PHP_SELF']}" method="post"> <label for="title">Title:</label><br /> <input name="title" id="title" type="text" maxlength="150" /> <div class="clear"></div> <label for="bodytext">Body Text:</label><br /> <textarea name="bodytext" id="bodytext"></textarea> <div class="clear"></div> <input type="submit" value="Create This Entry!" /> </form> <br /> <a href="display.php">Back to Home</a> ADMIN_FORM; } public function write($p) { if ( $_POST['title'] ) $title = mysql_real_escape_string($_POST['title']); if ( $_POST['bodytext']) $bodytext = mysql_real_escape_string($_POST['bodytext']); if ( $title && $bodytext ) { $created = time(); $sql = "INSERT INTO testDB VALUES('$title','$bodytext','$created')"; return mysql_query($sql); } else { return false; } } public function connect() { mysql_connect($localhost,$ ,$ ) or die("Could not connect. " . mysql_error()); mysql_select_db($this->table) or die("Could not select database. " . mysql_error()); return $this->buildDB(); } private function buildDB() { $sql = <<<MySQL_QUERY CREATE TABLE IF NOT EXISTS testDB ( title VARCHAR(150), bodytext TEXT, created VARCHAR(100) ) MySQL_QUERY; return mysql_query($sql); } } ?> Thanks Alex
  10. Hi, I'm still really new to PHP, but I am trying to build a contact form. So far I have <?php $dontsendemail = 0; $possiblespam = FALSE; $strlenmessage = ""; $email = $_REQUEST['email']; $message = $_REQUEST['message']; $subject = "Twitter Backgraphic/Avatar Sale";$emailaddress = "alex-konetchy@hotmail.com"; function checkcaptcha() { session_start(); if ($_SESSION["pass"] != $_POST["userpass"]) { die("Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again."); return 1; } } function checkemail($field) { // checks proper syntax if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field)) { die("Improper email address detected. Please hit your browser back button and try again."); return 1; } } function spamcheck($field) { if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("% 0A",$field)){ $possiblespam = TRUE; }else $possiblespam = FALSE; if ($possiblespam) { die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again."); return 1; } } function strlencheck($field,$minlength,$whichfieldresponse) { if (strlen($field) < $minlength){ die($whichfieldresponse); return 1; } } if ($dontsendemail == 0) $dontsendemail = checkcaptcha($email); if ($dontsendemail == 0) $dontsendemail = checkemail($email); if ($dontsendemail == 0) $dontsendemail = spamcheck($email); if ($dontsendemail == 0) $dontsendemail = spamcheck($subject); if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br>"); if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br>"); if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br>"); if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $email" ); echo "Thank you for requesting a TwitBackGraphic. We'll look at your message, and start designing your background.<br><br>Good Luck!<br>";} ?> My HTML is <form method="post" id="captcha_form" name="captcha_form" action="mailform.php"> <div class="over">Name: <br><input type="text" size="30" name="name id="name" value=""> </div> <div class="over">Twitter name @twitter.com(username) <br><input type="text" size="30" name="twitter" id="twitter" value=""> </div> <div class="over">Email address: <br><input type="text" size="30" name="email" id="email" value=""> </div> <?php $subject = "Twitter Backgraphic/Avatar Sale"; ?> <div class="over">How would you like your design? Submit all information you want included in your twitbackgraphic<br><span style="font-size:10px;">(Colors, style, twitter name, and other information you want in your design)</span> <br><textarea name="message" id="message" rows="10" cols="60"><?php echo "</tex" . "tarea>"; ?> <br> </div> <div class="over"> <img src="captcha.php" alt="Captcha"> <span style="font- size:10px;">Note: CaSE sEnsITivE</span> <br><input type="text" name="userpass" value=""> </div> <div style="padding-bottom: 1em;"><input name="submit" type="submit" value="Submit"> </div> </form> Could you show me how to make the name and twitter fields show up in the email message. Thanks for the help Alex
  11. @gevans That code you gave me works great. I know that PHP is server side so will it work on all browsers? Thanks
  12. Yeah. I do have some experience in php. I use it as content management, and for other simple functions, but I'm definitely not a professional with it. And yes my server does support PHP @maq I never worked with .htaccess files either, since I never had to use them
  13. Oh sorry, I couldn't find another forum it could fit under. Anyway, I wanted the server to do it automatically. Originally I put this in the index.html file in the home directory: <html> <head> <title>Redirect | KonetchReport</title> <META http-equiv="refresh" content="0;URL=http://www.konetchreport.com/forum"> </head> <body> <div align="center"> <a href="http://www.konetchreport.com/forum">Click this link if the page didn't show up in your browser</a> </div> </body> </html> But everyone see this. So I wanted it to not appear on this page at all and just open into that directory at once.
  14. Hey, This isn't a PHP question, but I was wondering how you redirected to a directory with out using a meta tag in and index.html file. For example the site http://www.sumopaint.com automatically redirects you to http://www.sumopaint.com/web. How would you do this? Thanks Alex Konetchy
×
×
  • 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.