Forum Moderators: coopster
Here's what I have that works:
-----------------------------------------------
INPUT PAGE:
<HTML>
<HEAD>
<TITLE>Your Title</TITLE>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<BR>
<?php
$host="----";
$user="---";
$password="----";
$database="----";
// connecting to the database
$Link_ID=mysql_pconnect($host, $user, $password);
if (!$Link_ID)
{
echo "Failed to connect to ".$host;
return 0;
}
if (!@mysql_select_db($database,$Link_ID))
{
echo "<br>Cannot use database=".$database;
}
?>
<center>
<form name="news" method="post" action="news2.php">
<BR>
News content: <textarea name="content" rows="6"></textarea><BR>
Your email: <input type="text" name="email"><BR>
<input name="submit" type="submit" value="Submit">
</form>
<BR><BR>
</center>
</body>
</html>
--------------------------------------
CONFIRMATION PAGE:
<HTML>
<HEAD>
<TITLE>Your Title</TITLE>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<BR>
<?php
$host="----";
$user="---";
$password="---";
$database="----";
// connecting to the database
$Link_ID=mysql_pconnect($host, $user, $password);
if (!$Link_ID)
{
echo "Failed to connect to ".$host;
return 0;
}
if (!@mysql_select_db($database,$Link_ID))
{
echo "<br>Cannot use database=".$database;
}
// sets info from previous pages into variables
$date = date("M d Y");
$content = $_POST['content'];
$email = $_POST['email'];
// inserts info into the table news
$insert = "INSERT INTO news ( content, email )
values( '$content', '$email' )";
// displays error or success message
if (! mysql_query( $insert ) ) {
die( "Couldn't add data to the table. You are now being taken back to the main page." );
} else {
echo "Your data was added to the table. You are now being taken back to the main page.";
}
?>
<BR><BR>
</center>
</body>
</html>
-----------------------------------------------------
So what I need to do, is have the confirmation page redirect to a page that can display the contents on the table in the DB.
Thanks,
Ian
Have you had a look at the PHP Forum Library [webmasterworld.com]? There is a short little tutorial in there describing how the Basics of extracting data from MySQL [webmasterworld.com].