Поща проверка

teroristd

Registered
Здравейте ,
пробвам да сложа някаква поща и не мога да разбера дали работи. Примерно ако не въведа нищо в полетата не ми излиза нищо а би трябвало да излезе "Моля въведете име.". Има ли начин като не съм на хостинг да проверя дали работи по някъкъв начин.

<?php


if($_POST['submit']){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];


if ($subject == "")
{
echo "Моля въведете име.";
}
if (!eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email))
{
echo "E-mail $еmail не е валиден!";
}
if($tel == "")
{
echo "Моля въведете телефон.";
}
if($message == ""){
echo "Моля въведете съобщение.";
}
else{


echo "<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>


<div class='entry' >

<form style='position:relative; left:10px; margin-bottom:30px;' method='POST' action='kontakti.php'>
Вашето име: <input type='text' name='title' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='title' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='title' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='text' cols='66' rows='10' ></textarea><br /><br />

<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >


</form>

</div>



<div class='meta1'>


</div>

</div>";

}

?>
 
Код:
<?php
if($_POST['submit']){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];
if (empty($subject))
{
echo "Моля въведете име.";
}
if (!eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email))
{
echo "E-mail $еmail не е валиден!";
}
if(empty($tel))
{
echo "Моля въведете телефон.";
}
if(empty($message)){
echo "Моля въведете съобщение.";
}
else{
?>
<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>
<div class='entry' >
<form style='position:relative; left:10px; margin-bottom:30px;' method='POST' action='kontakti.php'>
Вашето име: <input type='text' name='subject' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='tel' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='email' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='message' cols='66' rows='10' ></textarea><br /><br />
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >
</form>
</div>
<div class='meta1'>
</div>
</div>
<?php
}
}
?>
Пробвай.
 
Най-малкото, че кода е грешен, по-точно даже нямаш затврени къдрави скоби, отделно, че ифовете ти не бяха на място..

Така би трябвало да работи, но няма да праща съобщението, ако нямаш SMTP сървър..


Код:
<?php


if(isset($_POST['submit'])){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];


if (empty($subject))
{
echo "Моля въведете име.";
}
if (!preg_match('/[a-z0-9_\.]+@[a-z0-9]+\.[a-z]{2,4}$/', $email))
{
echo "E-mail $еmail не е валиден!";
}
if(empty($tel))
{
echo "Моля въведете телефон.";
}
if(empty($message)){
echo "Моля въведете съобщение.";
}
else{

$headers = 'From: youremail@abv.bg' . "\r\n" .
    'Reply-To: youremail@abv.bg' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($email, $subject, $message, $headers);

}
}
else
{

echo "<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>


<div class='entry' >

<form style='position:relative; left:10px; margin-bottom:30px;' method='POST' action='kontakti.php'>
Вашето име: <input type='text' name='title' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='title' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='title' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='text' cols='66' rows='10' ></textarea><br /><br />

<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >


</form>

</div>



<div class='meta1'>


</div>

</div>";

}
?>
 
@kulov, имената на input-ите не са както са въведени в променливите. Освен това, което ти каза.
 
Код:
	 <?php


if(isset($_POST['submit'])){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];


if (empty($subject))
{
echo "Моля въведете име.";
}
if (!preg_match('/[a-z0-9_\.]+@[a-z0-9]+\.[a-z]{2,4}$/', $email))
{
echo "E-mail $еmail не е валиден!";
}
if(empty($tel))
{
echo "Моля въведете телефон.";
}
if(empty($message)){
echo "Моля въведете съобщение.";
}
else{

$headers = 'From: youremail@abv.bg' . "\r\n" .
    'Reply-To: youremail@abv.bg' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($email, $subject, $message, $headers);

}
}
else
{

echo "<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>


<div class='entry' >

<form method='POST' action=''>
Причина за съобщението: <input type='text' name='subject' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='tel' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='email' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='massage' cols='66' rows='10' ></textarea><br /><br />

<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' name='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >


</form>

</div>



<div class='meta1'>


</div>

</div>";

}
?>
 
Код:
<?php
if($_POST['submit']){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];
if (empty($subject))
{
echo "Моля въведете име.";
}
if (!eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email))
{
echo "E-mail $еmail не е валиден!";
}
if(empty($tel))
{
echo "Моля въведете телефон.";
}
if(empty($message)){
echo "Моля въведете съобщение.";
}
}
else {
echo "
<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>
<div class='entry' >
<form style='position:relative; left:10px; margin-bottom:30px;' method='POST' action='kontakti.php'>
Вашето име: <input type='text' name='subject' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='tel' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='email' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='message' cols='66' rows='10' ></textarea><br /><br />
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >
</form>
</div>
<div class='meta1'>
</div>
</div>";
}
?>
 
Код:
<?php
if($_POST['submit']){
$subject = $_POST['subject'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$message = $_POST['message'];
if(strlen($subject)==0)
{
echo "Моля въведете име.";
}
if(!eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email))
{
echo "E-mail $еmail не е валиден!";
}
if(strlen($tel)==0)
{
echo "Моля въведете телефон.";
}
if(strlen($message)==0){
echo "Моля въведете съобщение.";
}
}
else {
?>
<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>
<div class='entry' >
<form style='position:relative; left:10px; margin-bottom:30px;' method='POST' action='kontakti.php'>
Вашето име: <input type='text' name='subject' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='tel' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='email' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='message' cols='66' rows='10' ></textarea><br /><br />
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >
</form>
</div>
<div class='meta1'>
</div>
</div>
<?php
}
?>
 
Код:
	     <?php


if(isset($_POST['submit'])){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];


if (empty($subject))
{
echo "Моля въведете причината за съобщението.";
}
elseif (!preg_match('/[a-z0-9_\.]+@[a-z0-9]+\.[a-z]{2,4}$/', $email))
{
echo "E-mail $еmail не е валиден!";
}
elseif(empty($tel))
{
echo "Моля въведете телефон.";
}
elseif(empty($message)){
echo "Моля въведете съобщение.";
}
else
{

$headers = 'From: youremail@abv.bg' . "\r\n" .
    'Reply-To: youremail@abv.bg' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($email, $subject, $message, $headers);

}
}
else
{

echo "<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>


<div class='entry' >

<form method='POST' action=''>
Причина за съобщението: <input type='text' name='subject' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='tel' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='email' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='message' cols='66' rows='10' ></textarea><br /><br />

<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' name='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >


</form>

</div>



<div class='meta1'>


</div>

</div>";

}
?>
 
такава аномалия няма данеби да ми го крие зад хедъра или някой друг елемент
 
А бе я провай така..

Код:
<div class='post' style='margin-top:-30px;'>
<p style = 'background:url(bar.png) no-repeat; width:574px; height:40px; position:relative; top:-10px; left:0px;'><a style = 'position:relative; top:8px; left:25px; text-decoration:none; color: #202020;'><b>Форма за контакти</b></a></p>


<div class='entry' >

<form method='POST' action=''>
Причина за съобщението: <input type='text' name='subject' style='width:250px; margin-left:40px; margin-bottom:10px;' /><br />
Вашият телефон: <input type='text' name='tel' style='width:250px; margin-left:13px; margin-bottom:10px;' /><br />
Вашият имейл: <input type='text' name='email' style='width:250px; margin-left:26px; ' /><br /><br />
Вашето съобщение: <br/><textarea name='message' cols='66' rows='10' ></textarea><br /><br />

<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='submit' name='submit' value='Изпрати' >
<input style = ' font:12px Arial; width:70px; background:#cccccc; color: #000; height:21px; padding: 0 0 10px 0; margin:0 auto; ' type='reset' value='Изчисти' >


</form>

</div>


</div>
<br /><br />	       
		   <?php


if(isset($_POST['submit'])){
$subject = $_POST["subject"];
$email = $_POST["email"];
$tel = $_POST["tel"];
$message = $_POST["message"];


if (empty($subject))
{
echo "Моля въведете причината за съобщението.";
}
elseif (!preg_match('/[a-z0-9_\.]+@[a-z0-9]+\.[a-z]{2,4}$/', $email))
{
echo "E-mail $еmail не е валиден!";
}
elseif(empty($tel))
{
echo "Моля въведете телефон.";
}
elseif(empty($message)){
echo "Моля въведете съобщение.";
}
else
{

$headers = 'From: youremail@abv.bg' . "\r\n" .
    'Reply-To: youremail@abv.bg' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($email, $subject, $message, $headers);

}
}
?>
 
Машала от предпоследния пост на Kulov се получи :) имате мойте благодарности и +1 но има ли начин да се провери дали всичко е наред или трябва да се качи на хостинг и чак тогава.
 

Back
Горе