• Bu site çerezler kullanır. Bu siteyi kullanmaya devam ederek çerez kullanımımızı kabul etmiş olursunuz. Daha fazla bilgi edin.

Php İletişim Formu Yardım

Konuyu Okuyan Kişiler (0)

Bouncer

webmaster.tc
Katılım
19 Kas 2012
Mesajlar
192
Beğeniler
0
#1
Arkadaşlar Ben Php İle İletişim Formu Çok Denedim Olmadı Bir Türlü Çalıştıramadım lütfen elinizde php iletişim formu ÇALIŞAN elinizde varsa lütfen paylaşabilirmisiniz
 

FollowME

webmaster.tc
Katılım
3 Ocak 2013
Mesajlar
86
Beğeniler
0
#3
tam olarak istediğiniz iletişim formundan gelen verileri bir veri tabanına kayıt etmek mi
 

Bouncer

webmaster.tc
Katılım
19 Kas 2012
Mesajlar
192
Beğeniler
0
#4
yok benim istediğim iletişim formu olacak iletişim formuna yazılacak olan verileri e posta adresime gelmesini istiyorum
 

FollowME

webmaster.tc
Katılım
3 Ocak 2013
Mesajlar
86
Beğeniler
0
#7
contact.php
PHP:
        <div class="main">
                        <h1>Contact us</h1>
                        <p><strong>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</strong> </p>
                        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
                        <p><em>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</em></p>
                        
                         <?php if(isset($mail_error) && $mail_error) { ?>
                        <p class="succes">The email has NOT been sent!</p>
                        <?php } elseif(isset($mail_error)) { ?>
                        <p class="succes">The email was sent succesfully!</p>
                        <?php } ?>
                            <form action="" class="form-contact" method="post">

                            <div class="holder">
                                <label for="name">Name:<span class="green">*</span>  </label>
                                <input type="text" name="name" value="<?php echo @$_POST['name']; ?>">
                                <?php if(isset($errors['name'])) { ?> <?php echo $errors['name']; ?> <?php } ?>
                            </div>


                            <div class="holder">
                                <input type="text" name="middle-name" style="display:none;">
                                <label for="email">Email:<span class="green">*</span>  </label>
                                <input type="text" name="email" value="<?php echo @$_POST['email']; ?>">
                                <?php if(isset($errors['email'])) { ?> <?php echo $errors['email']; ?> <?php } ?>
                            </div>

                            <div class="holder">
                                <label for="subject">Subject:  </label>
                                <input type="text" name="subject" value="<?php echo @$_POST['subject']; ?>">
                            </div>

                            <div class="holder">
                                <label for="message">Message: <span class="green">*</span></label>
                                <textarea rows="10" cols="10" name="message"><?php echo @$_POST['message']; ?></textarea>
                                <?php if(isset($errors['message'])) { ?> <?php echo $errors['message']; ?> <?php } ?>
                            </div>

                            <div class="clear"></div>

                            <input type="submit" value="SEND" class="send">
                            <em>Please allow us 24h for the response. Thank you !</em>
                        </form>

                    </div>
contact-send.php

PHP:
<?php
function validateForm($data)
{
    $errors = array();

    if(empty($data['name']))
    {
        $errors['name'] = '<p class="error">You must complete the name field</p>';
    }
    elseif(!preg_match('/[-a-z\'` ]+/i', $data['name']))
    {
        $errors['name'] = '<p class="error">The name you entered is not valid</p>';
    }

    if(empty($data['email']))
    {
        $errors['email'] = '<p class="error">You must complete the email field</p>';
    }
    elseif(!filter_var($data['email'], FILTER_VALIDATE_EMAIL))
    {
        $errors['email'] = '<p class="error">The email address you entered is not valid</p>';
    }

    if(empty($data['message']))
    {
        $errors['message'] = '<p class="error">You must enter a message</p>';
    }

    return $errors;
}


function processTheForm($to)
{
    $result = array();
    if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST['middle-name']))
    {
        $errors = validateForm($_POST);
        $_POST['message'] = strip_tags($_POST['message']);
        $subject= strip_tags($_POST['subject']);

        if(empty($subject))
        {
            $subject = 'Message from '.$_POST['name'];
        }

        if(empty($errors))
        {
            $headers = array(
                'Content-type'=>'text/html',
                'From'=>"{$_POST['name']}<{$_POST['email']}>",
                'To'=>$to,
                'Date'=>date('r')
            );

            $mailTpl = file_get_contents('mail-template.tpl.php');
            $mailTpl = str_replace(array('[name]', '[email]', '[message]'),
                array($_POST['name'], $_POST['email'], $_POST['message']), $mailTpl);


            if(mail($to, $subject, $mailTpl, implode("\r\n", $headders)))
            {
                unset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message']);
                $result['mail_error'] = false;
            }
            else
            {
                $result['mail_error'] = true;
            }
        }

        $result['errors'] = $errors;
    }

    return $result;
}

mail-template.tpl.php

asagıdaki alanlara gelecek olan mail vs yazılacak
PHP:
[name]
[email]
[message]
 

Bouncer

webmaster.tc
Katılım
19 Kas 2012
Mesajlar
192
Beğeniler
0
#8
contact.php
PHP:
        <div class="main">
                        <h1>Contact us</h1>
                        <p><strong>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</strong> </p>
                        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
                        <p><em>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</em></p>
                        
                         <?php if(isset($mail_error) && $mail_error) { ?>
                        <p class="succes">The email has NOT been sent!</p>
                        <?php } elseif(isset($mail_error)) { ?>
                        <p class="succes">The email was sent succesfully!</p>
                        <?php } ?>
                            <form action="" class="form-contact" method="post">

                            <div class="holder">
                                <label for="name">Name:<span class="green">*</span>  </label>
                                <input type="text" name="name" value="<?php echo @$_POST['name']; ?>">
                                <?php if(isset($errors['name'])) { ?> <?php echo $errors['name']; ?> <?php } ?>
                            </div>


                            <div class="holder">
                                <input type="text" name="middle-name" style="display:none;">
                                <label for="email">Email:<span class="green">*</span>  </label>
                                <input type="text" name="email" value="<?php echo @$_POST['email']; ?>">
                                <?php if(isset($errors['email'])) { ?> <?php echo $errors['email']; ?> <?php } ?>
                            </div>

                            <div class="holder">
                                <label for="subject">Subject:  </label>
                                <input type="text" name="subject" value="<?php echo @$_POST['subject']; ?>">
                            </div>

                            <div class="holder">
                                <label for="message">Message: <span class="green">*</span></label>
                                <textarea rows="10" cols="10" name="message"><?php echo @$_POST['message']; ?></textarea>
                                <?php if(isset($errors['message'])) { ?> <?php echo $errors['message']; ?> <?php } ?>
                            </div>

                            <div class="clear"></div>

                            <input type="submit" value="SEND" class="send">
                            <em>Please allow us 24h for the response. Thank you !</em>
                        </form>

                    </div>
contact-send.php

PHP:
<?php
function validateForm($data)
{
    $errors = array();

    if(empty($data['name']))
    {
        $errors['name'] = '<p class="error">You must complete the name field</p>';
    }
    elseif(!preg_match('/[-a-z\'` ]+/i', $data['name']))
    {
        $errors['name'] = '<p class="error">The name you entered is not valid</p>';
    }

    if(empty($data['email']))
    {
        $errors['email'] = '<p class="error">You must complete the email field</p>';
    }
    elseif(!filter_var($data['email'], FILTER_VALIDATE_EMAIL))
    {
        $errors['email'] = '<p class="error">The email address you entered is not valid</p>';
    }

    if(empty($data['message']))
    {
        $errors['message'] = '<p class="error">You must enter a message</p>';
    }

    return $errors;
}


function processTheForm($to)
{
    $result = array();
    if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST['middle-name']))
    {
        $errors = validateForm($_POST);
        $_POST['message'] = strip_tags($_POST['message']);
        $subject= strip_tags($_POST['subject']);

        if(empty($subject))
        {
            $subject = 'Message from '.$_POST['name'];
        }

        if(empty($errors))
        {
            $headers = array(
                'Content-type'=>'text/html',
                'From'=>"{$_POST['name']}<{$_POST['email']}>",
                'To'=>$to,
                'Date'=>date('r')
            );

            $mailTpl = file_get_contents('mail-template.tpl.php');
            $mailTpl = str_replace(array('[name]', '[email]', '[message]'),
                array($_POST['name'], $_POST['email'], $_POST['message']), $mailTpl);


            if(mail($to, $subject, $mailTpl, implode("\r\n", $headders)))
            {
                unset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message']);
                $result['mail_error'] = false;
            }
            else
            {
                $result['mail_error'] = true;
            }
        }

        $result['errors'] = $errors;
    }

    return $result;
}

mail-template.tpl.php

asagıdaki alanlara gelecek olan mail vs yazılacak
PHP:
[name]
[email]
[message]
Kardeş Ben mail adresini nereye yazacam biraz açıklarmısın
 

Bouncer

webmaster.tc
Katılım
19 Kas 2012
Mesajlar
192
Beğeniler
0
#12
tmm kardeş yinede tşkederim action olacak bildiğim kadarıyla ikinci dosya içine gömülmesi lazım
 

Bouncer

webmaster.tc
Katılım
19 Kas 2012
Mesajlar
192
Beğeniler
0
#13