Jump to content
Sign in to follow this  
Stefan

Ce Reprezinta Aceasta Expresie Din Email Php?

Recommended Posts

Salut, ce specifica codul acesta ( ce se afala intre '  '  pe prima linie ) ? Este de la un formular de contact.

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }

Share this post


Link to post
Share on other sites

Expresie regulata. Nu le stiu prea bine, dar poti cauta rapid pe google despre regulile expresiilor regulate, daca chiar vrei.

Pe scurt, descrie cum ar trebui sa arate o adresa de email.


love is a verb
Love is a doing word

Share this post


Link to post
Share on other sites

As folosi ceva de genu' pentru validarea adreselor email :).

<?php

$email_1 = 'Courage';
$email_2 = 'courage@pctroubleshooting.ro';

function mail_valid( $email )
{
    return filter_var( $email, FILTER_VALIDATE_EMAIL );
}

if ( ! mail_valid( $email_1 ) ) {
    echo "<p>Adresa {$email_1} este invalida</p>";
} else {
    echo "<p>Adresa {$email_1} este valida</p>";
}

if ( ! mail_valid( $email_2 ) ) {
    echo "<p>Adresa {$email_2} este invalida</p>";   
} else {
    echo "<p>Adresa {$email_2} este valida</p>";
}

?>

Adresa Courage este invalida

Adresa courage@pctroubleshooting.ro este valida

Share this post


Link to post
Share on other sites

Da, filter var este o functie default de la PHP.

http://php.net/manual/en/function.filter-var.php

 

Si ce este scris cu mare este una dintre optiunile care poate primi.

http://php.net/manual/en/filter.filters.validate.php


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...