thanx for the replay :-)
My code is very "messy" and it will be great if you will check it out :
if(isset($submit)) // if form submited
{
global $id ;
$msg = htmlspecialchars($msg);
$msg = nl2br($msg) ;
//smiles :-)
if(!isset($smile_check)){
$msg = str_replace(":ùîç:","<img src=s_happy.gif>",$msg);
$msg = str_replace(":òöåá:","<img src=s_sad.gif>",$msg);
$msg = str_replace(":ëåòñ:","<img src=s_mad.gif>",$msg);
$msg = str_replace(":÷øéöä:","<img src=s_wink.gif>",$msg);
$msg = str_replace(":òéðééí:","<img src=s_eyes.gif>",$msg);
$msg = str_replace(":çéçé:","<img src=s_hihi.gif>",$msg);
$msg = str_replace(":îîöá:","<img src=s_hello.gif>",$msg);
$msg = str_replace(":îåçäçä:","<img src=s_muhaha.gif>",$msg);
$msg = str_replace(":áåëä:","<img src=s_cry.gif>",$msg);
$msg = str_replace(":÷åì:","<img src=s_cool.gif>",$msg);}
//ddcode
if(!isset($ddcode_check)){
$msg = str_replace(":ôúç-÷åã:","<div align=left dir=ltr><u>",$msg);
$msg = str_replace(":ñâåø-÷åã:","</u></div>",$msg);
$msg = str_replace(":ôúç-ãâù:","<b>",$msg);
$msg = str_replace(":ñâåø-ãâù:","</b>",$msg);}
//end smile\code
$new_msg = wordwrap($msg, 550) ;
$subject = htmlspecialchars($subject);
$www = htmlspecialchars($www);
$email = htmlspecialchars($email);
$name = htmlspecialchars($name);
if($type="new") // if its a new msg
{
if(isset($name) && $name != "" && isset($subject) && $subject != "" && isset($new_msg) && $new_msg != "") //check if fields are filled
{
// cookies
setcookie("dima2_name",$name,time()+999999999);
if(isset($www))
{
setcookie("dima2_www",$www,time()+999999999);
}
else{
setcookie("dima2_www");
}
if(isset($icq)){
setcookie("dima2_icq",$icq,time()+999999999);}
else{
stecookie("dima2_icq");}
if(isset($email)){
setcookie("dima2_email",$email,time+999999999);}
else{
setcookie("dima2_email");}
// end cookies :-)
$insert_query_new = mysql_query("INSERT INTO dima2_msg (msg, subject, icq, www, email, name, date, ip) values ('$new_msg','$subject','$icq','$www','$email','$name','$date','$ip')");
print "<meta http-equiv=\"Refresh\" content=\"0; URL=index.php\">";
exit();
}
else
{
print "<meta http-equiv=\"Refresh\" content=\"0; URL=http://www.signup.co.il\">";
exit();
}
}
elseif($type="replay")
{
if(isset($name) && $name != "" && isset($subject) && $subject != "") //check if fields are filled
{
// cookies
setcookie("dima2_name",$name,time()+999999999);
if(isset($www))
{
setcookie("dima2_www",$www,time()+999999999);
}
else{
setcookie("dima2_www");
}
if(isset($icq)){
setcookie("dima2_icq",$icq,time()+999999999);}
else{
stecookie("dima2_icq");}
if(isset($email)){
setcookie("dima2_email",$email,time+999999999);}
else{
setcookie("dima2_email");}
// end cookies :-)
$insert_query_replay = mysql_query("INSERT INTO dima2_re (msg, subject, icq, www, email, name, date, ip, msgid) values ('$new_msg','$subject','$icq','$www','$email','$name','$date','$ip','$id')");
print "<meta http-equiv=\"Refresh\" content=\"0; URL=view.php?id=$id\">";
exit();
}
else
{
header("location:submit.php?do=replay");
exit();
}
}
else
{
die("èòåú ÷øéèéú");
}
}
else
{
?>
<head>...........
if($do != "replay" && $do != "new") // allow access only to replay or post new msg
{
.............
.......
and in the end of all the code :
<? } ?>
when the form is submited and the values are wrong, (if $msg = "" && isset($msg)) then the code should redirect to "submit.php?do=$bla but it redirects to index.php ...
please help...
THANX !!!