Jump to content

[SOLVED] Admin Notepad


Cory94bailly

Recommended Posts

My code:

 

 

<?php
ob_start();
require 'config.php';

// Make a MySQL Connection
mysql_connect($path, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
//Starts if you click the submit button.
if(isset($_POST['submit']))
{
//Set the variable!
        //Update it!
        $query = "UPDATE notepad SET notepad='$updated'";
        mysql_query($query) or die(mysql_error());
        echo "<meta http-equiv='refresh' content='1;url=index.php'>";
        echo "variables";
    }
    else
    {
    //Error message.
        die('Error!!!!!!!!!');
    }

    list($notepad) = mysql_fetch_row($result);
    //The form.
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
  <p>Text:<br>
     <textarea rows="10" cols="50" name="news"><?php echo $notepad ?></textarea>
  </p>
  <input type="submit" name="submit" value="Submit">
</form>
<?php
//End it!!!
ob_end_flush();
?>

 

Now all I am getting is "Error!!!!!!!!!"

 

Any help?

 

(Btw, I know I did it wrong somehow =/)

Link to comment
Share on other sites

Just noticed.. I didn't define 2 or 3 variables.

 

New code:

<?php
ob_start();
require 'config.php';

// Make a MySQL Connection
mysql_connect($path, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
//Starts if you click the submit button.
if(isset($_POST['submit']))
{
//Set the variable!
        //Update it!
        $query = "UPDATE notepad SET notepad='$updated'";
        $updated = $_POST['updated'];
        mysql_query($query) or die(mysql_error());
        echo "<meta http-equiv='refresh' content='1;url=index.php'>";
    }
    else
    {
    //Error message.
        die('Error!!!!!!!!!');
    }
    $query = "SELECT notepad FROM notepad";
    list($notepad) = mysql_fetch_row($result);
    //The form.
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
  <p>Text:<br>
     <textarea rows="10" cols="50" name="updated"><?php echo $notepad ?></textarea>
  </p>
  <input type="submit" name="submit" value="Submit">
</form>
<?php
//End it!!!
ob_end_flush();
?>

 

Still get "Error!".

Link to comment
Share on other sites

Ok, I got it to atleast show the box now..

 

<?php
ob_start();
require 'config.php';

// Make a MySQL Connection
mysql_connect($path, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
//Starts if you click the submit button.
if(isset($_POST['submit']))
{
//Set the variable!
        //Update it!
        $query = "UPDATE notepad SET notepad='$updated'";
        $updated = $_POST['updated'];
        mysql_query($query) or die(mysql_error());
        echo "<meta http-equiv='refresh' content='1;url=index.php'>";
    }
    $query = "SELECT notepad FROM notepad";
    $result = mysql_query($query);
    list($notepad) = mysql_fetch_row($result);
    //The form.
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
     <textarea rows="10" cols="50" name="updated"><?php echo $notepad ?></textarea>
  <input type="submit" name="submit" value="Submit">
</form>
<?php
//End it!!!
ob_end_flush();
?>

 

But it's not showing the text if I submit it.

Link to comment
Share on other sites

<?php echo $_SERVER['PHP_SELF'] ?>

 

<?php echo $notepad ?>

 

you are missing the ; at the end of each of these.  That is your problem.

 

Again, no it wasn't..

 

Heh, still showing a blank box... I put text in it, submit, and it stays blank..

Link to comment
Share on other sites

        $updated = $_POST['updated'];

 

That line needs to be before this line

 

        $query = "UPDATE notepad SET notepad='$updated'";

 

You need to assign the variable before you can use it.

 

        $updated = $_POST['updated'];

        $query = "UPDATE notepad SET notepad='$updated'";

Link to comment
Share on other sites

Well I got it to work..

 

<?php
ob_start();
require 'config.php';

// Make a MySQL Connection
mysql_connect($path, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
//Starts if you click the submit button.
if(isset($_POST['submit']))
{
//Set the variables!
        //Update it!
        $updated = $_POST['updated'];
        $query = "UPDATE notepad SET text='$updated'";
        mysql_query($query) or die(mysql_error());
        echo "<meta http-equiv='refresh' content='1'>";
    }
    $query = "SELECT text FROM notepad";
    $result = mysql_query($query);
    list($notepad) = mysql_fetch_row($result);
    //The form.
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
     <textarea rows="10" cols="50" name="updated"><?php echo $notepad; ?></textarea>
  <input type="submit" name="submit" value="Submit">
</form>
<?php
//End it!!!
ob_end_flush();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.