Jump to content
Larry Ullman's Book Forums

michiel

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by michiel

  1. Ok, maybe I'm just making it unnessarily difficult for myself. Thanks for your reply.
  2. The idea I had was this: have the website in a directory (in this case called html, but it could be named anything.) and put other files 'above' it, namely the .htpasswd file I quote: ...This is the file that contains all the usernames and encrypted passwords for your site. It's extremely important that you place this file outside of the web root. You should only be able to access it by FTP, not over the web...
  3. I want to redirect a my site url to a directory on the server.. I ftp the site to a folder: html/myfiles... (not directly in the root, so that I can place other files there htaccess pswds etc) my host says I should use this code: RewriteEngine On Options +FollowSymlinks RewriteBase / RewriteCond %\{HTTP_HOST\} site.com RewriteCond %\{REQUEST_URI\} !^/html/? RewriteRule ^(.*)$ html/$1 [L] But when I place the htaccess file in the root (that is the area when I arrive when I ftp?) I get a internal server error. (site.com is an example) I tried mod alias aswell... It shouldn't be that hard?
  4. Hi, I installed pear on my computer and built a site using html_QuickForm2. All very nice. Then I upload the site to my shared webhost and the pages that have the quickform in it are not showing. Pear is installed (I can see this in the php info file.) The path would be: .:/usr/share/pear:/usr/share/php My code now is like this (but still no show ;-( $path = '.:/usr/share/pear:/usr/share/php'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require('HTML/QuickForm2.php'); Do I have to upload the quickform files aswell? And where would I put them?
  5. Hi, This works ... if (!$user->canEditPage(new Page($id))) { header("Location:index.php"); exit;}
  6. is this what we want? if (!$user->canEditPage(new Page($_GET['id']))) { header("Location:index.php"); exit;}
  7. Hi, one last question regarding this code. Specifically this snippet: if (!$user->canEditPage(new Page)) { header("Location:index.php"); exit;} Is this the right way to make the object from the page class? The parameter works, but it doesnt seem right to me. I havent seen this before. The site is coming along fine otherwise.
  8. Succes! Thank you for the lead. I went for the hidden form input method. It works now. Now up to the next task: delete the page ;-) Michiel
  9. Still having trouble :-( The problem is the UPDATE .... WHERE...statement. I dont know how to retireve the page id. I tried with $page->getId( ) ; $_GET['id']. Etc. Now: with the code below I can edit and update the data base, except: I update all the rows (as expected, but hey: the connection works). Any suggestions? <?php # edit page.php require('includes/utilities.inc.php'); //code is dubious!!!!!!!!! if (!$user->canEditPage(new Page)) { header("Location:index.php"); exit;} //-------------------------------------------- // Create a new form: set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/local/pear/share/pear/'); require('HTML/QuickForm2.php'); $form = new HTML_QuickForm2('EditPageForm'); // Het titel invoerveld: $title = $form->addElement('text', 'title'); $title->setLabel('Pagina titel'); $title->addFilter('strip_tags'); $title->addRule('required', 'Vul een pagina titel in'); // Het verhaal invoerveld: $content = $form->addElement('textarea', 'content'); $content->setLabel('Je verhaal'); $content->addFilter('trim'); $content->addRule('required', 'Voer je tekst in'); // De 'voeg toe' button: $submit = $form->addElement('submit', 'submit', array('value'=>'Update deze pagina')); //prepare statement: $q = 'SELECT id, title, content FROM pages WHERE id=:id'; $stmt = $pdo->prepare($q); $r = $stmt->execute(array( ':id' => $_GET['id'])); if ($r) { // fetch the page content from database as object: $stmt->setFetchMode(PDO::FETCH_CLASS, 'Page'); while ($page = $stmt->fetch()) { // populate the form with the data: $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array( 'title' => $page->getTitle(), 'content'=> $page->getContent() ))); } } if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form submission // Validate the form data: if ($form->validate()) { $q = 'UPDATE pages SET title=:title , content=:content'; //WHERE id=:id'; $stmt = $pdo->prepare($q); $s=$stmt->execute(array(':title'=> $title->getValue(), ':content' => $content->getValue())); //how to retrieve the id of this page? if ($s) { $form->toggleFrozen(true); $form->removeChild($submit); } } // End of form validation IF. } // End of form submission IF. // Show the page: $pageTitle = 'Edit page'; include('includes/header.inc.php'); include('views/edit_page.html'); include('includes/footer.inc.php'); ?>
  10. Solved it! But new problem arises: the edits are 'updated' in the form but not in the database..
  11. Hi, I try to create the edit_page.php I am able to to retrieve the data from the data base and populate the new html quickform using addDataSource method. This is my pdo statement: $stmt = $pdo->prepare('SELECT title, content FROM pages WHERE id=:id'); $stmt->execute(array( ':id' => $_GET['id'])); $stmt->setFetchMode(PDO::FETCH_CLASS, 'Page'); $result=$stmt->fetch(); //then I create new form (I dont paste the whole code here) and pull content from database in form using addDataSource. So far it works: $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array( 'title' => $result->getTitle(), 'content'=> $result->getContent() ))); When I press submit to UPDATE I get this message: FATAL ERROR: Call to a member function getTitle() on a non-object same for the second result: FATAL ERROR: Call to a member function getContent() on a non-object Can you point me a direction where to look? I suspect this is wrong: $result=$stmt->fetch(); yet it seems to work...
×
×
  • Create New...