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
https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/
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
https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551250
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
https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551259
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
https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551268
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
https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551276
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
https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551280
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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