I got a little php-chat-function wich is suppose to let people write a little comment about a place they've visitted. Therfore I want the visitors to be able to select a destination from a pulldown-list.
<form method="post" name="my_form">
<select name="select" style="color:#2c7281;" onfocus="this.value = 'destination'">
<OPTION value="Cannes"> Cannes</option>
</select></form>
<?php
if ( isset( $_POST[ 'submit' ] ) ) {
$dest = $_POST ['destination'];
If ($dest === "") {
echo "<font color=red><b>You must select a destination!</font></b>";
die;
}
$dest = $_POST ['destination'];
$fp = $file = fopen( "messages.php", "a");
fwrite($file, $dest);
rewind($fp);
fclose($fp);
echo '<script type="text/javascript">window.location ="";</script>';
}
?>
Any idea why this won't work? not only doesn't it write, it also bypass my rule of "you must select a destination"
In advance, thank you
Try this:
<form method="post" name="my_form">
<select name="destination" style="color:#2c7281;">
<OPTION value=""> Select your destination...</option>
<OPTION value="Cannes"> Cannes</option>
</select></form>
<?php
if ( isset( $_POST[ 'submit' ] ) ) {
$dest = $_POST ['destination'];
if ($dest === "") {
echo "<font color=red><b>You must select a destination!</font></b>";
die;
}
$dest = $_POST ['destination'];
$fp = $file = fopen( "messages.php", "a");
fwrite($file, $dest);
rewind($fp);
fclose($fp);
echo '<script type="text/javascript">window.location ="";</script>';
}
?>