Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    coding an autoresponse 'click to verify email'

    Hi,

    I have a register and login page and would like to add an autoresponse email. The end result being when people register they have to click a link in their email before being able to login. Essentially this is to stop fake email addresses being used. All my coding works fine, you can't login until you register and on registration the data gets stored in a MySQL table. I can't figure out the autoresponder and verification part. Any help much appreciated and of course there will be icecreams all round. Code below.

    Thanks.


    <?PHP
    ob_start();

    //Connect to enter the information into the fields
    $link = mysql_connect('localhost','bangers', 'andmashme') or die("Could not connect");
    mysql_select_db('bangers') or die("Could not select database");

    //Todays date
    $date = time();

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>BANGERS AND MASH: VIEW PICS LOGIN</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
    <link href="III.css" rel="stylesheet" type="text/css">
    </head>

    <body ><center>

    <body bgcolor="white">

    <img src="banner.png" width="597" height="159" border="0">

    <!-- ----------------------------------------------PALN A PARTY-------------------------------------------------------------------------------------->
    <div class="leftcontent">
    <div class="leftTop">.</div>
    <p class="boxtext"> <font color="black"><font face="Courier New">
    <b>Welcome to the weekly updated...
    <br>
    BANGERS AND MASH GALLERY!</b>
    <br>
    Take a moment to register, &amp;
    Existing users proceed to the enter gallery section</p>
    <p class="boxtext"> <font color="black">
    <div class="leftbottom"></div>
    <div id="clear"></div>
    <div class="leftTop"></div>

    <?



    if ($type == 'login') {

    //LOG IN AREA
    $sql_check = mysql_query("SELECT * FROM `gallerytable` WHERE 1 AND `email` LIKE '$email2' LIMIT 0 , 30") or die ("Unable to get results.");
    $auth_list = mysql_fetch_array($sql_check);

    function CheckEmail($Email = "") {
    if (ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+", $Email)) {
    return true;
    } else {
    return false;
    }
    }

    if (mysql_num_rows($sql_check) > 0 && CheckEmail($email2)) {

    $email = $auth_list['email'];

    $cookie_data = $email.':'.$date;
    setcookie('galleryid', $cookie_data, time()+1118640);

    echo '

    <p align="right" class="boxtext">
    <h2>PLEASE WAIT....</h2>
    </p>';

    echo "<meta http-equiv=\"Refresh\" content=\"0; url=gallery2.php?contentfolder=". date("Y") ."\">";
    }

    else {

    echo '
    <p align="centre" class="boxtext" font color="black">
    <h2>FAILED</h2>
    <h2>This email has not been registered with us.
    <br>Please go back and register in order to view the gallery.</h2>
    <a href="java script:history.go(-1)"><img src="back.jpg" width="104" height="41" border="0"></a>
    </p>';

    }

    }

    else if ($type == 'register') {

    // CHECK EMAIL FUNCTION
    //***********************
    function check_email_mx($email) {
    if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
    (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {
    $host = explode('@', $email);
    if(checkdnsrr($host[1].'.', 'MX') ) return true;
    if(checkdnsrr($host[1].'.', 'A') ) return true;
    if(checkdnsrr($host[1].'.', 'CNAME') ) return true;
    }
    return false;
    }

    // Check if its in there
    $result=mysql_query("SELECT * FROM `gallerytable` WHERE `email` = '$email'");

    // IF email is ok
    if (!check_email_mx($email)) {
    echo '
    <p align="right" class="boxtext" font color="black">
    <h2>EMAIL ERROR</h2>
    <h2>You have entered an incorrect email.
    <br>
    Please click the button below to go back and try again.</h2>
    <a href="java script:history.go(-1)"><img src="back.gif" width="104" height="41" border="0"></a>
    </p>';

    }

    elseif (mysql_num_rows($result) <= 0) {

    //Puts deatils into the bangers database
    $insert=mysql_query("INSERT INTO `gallerytable` (`id`, `fname`, `sname`, `email`, `telno`, `date`) VALUES ('', '$f_name', '$s_name', '$email', '$mobile', '$date')")or
    die('couldn\'t Insert record into bangers database :'.mysql_error());

    echo '
    <p align="right" class="boxtext" font color="black">
    <h2>THANK YOU FOR REGISTERING!!</h2>
    <h2>Your details have been registered with us and will not
    <br>o the login section to view images.</h2>
    <a href="java script:history.go(-1)"><img src="back.gif" width="104" height="41" border="0"></a>
    </p>';


    }

    else {

    echo '
    <p align="right" class="boxtext" font color="black">
    <h2>REGISTERED</h2>
    <h2>YOUR DETAILS HAVE ALREADY BEEN REGISTERED WITH US. PLEASE PROCEED TO THE ENTER GALLERY SECTION.</h2>
    <a href="java script:history.go(-1)"><img src="back.jpg" width="104" height="41" border="0"></a>
    </p>';

    }

    }

    else {

    echo '

    <table width="800" boder="0" align="center">

    <table width="600" border="0" align="center">
    <tr>
    <td valign="middle" colspan="2" align="center"><p><img src="register.gif" width="227" height="26" /></p>
    </td>
    <td valign="center" colspan="2" align="center"><img src="entergallery.gif" width="227" height="24" />
    </td>
    <td>&nbsp;</td>
    <tr>
    <td width="300" valign="middle">
    <p><strong><img src="required1.gif" width="227" height="31" /></strong></p>
    </td>
    <td width="300" valign="middle"> &nbsp</td>
    <td width="300" valign="middle">
    <form name="login" method="post" action="'.$_SERVER['PHP_SELF'].'">
    <img src="email1.gif" width="227" height="24" />
    <td width="300" valign="middle">
    <input name="email2" type="text" size="16" class="Field" />
    </td>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td width="300" valign="middle">
    <input name="type" type="hidden" value="login"/>
    <input name="Submit" type="image" class="submit" value="Submit" src="submit.gif" align="right">
    </form> </td>


    <tr>
    <td width="300" valign="middle">
    <form name="register" method="post" action="'.$_SERVER['PHP_SELF'].'">
    <p><img src="name1.gif" width="227" height="27"/>
    <td width="300" valign="middle">
    <input name="f_name" type="text" class="Field" id="f_name" size="16"/>
    <tr>
    <td width="300" valign="middle">
    <p><img src="surname1.gif" width="227" height="28" />
    <td width="300" valign="middle">
    <input name="s_name" type="text" class="Field" id="s_name" size="16"/>
    <tr>
    <td width="300" valign="middle">
    <p><img src="email1.gif" width="227" height="24" />
    <td width="300" valign="middle">
    <input name="email" type="text" size="16" class="Field" />
    <tr>
    <td width="300" valign="middle">
    <p><img src="emailconfirm1.gif" width="227" height="25" />
    <td width="300" valign="middle">
    <input name="confemail" type="text" size="16" class="Field" />
    <tr>
    <td width="300" valign="middle">
    <p><img src="mobile1.gif" width="227" height="22" />
    <td width="300" valign="middle">
    <input name="mobile" type="text" size="16" class="Field" />
    </td>
    <tr>
    <td width="300" valign="middle"></td>
    <td width="300" valign="middle">
    <input name="type" type="hidden" value="register"/>
    <input name="Submit" type="image" class="submit" value="Submit" src="submit.gif" align="right">
    </p>
    </form>
    <br/></td>
    <td width="5"/>
    </form> </td>
    </tr>
    </table>

    ';

    }




    ?>
    </p>

    <div class="leftbottom"></div>
    </div>
    <!--END NEWS -->

    </div>
    </div>
    </body>
    </html>

  • #2
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Firstly, this is in the wrong section but I can help you.

    What you need to do is this:

    * Create a new MySQL table called activation.
    * Upon the user registering insert a randomly generated code into the activation table under a field called 'code'. You will also want to insert the users email address under the table field 'email'.
    * The URL is then generated and sent to the user using the simple mail() command in PHP. The url would look like http://yourdomain.com/activate.php?e...&key=423480329
    * Your activate.php script would then search the activation table, erase the details and then update your users table which should have a field called "activated" using simple 0's and 1's.
    * Then upon every login, check if the user has a activated value of 1 meaning they've activated.
    * You could use cronjobs to check after a short period of time if a user hasn't activated and delete the entries from your DB.

  • #3
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply, As I'm a bit of a novice at all this coding stuff is there any chance you could help me set it up? Or if that's asking too much do you know of any good tutorials that might help me with it?

    Thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •