Jump to content

marco sgotto

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Everything posted by marco sgotto

  1. hi everyone !! I'm new with forum and with php... if u think on PHP code structure , to reload/refresh $variables in a page , u simple have to get the $variable from mysql before u write that in the HTML page and after the isset , but put the mysql_connect on top of the page. now : session start connect to mysql make an isset instruction query mysql and get a variable $var and than write the $var. using this scheme theres no problem. exemple : befor this page i have the login.php page with the login form in that page i create the $_SESSION[] array <?PHP session_start(); if( $_SESSION['user'] == NULL){ // I create user in login.php page befor redirect Header("Location: login.page url "); // if no session from login page redirect to login page }else{ mysql_connect('sql.site.com', 'user', 'password') or die(mysql_error()); // connection to database mysql_select_db('database'); } } // end if SESSION //isset case for a POST form if(isset($_POST['submitnew'])){ $new = addslashes($_POST['newtext']); // put value of var from POST in a variable $new mysql_query("UPDATE `table` SET `textsql`= '$new' WHERE id='1' "); // update new values in the database }// end if isset $query = mysql_query("SELECT * FROM `table` WHERE id='1' "); // obtain a value from database (in this case must be after isset) $fetch = mysql_fetch_array($query); $text = $fetch['textsql']; // now the value from database is in a variable called $text ?> <body> <form id='change text' method='post'> <-- now we can write the new value and not the obsolete one without any cache problem --> <-- in this case I write the $text variable in the textarea with PHP echo --> <textarea rows="20" cols="20" name="newtext"> <?PHP echo $text; ?> </textarea> <input type='submit' name='submitnew' value='Update'/> </form> </body> this work for me !! for text and images !! Many thanks -- Marco EDIT: please use code tags & no need to reply to this old of a thread.
×
×
  • 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.