formularz - problem ! pomocy !

Problemy związane ze stronami PHP

formularz - problem ! pomocy !

Postprzez madalen76 » Cz gru 19, 13 17:52

Witam,
do template'u został dołączony formularz php. Na php się nie znam, ale już sporo sama zrobiłam :-). Jednak nie mogę poradzić sobie z dwoma rzeczami:
1. Pierwsza sprawa - gdy gość odwiedzający stronę chce wysłać formularz musi po wpisaniu potrzebnych informacji, zrobić proste zadanie matematyczne w celu uniknięcia spamu, ale za cholerę te cyferki się nie pokazują. Widać tylko "... +... = ? "
2. I druga rzecz to gdy w końcu uda mu się wysłać formularz, on nie dociera na moją skrzynkę, pomimo wpisania adresu e-mail.

Będę wdzięczna za pomoc. Poniżej załączam formularz php, może gdzieś mam błędy ? :roll:
Kod: Zaznacz cały
<?php
if (count($_POST))
{
 
ini_set('error_reporting'E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);        
          
$to 'biuro@coolproject.pl';
          
$subject 'Wiadomość ze strony';
          
$contact_submitted 'Wiadomość została wysłana. Dziekujemy za kontakt.';

          function 
email_is_valid($email) {
            return 
preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i',$email);
          }
          if (!
email_is_valid($to)) {
            echo 
'<p style="color: red;">You must set-up a valid (to) email address before this contact page will work.</p>';
          }
          if (isset(
$_POST['contact_submitted'])) {
            
$return "\r";
            
$youremail trim(htmlspecialchars($_POST['your_email']));
            
$yourname stripslashes(strip_tags($_POST['your_name']));
            
$yourmessage stripslashes(strip_tags($_POST['your_message']));
            
$contact_name "Name: ".$yourname;
            
$message_text "Message: ".$yourmessage;
            
$user_answer trim(htmlspecialchars($_POST['user_answer']));
            
$answer trim(htmlspecialchars($_POST['answer']));
            
$message $contact_name $return $message_text;
            
$headers "From: ".$youremail;
            if (
email_is_valid($youremail) && !eregi("\r",$youremail) && !eregi("\n",$youremail) && $yourname != "" && $yourmessage != "" && substr(md5($user_answer),5,10) === $answer) {
              
mail($to,$subject,$message,$headers);
              
$yourname '';
              
$youremail '';
              
$yourmessage '';
              echo 
'<p style="color: blue;">'.$contact_submitted.'</p>';
            }
            else echo 
'<p style="color: red;">Please enter your name, a valid email address, your message and the answer to the simple maths question before sending your message.</p>';
          }
          
$number_1 rand(19);
          
$number_2 rand(19);
          
$answer substr(md5($number_1+$number_2),5,10);   
    }    
        
?>
        <form id="contact" action="contact.php" method="post">
          <div class="form_settings">
            <p><span>Imię</span><input class="contact" type="text" name="your_name" value="<?php echo $yourname?>" /></p>
<p><span>Email</span><input class="contact" type="text" name="your_email" value="<?php echo $youremail?>" /></p>
<p><span>Wiadomość</span><textarea class="contact textarea" rows="5" cols="50" name="your_message"><?php echo $yourmessage?></textarea></p>
            <p style="line-height: 1.7em;">Aby uniknąć spamu, proszę odpowiedz na to pytanie:</p>
            <p><span><?php echo $number_1?> + <?php echo $number_2?> = ?</span><input type="text" name="user_answer" /><input type="hidden" name="answer" value="<?php echo $answer?>" /></p>
            <p style="padding-top: 15px"><span>&nbsp;</span><input class="submit" type="submit" name="contact_submitted" value="Wyslij" /></p>
          </div>
        </form>
        <?php
}
?>
madalen76
 
Posty: 1
Dołączył(a): Cz gru 19, 13 17:41

Re: formularz - problem ! pomocy !

Postprzez wargo » N gru 22, 13 22:17

http://www.ugu.pl/forum/viewtopic.php?f=2&t=905
wargo
 
Posty: 1353
Dołączył(a): Cz lip 05, 07 16:59
Lokalizacja: Pleszew


Powrót do PHP

Copyright © 2007-2011 ugu.pl
Wszelkie prawa zastrzeżone.
Polityka prywatności