romio Posted March 17, 2006 Share Posted March 17, 2006 I have developed a simple newsletter subscriber where the admin can login and send to all active subscribers an email. What I need to do is create my own random procedure in order to send the new subscribers a link to active him/her self, I have an overall idea but not sure how to implement it, would it be better to have a separate table or just use the same table by adding a new filed? Here are my thoughts up to now:This is my code, which adds a new subscriber:[code]if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "subscribe")) { $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $phone = $_POST['phone']; $street_address = $_POST['street_address']; $postal_code = $_POST['postal_code']; $province = $_POST['province']; $town = $_POST['town']; $country = $_POST['country']; $query = "INSERT INTO subscribers (first_name, last_name, email, phone, street_address, postal_code, province, town, country) VALUES ('$first_name', '$last_name', '$email', '$phone', '$street_address', '$postal_code', '$province', '$town', '$country')"; mysql_select_db($database, $dbcnx); mysql_query($query) or die('Error, insert query failed'); $headers .= "Miramare Beach Hotel"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; $recipient = $email; $subject = "News letter Subscribtion"; $message = "You have been added Successfuly"; $msg = wordwrap( $msg, 1024 ); mail($recipient, $subject, $message, stripslashes($msg), $headers); echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url='../../../?page=thanks.php'\">"; exit(); }?>[/code]Can I add simply this link before the insert statement (I have also edited the insert query:[code]CREATE PROCEDURE Random_NumASDECLARE Random_Num int;DECLARE Upper_Num int;DECLARE Lower_Num intSET Lower_Num = 1SET Upper_Num = 999999SELECT Random_Num = Round(((Upper_Num - Lower_Num - 1) * Rand() + Lower_Num), 0)SET NOCOUNT ON$query = "INSERT INTO subscribers (first_name, last_name, email, phone, street_address, postal_code, province, town, country, random_num) VALUES ('$first_name', '$last_name', '$email', '$phone', '$street_address', '$postal_code', '$province', '$town', '$country', 'Random_Num')";SET NOCOUNT OFFGO[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5146-random-number-to-verify-subscriber/ Share on other sites More sharing options...
zq29 Posted March 19, 2006 Share Posted March 19, 2006 You could make things easier for yourself by running their email address through md5() and then using that output as a "random" string - I assume the email address is a unique field. One less field in the database to worry about matching up... Quote Link to comment https://forums.phpfreaks.com/topic/5146-random-number-to-verify-subscriber/#findComment-18780 Share on other sites More sharing options...
skatermike21988 Posted March 19, 2006 Share Posted March 19, 2006 [a href=\"http://www.phpfreaks.com/tutorials/40/3.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/40/3.php[/a]thereis something similar it talks about members area's but it generates a random password in md5 and sends a link for user to activate their membership. you can manipulate the code to ur needs Quote Link to comment https://forums.phpfreaks.com/topic/5146-random-number-to-verify-subscriber/#findComment-18787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.