Jump to content
Larry Ullman's Book Forums

Understanding The Link For Activating Accounts


Recommended Posts

Hi Larry and everyone....

 

Please help me understand this link as used in pg 90 of Effortless E-commerce:

www.example.com/activate.php?x=email@example.com&y=CODE

 

If it was only https://www.example.com/activate.php then I'd understand how to write code to be accessed by users when they browse https://www.example.com/activate.php

and that is simply writing the code I want to be displayed in activate.php and storing activate.php in the root folder www.example.com.

 

But how about www.example.com/actvate.php?x=email@example.com&y=CODE ??

 

How do I write code that can be accessed by the above link?

 

How should I understand the "?x=email@example.com&y-CODE" part in the above link?

 

I know that by using that kind of link a link that is unique to each user's email can be used to help activate their registration...

but I still don't understand how to prepare a code that can be accessed by that type of link and will respond to different users....

 

I hope you understand what I am trying to ask here....please help....

 

To use another example...I have seen an iphone program access and store a photo by accessing the following site:

www.floraphotographs.com/showrandomiphone.php?color=%@&session=%d

 

again after the .php file there is the code that starts with ? and that is "?color=%@&session=%d".

 

I would really like to understand this and learn how a php programmer can write code that responds to similar links as above...

After reading the code in the iphone....I knew that it worked..but I didn't know how it worked...and because of that, I didn't know how to write code for that purpose as well...

 

 

Thank you very much...

 

:)

Link to comment
Share on other sites

Hi Preston,

 

This book has some complicated parts to it. So you may do well to buy PHP and MYSQL that Larry is updating now. I say this because if you are unfamiliar with how that link works then you should probably back up a bit. In my opinion.

 

But to answer your question the ? Is used to represent a $_GET variable. The code would look like:

if(isset($_GET['x'])) {
   // use variable in script
}

This then allows you to pull the info from the url into your scripts to use.

 

I hope that helps, if you need any thing else please ask :)

 

 

 

To add to this: What Larry means with this link is.

 

He will send you an email when you register saying welcome etc etc to activate your account please click the link.

 

The link will have the user's email which is what you can see x=

 

but it will also have another variable 'y=', although you can pick whatever to call them. 'y' will often represent a unique id. Then when you click that link you go to actiavte.php, which you write to pull the x and y variables from the url and use them usually in a MYSQL query. Such as,

 

"UPDATE users SET `activated`=NULL WHERE `email`='$x' AND `activated`=$y LIMIT 1" 

 

This is a very basic example of how to do it and it involves no security at all.

 

"PHP and MYSQL" has a lot of really good stuff in it including this. You're likely use most of the material in the book alot and it will compound your understanding for more complicated areas.

 

Anyway, again, hope that helps, shout if your still confused

 

:)

  • Upvote 1
Link to comment
Share on other sites

Hi Jonathan,

 

Thank you very much for your reply.

 

Your explanation has given me the tip that I needed to further understand this tool...

 

I played around with php based on your explanation about what '?' means....

 

So in short I did something like...

I opened example.php?x=john on the browser

 

where example.php has the following code:

<?php

 

if($_GET['x']=='john'){

 

echo "john";

 

}

 

?>

 

and the browser would display "john"....

 

Thank you very much for helping...

 

:)

 

 

 

 

Hi Preston,

 

This book has some complicated parts to it. So you may do well to buy PHP and MYSQL that Larry is updating now. I say this because if you are unfamiliar with how that link works then you should probably back up a bit. In my opinion.

 

But to answer your question the ? Is used to represent a $_GET variable. The code would look like:

if(isset($_GET['x'])) {
   // use variable in script
}

This then allows you to pull the info from the url into your scripts to use.

 

I hope that helps, if you need any thing else please ask :)

 

 

 

To add to this: What Larry means with this link is.

 

He will send you an email when you register saying welcome etc etc to activate your account please click the link.

 

The link will have the user's email which is what you can see x=

 

but it will also have another variable 'y=', although you can pick whatever to call them. 'y' will often represent a unique id. Then when you click that link you go to actiavte.php, which you write to pull the x and y variables from the url and use them usually in a MYSQL query. Such as,

 

"UPDATE users SET `activated`=NULL WHERE `email`='$x' AND `activated`=$y LIMIT 1" 

 

This is a very basic example of how to do it and it involves no security at all.

 

"PHP and MYSQL" has a lot of really good stuff in it including this. You're likely use most of the material in the book alot and it will compound your understanding for more complicated areas.

 

Anyway, again, hope that helps, shout if your still confused

 

:)

Link to comment
Share on other sites

 Share

×
×
  • Create New...