Hello
I am very new to php and progaming. I am setting up a guestbook in two languages. I got this code for my main page:
<html>
<head>
<?
if(empty($lang)){
$lang = "eng";
}
?>
<title>Test Guestbook</title>
</head>
<tr>
<td valign="top" class="main"><img src="images/spacer.gif" height="1" width="1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right" class="prodtitle"><img src="images/spacer.gif" height="20" width="1">
<a href="test_guest.php?lang=<? if ($lang=="fra") { print "eng"; } else { print "fra"; } ?>"><? if ($lang=="fra") { print "English"; } else { print "Français"; } ?>
</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="200" border="0">
<tr>
<td>
<center>
<h1>Forum</h1>
</center>
<form method="post" action="guess\new.php" name="new">
<center>
<table width="300" border="0">
<tr>
<td width="56" rowspan="2"></td>
<td width="28">
<? if ($lang=="fra") { print "Nom :"; } else { print "Name :"; } ?></td>
<td width="281"><input name="name" type="text" size=40></td>
</tr>
<tr>
<td><? if ($lang=="fra") { print "Courriel :"; } else { print "Email :"; } ?></td>
<td><input name="mail" type="text" size=40></td>
</tr>
<tr>
<td colspan="3">
<center>
<? if ($lang=="fra") { print "Vos Commentaires :"; } else { print "Your Comments :"; } ?></center>
</td>
</tr>
<tr>
<td colspan="3">
<center>
<textarea name="mess" cols="40" rows=5></textarea>
<table width="300" border="0">
<tr>
<input type="submit" value="<? if ($lang=="fra") { print "Envoyer :"; } else { print "Submit :"; } ?>"><td width="56" rowspan="2"></td>
</tr>
<tr></tr>
</table>
</center>
</td>
</table>
</center>
</form>
<p>
<?
$MessOnScreen=15;
$base="guess\base.txt";
$file = file($base);
$files = array_reverse($file);
if(sizeof($files)<$MessOnScreen)$MessOnScreen=sizeof($files);
for ($i=0; $i < $MessOnScreen; $i++)
{
$mess=explode("^^",$files[$i]);
echo "From: <b>".$mess[0]."</b><br>";
echo "E-mail: ".$mess[1]."<br>";
echo "Date: ".$mess[2]."<br>";
echo "Writing: <br>".$mess[3]."<br>";
echo "<br>";
}
?>
</p>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
and the code for the message receiving page is :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<?php
$base="base.txt";
global $name, $mail, $mess, $base;
if(empty($name) || empty($mess))
{
echo "<script>alert('Nothing Entered');";
echo "window.open('../test_guest.php', '_self')</script>";
exit();
}
$file=file($base);
$file=implode("",$file);
$mess=preg_quote($mess);
if(eregi($mess, $file))
{
echo "<script>alert('nothing');";
echo "window.open('../test_guest.php', '_self')</script>";
exit();
}
$mess=stripslashes($mess);
$name=htmlspecialchars($name);
$mail=htmlspecialchars($mail);
$mess=str_replace("\n","<br>",$mess);
$date=date("d.m.y - H:i:s");
$text=$name."^^".$mail."^^".$date."^^".$mess."\n";
$fp=fopen($base,"a");
fputs($fp, $text);
fclose($fp);
echo "<script>alert('You successfully added you message');";
echo "window.open('../test_guest.php', '_self')</script>";
?>
</body>
</html>
All works well at first untill I switch the languages on the page and I get a blank page. I am guessing but there should be a code inside this
<script>alert('You successfully added you message');";
echo "window.open('../test_guest.php', '_self')</script>
telling it when it changes from english to french to revert back to my main page plus the languages something like this.
test_guest.php?lang=<? if ($lang=="fra") { print "fra"; } else { print "eng"; } ?>
Any ideas. Many thanks for you time and help and sorry for the long winded explanation but I am really out of ideas.
CH