Hello !!!
I’m launching my website in a few hours, and I just noticed something very annoying, that I don’t know how to fix…
It’s surely something extremely easy, but I’m in a lot of stress and panic right now, so I can’t think properly.
Here is my problem, I have this php script that I wrote from a tutorial, and when I click the submit button, it opens a new page, whereas I want it to open in the same page ( target=_top)
I’m sure it’s easy.
[code=php]
<? include’cookiecheck.php’; ?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Les Enfants de l’Ô – Tagboard</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<? include($headervar.$skin.$extension); ?>
<div id=”tag”></div>
<div align=”center” id=”tagboard” class=”border padding”>
<?php
// SQL database Variables
$hostname=”sql.free.fr”;
$user=”myusername”;
$pass=”mypasswd”;
$dbase=”enfantsdelo”;
$connection = mysql_connect(“$hostname” , “$user” , “$pass”);
$db = mysql_select_db($dbase , $connection);
// query database to list the records
$q = “select * from shoutbox order by id desc limit 35 “;
$result = mysql_query($q);
while ($row = mysql_fetch_array($result))
{
$id = $row[“id”];
$name=$row[“name”];
$url = $row[“url”];
$msg = $row[“msg”];
$olddate= $row[“date”];
//put the date in french format
$newdate = date(“d-m-Y”,strtotime($olddate));
$heure = date (“H:i”, strtotime($olddate));
// format how you want the shout box to display the entries here.
if ( $url == ” || $url == ‘http://’ )
{
echo “<p class=”small nflb”><b>$name</b>: $msg<br><em>[$newdate ($heure)]</em></p>”;
}
else
{
echo “<p class=”small nflb”><b><a href=”$url” target=”new”>$name</a></b>: $msg<br><em>[$newdate ($heure)]</em></p>”;
}
}
?>
</div>
<form action=”chat/post.php” method=”post” target=”tagboard”>
<table width=”100%” border=”0″>
<tr>
<td><div align=”center”>Nom :<br>
<input type=”text” name=”name” class=”form small”></div></td>
<td><div align=”center”>URL :<br>
<input type=”text” name=”url” value=”http://” class=”form small”></div></td>
</tr>
<tr>
<td colspan=”2″><div align=”center”>Message :<br>
<textarea cols=”47″ rows=”3″ name=”msg” class=”form small”></textarea></div></td>
</tr>
</table>
<div align=”center”><input type=”submit” class=”submit” value=”Go go go !”></div>
</form>
<? include(‘tag.php’);
include(‘footer.php’);?>
that’s the tagboard page. And here comes the post.php file :
[code=php]
<?php
// SQL database Variables
$hostname=”sql.free.fr”;
$user=”myusername”;
$pass=”mypasswd”;
$dbase=”enfantsdelo”;
$connection = mysql_connect(“$hostname” , “$user” , “$pass”);
$db = mysql_select_db($dbase , $connection);
// do a basic check, don’t let user submit a blank entry.
if ($name == ” || $msg == ” )
{
include(‘../msg.php’);
echo “On n’a pas oublié quelque chose, par hasard ? Cliquez sur le bouton retour pour ne pas perdre les informations déjà inscrites.”;
include(‘../bottomf.php’);
die;
}
// strips off weird characters and HTML tags
$name = htmlspecialchars($name);
$msg = htmlspecialchars($msg);
// do check here
$last_entry = “select * from shoutbox order by id desc limit 1”;
$check = mysql_query($last_entry);
while ($row = mysql_fetch_array($check))
{
$oldname = $row[“name”];
$oldmsg = $row[“msg”];
}
// compare the values of old and new entry
if ($oldname == $name && $oldmsg == $msg) // means the name and msg entered is the same
{
include(‘../msg.php’);
echo “Bon, je peux comprendre qu’on soit enthousiaste, mais tout de même, il y a des limites… Cliquez sur le bouton retour pour ne pas perdre les informations déjà inscrites.”;
include(‘../bottomf.php’);
die;
}
// insert into database
$q = “insert into shoutbox (id,name,msg,url,date) VALUES (”,’$name’,’$msg’,’$url’,now()) “;
$result = mysql_query($q);
if ($result)
{
// success so redirect user to view shoutbox.
$siteurl = ‘../chat.php’;
header(‘Location: ‘.$siteurl); // this is probably what has to be changed, if I guess right.
}
?>
thanks for all the help !!!