Ето формата:
Ето и скрипта, който праща съобщението:
Ето какъв е проблема: Когато всичко полета са празни изписва грешка, че никое поле не е попълнено. Когато примерно попълня името и натисна Send, при грешките пред грешката, че не е попълнен e-mailа изписва "Array". Въпроса ми е как да премахна този array? Проблема вероятно е от това, че типа на променливата $error e array. Как може да се оправи? +1
Код:
<table width="320" align="left">
<tr>
<td>Full Name:</td>
<td valign="top">*</td>
<td width="200"><input name="subject" type="text" value="<?php echo $_GET['subject'];?>" size="21" maxlength="25" /></td>
</tr>
<tr>
<td>E-mail:</td>
<td valign="top">*</td>
<td width="200"><input name="from" type="text" value="<?php echo $_GET['from'];?>" size="21" maxlength="25" /></td>
</tr>
<tr>
<td colspan="2">Country:</td>
<td width="200"><select name="country">
<option value="Select country" selected="selected">Select country</option>
<option value="Other">Other</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="Andorra">Andorra</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
</select></td>
</tr>
<tr>
<td colspan="2">Telephone:</td>
<td width="200"><input name="tel" type="text" value="" size="21" maxlength="25" /></td>
</tr>
<tr>
<td colspan="3">Your Message: *</td>
</tr>
<tr>
<td colspan="3"><textarea name="message" rows="6" cols="32"><?php echo $_GET['message'];?></textarea></td>
</tr>
<tr>
<td width="97">Enter the code: </td>
<td width="7" valign="top">*</td>
<td width="200"><input name="verif_box" type="text" size="15" maxlength="15"/>
<img src="verif.php?<?php echo rand(0,9999);?>" alt="vp" width="50" height="24" align="absbottom" /></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<?php if(isset($_GET['wrong_code'])){?>
Wrong code!
<?php ;}?>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input name="Submit" type="submit" class="button" value="Send"/>
</div></td>
<td width="200"><div class="contact-button">
<input name="reset" type="reset" class="button" value="Reset"/>
</div></td>
</tr>
</table>
Ето и скрипта, който праща съобщението:
Код:
<?php
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];
$tel = $_REQUEST["tel"];
$verif_box = $_REQUEST["verif_box"];
$country = $_REQUEST["country"];
$message = stripslashes($message);
$subject = stripslashes($subject);
$from = stripslashes($from);
$tel = stripslashes($tel);
$country = stripslashes($country);
$error = array();
if (!$subject)
$error =" • Please go back and fill up the name. <br /><br />";
if (!eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $from))
$error .= " • The e-mail <b>$from</b> is invalid! <br /><br />";
if (!$message)
$error .= " • Please go back and fill up the message. <br /><br />";
if (!$verif_box)
$error .= " • Please go back and fill up the validation code. <br /><br />";
if(!empty($error))
print ("$error <a href=\"javascript:history.go(-1);\"> << Go back</a>");
else
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
mail("****@abv.bg", 'Mail ot saita: '.$subject, "<b>From:</b>\n".$subject."\n\n"."<b>Country:</b>\n".$country."\n\n"."<b>Telephone:</b>\n".$tel."\n\n"."<b>Message:</b>\n".$message, "From: $from");
echo "No errors. Your message has been sent successfully!<br /><br /> <a href=\"../index.html\">Go to the main page.</a>";
setcookie('tntcon','');
} else {
header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&tel=$tel&wrong_code=true");
exit;
}
?>
Ето какъв е проблема: Когато всичко полета са празни изписва грешка, че никое поле не е попълнено. Когато примерно попълня името и натисна Send, при грешките пред грешката, че не е попълнен e-mailа изписва "Array". Въпроса ми е как да премахна този array? Проблема вероятно е от това, че типа на променливата $error e array. Как може да се оправи? +1