Jump to content

Special Registration Feature


jamesjmann

Recommended Posts

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
Share on other sites

You only want the domain ?


echo strstr('something@example.com', '@');
// = @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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.