EmailField-ga WebsiteField-ni aylantirish

Ushbu .php sahifasini (u ishlaydi) veb-sayt kirishini elektron pochta xabariga kiritish uchun ga aylantirmoqchi

I have changed all the websiteField items to emailField including an email Regex but it brings back a error message from the server. 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.

    <?php

    require "config.php";
    require "connect.php";

    if(isset($_POST['submitform']) && isset($_POST['txn_id']))
    {
    $_POST['nameField'] = esc($_POST['nameField']);
    $_POST['websiteField'] =  esc($_POST['websiteField']);
    $_POST['messageField'] = esc($_POST['messageField']);

    $error = array();

    if(mb_strlen($_POST['nameField'],"utf-8")<2)
    {
        $error[] = 'Please fill in a valid name.';
    }

    if(mb_strlen($_POST['messageField'],"utf-8")<2)
    {
        $error[] = 'Please fill in a longer message.';
    }

    if(!validateURL($_POST['websiteField']))
    {
        $error[] = 'The URL you entered is invalid.';
    }

    $errorString = '';
    if(count($error))
    {
        $errorString = join('
',$error); } else { mysql_query(" INSERT INTO dc_comments (transaction_id, name, url, message) VALUES ( '".esc($_POST['txn_id'])."', '".$_POST['nameField']."', '".$_POST['websiteField']."', '".$_POST['messageField']."' )"); if(mysql_affected_rows($link)==1) { $messageString = 'You were added to our donor list! »'; } } } ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Thank you!</title> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body class="thankyouPage"> <div id="main">

Thank you!

    

Add Yourself to our Donor List.

 

    <div class="lightSection">
        <form action="" method="post">
            <div class="field">
                
                <input type="text" id="nameField" name="nameField" />
            </div>

            <div class="field">
                
                <input type="text" id="websiteField" name="websiteField" />
            </div>

            <div class="field">
                
                


            </div>

            <div class="button">
                <input type="submit" value="Submit" />
                <input type="hidden" name="submitform" value="1" />
                <input type="hidden" name="txn_id" value="<?php echo $_POST['txn_id']?>" />
            </div>
        </form>

        <?php
        if($errorString)
        {
            echo '
'.$errorString.''; } else if($messageString) { echo '
'.$messageString.''; } ?> </div> </body> </html> <?php function esc($str) { global $link; if(ini_get('magic_quotes_gpc')) $str = stripslashes($str); return mysql_real_escape_string(htmlspecialchars(strip_tags($str)),$link); } function validateURL($str) { return preg_match('/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i',$str); } ?>

This is the same page with the changes made to reflect email instead of website

<?php

require "config.php";
require "connect.php";

if(isset($_POST['submitform']) && isset($_POST['txn_id']))
{
    $_POST['nameField'] = esc($_POST['nameField']);
    $_POST['emailField'] =  esc($_POST['emailField']);
    $_POST['messageField'] = esc($_POST['messageField']);

    $error = array();

    if(mb_strlen($_POST['nameField'],"utf-8")<2)
    {
        $error[] = 'Please fill in a valid name.';
    }

    if(mb_strlen($_POST['messageField'],"utf-8")<2)
    {
        $error[] = 'Please fill in a longer message.';
    }

    if(!validate_email($_POST['emailField']))
    {
        $error[] = 'The email you entered may be invalid! Please check same.';
    }

    $errorString = '';
    if(count($error))
    {
        $errorString = join('
',$error); } else { mysql_query(" INSERT INTO dc_comments (transaction_id, name, email, message) VALUES ( '".esc($_POST['txn_id'])."', '".$_POST['nameField']."', '".$_POST['emailField']."', '".$_POST['messageField']."' )"); if(mysql_affected_rows($link)==1) { $messageString = 'You were added to our donor list! »'; } } } ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Thank you!</title> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body class="thankyouPage"> <div id="main">

Thank you for your support!

    

Add your name to the donor list.

 

    <div class="lightSection">
        <form action="" method="post">
            <div class="field">
                
                <input type="text" id="nameField" name="nameField" />
            </div>

            <div class="field">
                
                <input type="text" id="emailField" name="emailField" />
            </div>

            <div class="field">
                
                


            </div>

            <div class="button">
                <input type="submit" value="Submit" />
                <input type="hidden" name="submitform" value="1" />
                <input type="hidden" name="txn_id" value="<?php echo $_POST['txn_id']?>" />
            </div>
        </form>

        <?php
        if($errorString)
        {
            echo '
'.$errorString.''; } else if($messageString) { echo '
'.$messageString.''; } ?> </div> </body> </html> <?php function esc($str) { global $link; if(ini_get('magic_quotes_gpc')) $str = stripslashes($str); return mysql_real_escape_string(htmlspecialchars(strip_tags($str)),$link); } function validate_email($str) { return preg_match('.*[email protected]*?\...*', $str); } ?>

Why will the email not work as planned and is the approach correct?

I am working with this DonationScript

0
Ko'rsatilganidek, "500 Server xatosi". Bu sizning PHP kodingiz bilan bog'liq muammo emas, balki haqiqiy hosting xatosi kabi ko'rinadi. .Htaccess faylini butunlay tahrirladingizmi?
qo'shib qo'ydi muallif Luke, manba
Sizda xato_kompaniyasining mazmunini olish va xato xabari bilan shug'ullanish mumkinmi?
qo'shib qo'ydi muallif jprofitt, manba

1 javoblar

Muammoingiz sizning regexp-da bo'lishi mumkin, * kod misoldagi noma'lum o'zgartirish. Buni ko'ring ... To'g'ri elektron pochta vazifasini o'chirib tashlang. Keyin o'zgaring

if(!validate_email($_POST['emailField']))

uchun

if (!filter_var($_POST['emailField'], FILTER_VALIDATE_EMAIL))

va bu siz uchun ishlayotganini ko'ring.

0
qo'shib qo'ydi
Hurmatli Austin Best, men tekshiruv funktsiyasini butunlay o'zgartirib, birinchi marta ishladim. Yaxshi ish va rahmat. E-pochtani tasdiqlash uchun past sifatli regexp dan foydalanganligimni anglatadimi?
qo'shib qo'ydi muallif Webiter, manba
PhP |BotsUz
PhP |BotsUz
93 ishtirokchilar

Phpni o'rganishni Hohlasangiz https://t.me/joinchat/AAAAAE-KRc5dd5tPMmGmWA A'zo bo'lin