Rispondi 
Pagine (2): « Prima [1] 2 Successiva > Ultima »
Creare pagina in php da editare online!
Modalità discussione Modalità lineare
25-05-2008, 13:49
Messaggio: #1 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

Creare pagina in php da editare online!


Ciao a tutti!
Parlo a voi esperti di php xD, io vorrei creare delle pagine in php da poter editare direttamente online! un pò tipo wikipedia, le pagine si possono editare online e cambiare i contenuti all' interno. Sarebbe difficile creare una cosa del genere? esiste qualche guida che spighi come fare?

Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 13:55
Messaggio: #2 (permalink)
L'avatar di djremix djremix
Moderatore
*****
Registrato: Apr 2008
Messaggi: 79
Reputazione:

RE: Creare pagina in php da editare online!


Ciao, guarda un CMS fa al caso tuo. Il CMS è una piattaforma dove puoi scegliere tu i contenuti da mettere, ed è gestibile direttamente online. Se non vuoi ricorrere al CMS di pure.

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 15:49
Messaggio: #3 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

RE: Creare pagina in php da editare online!


Tranquillo so che cosè un cmsn xD, ma non volevo usare un cms in quanto il mio devo fare questo lavoro su un sito in html! Se uso tipo joomla, mkportal o altri tipi di cms sarei costretto a rifare tutto il sito...

Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 16:05
Messaggio: #4 (permalink)
L'avatar di Giuseppe Giuseppe
Super Moderatore
******
Registrato: Sep 2007
Messaggi: 259
Reputazione:

RE: Creare pagina in php da editare online!


Non penso sia difficilissimo, ma nemmeno banale (specialmente se non hai un pò di dimestichezza con il php). Stai per costruire un cms...

Guide non ne conosco, penso comunque che ne esistano...

Il contenuto delle pagine vuoi salvarlo nel database o vorresti creare dei veri e propri file con estensione php (puoi utilizzare funzioni del tipo fopen, fwrite, fclose ecc..)?

PS: Potresti pensare di installare un cms in una sottodirectory di quella principale... In questo modo quello che hai già fatto resta com'è...

Ciao

Vuoi collaborare col furum PW?
Se sei interessato puoi contattare privatamente un moderatore o un amministratore ciao

SERP Analyzer 2
3D Box Creator[puoi collaborare anche tu!!!]
Tool per creare le tue sitemap

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 16:48
Messaggio: #5 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

RE: Creare pagina in php da editare online!


No non voglio creare dei veri e propri file con estensione php, per i cms no non ne voglio usare in quanto devo fare un piccolo lavoro e non un sito intero quindi usare un cms non fà al caso mio 07.
Comunque se mi dici che esistono delle guide proverò a cercarle! Grazie......

Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 18:24
Messaggio: #6 (permalink)
L'avatar di mar mar
Apprendista
**
Registrato: Dec 2007
Messaggi: 26
Reputazione:

RE: Creare pagina in php da editare online!


Come non vuoi creare file con estensione php!O_O
Ciò che descrivi non puoi mica farlo con semplici pagine html...

Visita www.phelproject.net , il sito dedicato ai miei script e ai miei progetti e Phelpp il mio blog con news dal mondo del web-scripting e dei miei progetti.

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 19:01
Messaggio: #7 (permalink)
L'avatar di djremix djremix
Moderatore
*****
Registrato: Apr 2008
Messaggi: 79
Reputazione:

RE: Creare pagina in php da editare online!


mar ha ragione. Se devi fare una cosa del genere DEVI usare lestensione .php altrimenti se metti php in html e salvi come .html non funziona. Comunque ora ti dò delle dritte (semplice form, dove inserisci dei dati e si aggiungono ad una tabella in htm).
P.S. Richiede l'uso di mysql.
Allora per la creazione e gestione del database che dovremmo usare per salvare i contenuti ti consiglio di scaricare la libreria "ezSQL Database Class". Una volta scaricapo il pacchetto zip estrai il file "ez_sql.php" contenuto nella cartella "MySQL" e copialo nella directory del web server. Poi apri il file e modificachiamo le seguenti stringhe:

Codice PHP:
define("EZSQL_DB_USER""root");
//<-- mysql db user
define("EZSQL_DB_PASSWORD""[b]metti una password[/b]");
//<-- mysql db password
define("EZSQL_DB_NAME""my_db");
//<-- mysql db name
define("EZSQL_DB_HOST""localhost");
//<-- mysql server host 


Ora è il momento di mettersi all'opera wink
Creaimo un file chiamato inserimento.html
e mettiamo questo codice (che se sei in grado lo personalizzi da solo)

Codice PHP:
<html>
<
head><title>Visualizzazione tabella</title></head>
<
body>
<
h1>Inserimento dati</h1>
<
form action="inserisci.php" type="post">
<
p>Titolo: <input type="text" maxlenght="150" name="titolo"></p>
<
p>Testo: <br /><textarea rows="7" name="testo"></textarea>
<
p><input type="submit" value="Inserisci"></p></form></body></html

Ora crea il file inserisci.php

Codice PHP:
<html><head><title>Visualizzazione tabella</title></head>
<
body><h1>Dati inseriti</h1>
<
table border="1" width="95%"><tr><th>N.</th><th>Titolo</th><th>Testo</th></tr>
<?
php
require_once('ez_sql.php');
$dato $db->get_results("SELECT * FROM dati");
foreach ( 
$dato as $dati ) {
echo 
"<tr>\n";
echo 
"<td>" $dato->id "</td>\n";
echo 
"<td>" $dato->titolo "</td>\n";
echo 
"<td>" $dato->testo "</td>\n";
echo 
"</tr>\n";
}
?>
</body></html> 


Con questo semplice script (forse) otterrai quello che vorrai 07
Ciao e fammi sapere.


Ultima modifica di Giuseppe : 25-05-2008 alle ore 20:59.

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 19:34
Messaggio: #8 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

RE: Creare pagina in php da editare online!


mar ha scritto:
Come non vuoi creare file con estensione php!O_O
Ciò che descrivi non puoi mica farlo con semplici pagine html...


ho sbagliato a scrivere, volevo dire che voglio creare delle pagine in php!
Scusami errore mio....wink


Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 19:37
Messaggio: #9 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

RE: Creare pagina in php da editare online!


Ok grazie djremix, domani lo proverò! speriamo che funzioni così...ma ad esempio posso fare solo che la parte da editare sia il centro della pagina di un sito?

Esempio: Il mio sito è cambiagames.com posso fare che la parte modificabile sia solo il centro della pagina? e il resto del sito rimanga uguale per tutti...

Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 20:05
Messaggio: #10 (permalink)
L'avatar di djremix djremix
Moderatore
*****
Registrato: Apr 2008
Messaggi: 79
Reputazione:

RE: Creare pagina in php da editare online!


Con quello script puoi attraverso un frame o un ssi richiamare la pagina inserisci.php e uscirà una tabella vuota. Poi tramite la pagina in html compili i form e la tabella si riempira con i dati messi nei form.

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 20:11
Messaggio: #11 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

RE: Creare pagina in php da editare online!


a quindi si può fare all' interno di un sito già fatto in hmtl tipo cambiagames.com giusto? è proprio quello che cercavo, domani provo a farlo andare xD

Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 20:17
Messaggio: #12 (permalink)
L'avatar di djremix djremix
Moderatore
*****
Registrato: Apr 2008
Messaggi: 79
Reputazione:

RE: Creare pagina in php da editare online!


ok 07

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 20:29
Messaggio: #13 (permalink)
L'avatar di Cambiagames Cambiagames
Webmaster PW
*****
Registrato: May 2007
Messaggi: 451
Reputazione:

RE: Creare pagina in php da editare online!


Ciao, ho scaricato il pacchetto ezSQL Database Class dentro la cartella mysql ce solo il file ez_sql_mysql.php presumo sia questo giusto? ho apero il file e ho trovato questo:

Codice PHP:
<?php

    
/**********************************************************************
    *  Author: Justin Vincent (justin@visunet.ie)
    *  Web...: http://php.justinvincent.com
    *  Name..: ezSQL_mysql
    *  Desc..: mySQL component (part of ezSQL databse abstraction library)
    *
    */

    /**********************************************************************
    *  ezSQL error strings - mySQL
    */

    
$ezsql_mysql_str = array
    (
        
=> 'Require $dbuser and $dbpassword to connect to a database server',
        
=> 'Error establishing mySQL database connection. Correct user/password? Correct hostname? Database server running?',
        
=> 'Require $dbname to select a database',
        
=> 'mySQL database connection is not active',
        
=> 'Unexpected error while trying to select database'
    
);

    
/**********************************************************************
    *  ezSQL Database specific class - mySQL
    */

    
if ( ! function_exists ('mysql_connect') ) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQL Lib to be compiled and or linked in to the PHP engine');
    if ( ! 
class_exists ('ezSQLcore') ) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used');

    class 
ezSQL_mysql extends ezSQLcore
    
{

        var 
$dbuser false;
        var 
$dbpassword false;
        var 
$dbname false;
        var 
$dbhost false;

        
/**********************************************************************
        *  Constructor - allow the user to perform a qucik connect at the
        *  same time as initialising the ezSQL_mysql class
        */

        
function ezSQL_mysql($dbuser=''$dbpassword=''$dbname=''$dbhost='localhost')
        {
            
$this->dbuser $dbuser;
            
$this->dbpassword $dbpassword;
            
$this->dbname $dbname;
            
$this->dbhost $dbhost;
        }

        
/**********************************************************************
        *  Short hand way to connect to mySQL database server
        *  and select a mySQL database at the same time
        */

        
function quick_connect($dbuser=''$dbpassword=''$dbname=''$dbhost='localhost')
        {
            
$return_val false;
            if ( ! 
$this->connect($dbuser$dbpassword$dbhost,true) ) ;
            else if ( ! 
$this->select($dbname) ) ;
            else 
$return_val true;
            return 
$return_val;
        }

        
/**********************************************************************
        *  Try to connect to mySQL database server
        */

        
function connect($dbuser=''$dbpassword=''$dbhost='localhost')
        {
            global 
$ezsql_mysql_str$return_val false;

            
// Must have a user and a password
            
if ( ! $dbuser )
            {
                
$this->register_error($ezsql_mysql_str[1].' in '.__FILE__.' on line '.__LINE__);
                
$this->show_errors trigger_error($ezsql_mysql_str[1],E_USER_WARNING) : null;
            }
            
// Try to establish the server database handle
            
else if ( ! $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword,true) )
            {
                
$this->register_error($ezsql_mysql_str[2].' in '.__FILE__.' on line '.__LINE__);
                
$this->show_errors trigger_error($ezsql_mysql_str[2],E_USER_WARNING) : null;
            }
            else
            {
                
$this->dbuser $dbuser;
                
$this->dbpassword $dbpassword;
                
$this->dbhost $dbhost;
                
$return_val true;
            }

            return 
$return_val;
        }

        
/**********************************************************************
        *  Try to select a mySQL database
        */

        
function select($dbname='')
        {
            global 
$ezsql_mysql_str$return_val false;

            
// Must have a database name
            
if ( ! $dbname )
            {
                
$this->register_error($ezsql_mysql_str[3].' in '.__FILE__.' on line '.__LINE__);
                
$this->show_errors trigger_error($ezsql_mysql_str[3],E_USER_WARNING) : null;
            }

            
// Must have an active database connection
            
else if ( ! $this->dbh )
            {
                
$this->register_error($ezsql_mysql_str[4].' in '.__FILE__.' on line '.__LINE__);
                
$this->show_errors trigger_error($ezsql_mysql_str[4],E_USER_WARNING) : null;
            }

            
// Try to connect to the database
            
else if ( !@mysql_select_db($dbname,$this->dbh) )
            {
                
// Try to get error supplied by mysql if not use our own
                
if ( !$str = @mysql_error($this->dbh))
                      
$str $ezsql_mysql_str[5];

                
$this->register_error($str.' in '.__FILE__.' on line '.__LINE__);
                
$this->show_errors trigger_error($str,E_USER_WARNING) : null;
            }
            else
            {
                
$this->dbname $dbname;
                
$return_val true;
            }

            return 
$return_val;
        }

        
/**********************************************************************
        *  Format a mySQL string correctly for safe mySQL insert
        *  (no mater if magic quotes are on or not)
        */

        
function escape($str)
        {
            return 
mysql_escape_string(stripslashes($str));
        }

        
/**********************************************************************
        *  Return mySQL specific system date syntax
        *  i.e. Oracle: SYSDATE Mysql: NOW()
        */

        
function sysdate()
        {
            return 
'NOW()';
        }

        
/**********************************************************************
        *  Perform mySQL query and try to detirmin result value
        */

        
function query($query)
        {

            
// Initialise return
            
$return_val 0;

            
// Flush cached values..
            
$this->flush();

            
// For reg expressions
            
$query trim($query);

            
// Log how the function was called
            
$this->func_call "\$db->query(\"$query\")";

            
// Keep track of the last query for debug..
            
$this->last_query $query;

            
// Count how many queries there have been
            
$this->num_queries++;

            
// Use core file cache function
            
if ( $cache $this->get_cache($query) )
            {
                return 
$cache;
            }

            
// If there is no existing database connection then try to connect
            
if ( ! isset($this->dbh) || ! $this->dbh )
            {
                
$this->connect($this->dbuser$this->dbpassword$this->dbhost);
                
$this->select($this->dbname);
            }

            
// Perform the query via std mysql_query function..
            
$this->result = @mysql_query($query,$this->dbh);

            
// If there is an error then take note of it..
            
if ( $str = @mysql_error($this->dbh) )
            {
                
$is_insert true;
                
$this->register_error($str);
                
$this->show_errors trigger_error($str,E_USER_WARNING) : null;
                return 
false;
            }

            
// Query was an insert, delete, update, replace
            
$is_insert false;
            if ( 
preg_match("/^(insert|delete|update|replace)\s+/i",$query) )
            {
                
$this->rows_affected = @mysql_affected_rows();

                
// Take note of the insert_id
                
if ( preg_match("/^(insert|replace)\s+/i",$query) )
                {
                    
$this->insert_id = @mysql_insert_id($this->dbh);
                }

                
// Return number fo rows affected
                
$return_val $this->rows_affected;
            }
            
// Query was a select
            
else
            {

                
// Take note of column info
                
$i=0;
                while (
$i < @mysql_num_fields($this->result))
                {
                    
$this->col_info[$i] = @mysql_fetch_field($this->result);
                    
$i++;
                }

                
// Store Query Results
                
$num_rows=0;
                while ( 
$row = @mysql_fetch_object($this->result) )
                {
                    
// Store relults as an objects within main array
                    
$this->last_result[$num_rows] = $row;
                    
$num_rows++;
                }

                @
mysql_free_result($this->result);

                
// Log number of rows the query returned
                
$this->num_rows $num_rows;

                
// Return number of rows selected
                
$return_val $this->num_rows;
            }

            
// disk caching of queries
            
$this->store_cache($query,$is_insert);

            
// If debug ALL queries
            
$this->trace || $this->debug_all $this->debug() : null ;

            return 
$return_val;

        }

    }

?>


Programmi e giochi nokia
Temi Free Per Cellulari
Blog Telefonia

Ultima modifica di Giuseppe : 25-05-2008 alle ore 20:58.

Visita sito dell'autore trova tutti i messaggi dell'autore Quota questo messaggio nella risposta
25-05-2008, 20:38
Messaggio: #14 (permalink)
L'avatar di djremix djremix
Moderatore
*****