Have an account? Sign in
Login  Register  Facebook
How to validating the adsense publisher code?
i want a php code that can check the adsense publisher code the code is contain 16 number some thing like this:
8505838780471642
Started: September 17, 2011 Latest Activity: September 17, 2011 php regex adsense
1 Answer
Regex would be ^d{16}$
Explication:
  • ^ for the beginning of the line (so nothing before that)
  • d meaning a number (decimbal)
  • {16} to mean \"exactly 16\"
  • $ for the ending of the line (so nothing after that)
ok lets see an application
html
<form method=\"post\">
    <input name=\"pub\" maxlength=\"16\" type=\"text\" />
    <input type=\"submit\" value=\"go\" />
</form>
php
if (isset($_POST[\'pub\'])) {
    if (preg_match(\"/^\\d{16}$/\", $_POST[\'pub\'])) {
         echo \'ok its good\' ;  	
    }else{
        echo \'its not real pub code\';       
    }    	
}

Posted: MacOS
In: September 17, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer