Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 05-11-2006, 11:09 PM Refreshing!!
Junior Talker

Posts: 3
Trades: 0
Heres the problem. Im creating a guestbook using php. I tried many scripts to try and refresh the page after an entry. None works. Now im stuck i need some help.

This is the url to my guestbook: http://www.bangkokcityonline.com/guestbook.php

here is the script for the guestbook:

<? include('testimonial.php') ?>

<?php

if (isset ($_POST['submit']))
{
if ($dbh = mysql_connect ('localhost', '*********', '******'))
{
if (!@mysql_select_db ('koulaid_entry'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
}

$title = $_POST['title'];
$text = $_POST['entry'];
$id = $_POST['id'];
$query = "INSERT INTO gbook (name_id, title, text) VALUES ('$id','$title', '$text')";
if (@mysql_query ($query))
{
print '<p>Thank you for the comments.</p>';
}
else
{
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
print '<b>Name:&nbsp;</b>' . ($_POST['id']) . '<br />';
print '<b>Subject:&nbsp;</b>' . ($_POST['title']) . '<br />';
print '<b>Comments:&nbsp;</b>' . ($_POST['entry']) . '<br />';

mysql_close();
}




/*
END OF PHP SCRIPT
*/
?>

<body>

<table class="guestbook">
<tr>
<td style="padding-top: 17px;">
<form action="guestbook.php" method="POST">
<table cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td colspan="2"><h3 align="center">Leave a comment</h3></td>
</tr>
<tr>
<td>Name:
</td>
<td><input type="text" name="id" maxlength="255" value="<?=$_POST['id']?>">
</td>
</tr>
<tr>
<td>Subject:
</td>
<td><input type="text" name="title" maxlength="255" value="<?=$_POST['title']?>">
</td>
</tr>
<tr>
<td>Comments:
</td>
<td><textarea name="entry" value="<?=$_POST['entry']?>" maxlength="255"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value="&nbsp;Sign&nbsp;" />
</td>
</table>
</form>
</td>
</tr>
</table>
</body>




here is the include script testimonial.php:

<head>
<style type="text/css">
body
{
background-color: FFEECC;
}
hr
{
width: 300px;
text-align: left;
}
table.main
{
vertical-align: middle;
}
table.guestbook
{
border-style: dotted;
height: 180px;
width: 300px;
}

font.font
{
font-size: 18;
color: 851325;
}
</style>
</head><body>
<h1 align="center">Bangkok City Thai Cuisine's Guestbook</h1><br>
<h2>Feedbacks/Testimonials</h2><br><br>

<!----------- BEGINNING OF PHP SCRIPT ----------------------->

<?
if ($dbh = mysql_connect ('localhost', 'koulaid_kou', 'jackpot'))
{
if (!@mysql_select_db ('koulaid_entry'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
}

$query = 'SELECT * FROM gbook';
if ($result = mysql_query ($query))
{
while ($row = mysql_fetch_array ($result))
{
$field1= $row["name_id"];
$field2= $row["title"];
$field3= $row["text"];

echo "<font class='font'>Name:</font> <b>$field1</b><br>";
echo "<font class='font'>Subject:</font> <b>$field2</b><br>";
echo "<font class='font'>Comments:</font> <b>$field3</b><br>";
echo "<table><tr><td><hr width='300px'></td></tr></table>";
}
}
else
{
die ('could not get it cuz: <b>' . mysql_error() . "</b> . the query was $query");
}

mysql_close();
?>
</body></html>
koulaid is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-11-2006, 11:14 PM Re: Refreshing!!
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
could you not put a refresh value in the form people use to post?
Then on the page have
PHP Code:
<?php
//  If $_POST['refresh'] isn't  empty
if(!empty($_POST['refresh']))
{
echo 
"some refresh code";
}
?>
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 05-11-2006, 11:20 PM Re: Refreshing!!
Junior Talker

Posts: 3
Trades: 0
Quote:
Originally Posted by stOx
could you not put a refresh value in the form people use to post?
Then on the page have
PHP Code:
<?php
// If $_POST['refresh'] isn't empty
if(!empty($_POST['refresh']))
{
echo 
"some refresh code";
}
?>
yea but i want it to refresh automatically right after someone posts
koulaid is offline
Reply With Quote
View Public Profile
 
Old 05-12-2006, 12:28 AM Re: Refreshing!!
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
It will.

The form has to post to a page, So if on that page it has some php to check if a "refresh" value has been posted (which it will be if they have just posted) you can then use that to echo some refresh code ( either a meta refresh or php header location )
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 05-13-2006, 12:28 AM Re: Refreshing!!
Junior Talker

Posts: 3
Trades: 0
Quote:
Originally Posted by stOx
It will.

The form has to post to a page, So if on that page it has some php to check if a "refresh" value has been posted (which it will be if they have just posted) you can then use that to echo some refresh code ( either a meta refresh or php header location )

k thx.. but i found another way to make it work. thx anyways
koulaid is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Refreshing!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33775 seconds with 12 queries