jamesjmann Posted March 23, 2011 Share Posted March 23, 2011 I just came up with this idea I got for my registration script, where when the user has complete all steps in the registration process, he/she comes to a page that displays this: <h1>Step 3: Activate your account</h1> <h2>Congratulations, <strong><?php echo $_SESSION["user"]["username"]; ?></strong>!</h2> <p>An email has been sent to <strong><?php echo $_SESSION["user"]["email"]; ?></strong> with an activation key, and important information regarding your account. Please check your email to complete registration.</p> Then this: $email_client = preg_match ("/[@][a-zA-z0-9]{10}\.com$/", $_SESSION["user"]["email"]); $email_link = "<a href='http://www." . $email_client . ".com'>Go to " . $email_client . " mail now!</a>"; echo "<p class='center_align'>" . $email_link . "</p>"; Basically, what it does, is it figures out what email provider the user supplied as their email, and generates a link that allows them to go to that website, without having to type it in the address bar (I think I got that idea from facebook lol; only they probably do it differently). So anyway, It's not complete, and this is where I need someone's help... I assign a preg_match function to $email_client, so if it finds a string like "@yahoo.com", $email_client will be true, but that's not what I want. I want $email_client to equal a string, such as "yahoo" or "aol" based off of what the preg_match function finds, WITHOUT using if/else statements. Before I did an if/else statement for every email provider I could think of, but I think it better if I do it this way, as some people have crazy a** email names lol. So, basically what I want to do is this: <?php //Step 1: Check email preg_match("/[@][a-zA-z0-9]{10}\.com$/", $_SESSION["user"]["email"]); //Step 2: Somehow assign the "a-zA-z0-9{10}" part to a variable //Step 3: Generate link with that variable used in the "href" attribute and the label ?> But I have no idea how to go about this...Help? Link to comment https://forums.phpfreaks.com/topic/231479-special-registration-feature/ Share on other sites More sharing options...
MrXHellboy Posted March 23, 2011 Share Posted March 23, 2011 You only want the domain ? echo strstr('[email protected]', '@'); // = @example.com Link to comment https://forums.phpfreaks.com/topic/231479-special-registration-feature/#findComment-1191266 Share on other sites More sharing options...
jamesjmann Posted March 23, 2011 Author Share Posted March 23, 2011 You only want the domain ? echo strstr('[email protected]', '@'); // = @example.com Yea like i just want the domain (yahoo for example) to be stored AFTER i use a function to find it after the @ sign. So then i can use the variable to disPlay a message with a link to the actual website of that domain. Link to comment https://forums.phpfreaks.com/topic/231479-special-registration-feature/#findComment-1191315 Share on other sites More sharing options...
jamesjmann Posted March 23, 2011 Author Share Posted March 23, 2011 I just found a solution: <?php $get_domain = strstr ($_SESSION["user"]["email"], "@"); $website = preg_replace ("/@/", "", $get_domain); $trim_domain = preg_replace ("/.com|.net|.biz|.info|.org/", "", $website); $format_domain = ucwords ($trim_domain); $domain = $format_domain; $email_link = "<a href='http://www." . $website . "'>Go to " . $domain . " mail now!</a>"; echo "<p class='center_align'>" . $email_link . "</p>"; ?> The above works MAGNIFICENTLY. Thanks for nudging me in the right direction! Link to comment https://forums.phpfreaks.com/topic/231479-special-registration-feature/#findComment-1191547 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.