Hello all,
How can I take a form text and send it to a MySQL database?
Is this the right code for sending the text to a save.php file?
<form action="save.php" name="editor" method="post">
What about that save.php file, what does it need to send the data to the database?
This is the present code in the save.php file
<?php
include("db_connect.php");
// echo "<input name=NAME>" as $NAME
$result = mysql_query("UPDATE page SET title = '$title', changedate = '$changedate', date = '$date', author = '$author', pagename = '$pagename', document = '$Body', sideheadlines = '$sideheadlines', sidedocument = '$sidedocument' WHERE id = '$id'");
?>
This is the code in the index file where the form is:
<form action="save.php" name="editor" method="post">
<table align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<?
include('db_connect.php');
$result = mysql_query("SELECT id,pagename FROM page");
echo mysql_error();
while($array = mysql_fetch_row($result))
{
echo '<a href="'.$_SERVER['PHP_SELF'].'?open='.$array[0].'">'.$array[1].'</a><br>';
}
if($open!='')
{
$result = mysql_query("SELECT title, changedate, date, author, pagename, document, sideheadline, sidedocument FROM page WHERE id=$open");
while($pageinfo = mysql_fetch_row($result))
{
$title=$pageinfo[0];
$changedate=$pageinfo[1];
$date=$pageinfo[2];
$author=$pageinfo[3];
$pagename=$pageinfo[4];
$document=$pageinfo[5];
$sideheadlines=$pageinfo[6];
$sidedocument=$pageinfo[7];
}
}
?>
</td>
<td>
Title: <? echo '<input name="title" value="'.$title.'">'; ?>
What am I missing?