The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Adding Html/php so people can register

3 posters

Go down

Solved Adding Html/php so people can register

Post by matchan2 August 11th 2010, 8:22 pm

I have a server at my house running mysql and other server tools so I can run the Ro Private server I created. The Ro server is non profit (of course) and my friends and I just wanted to take on a challenge. We finally have the entire server up and running except the registration part. I need to add the custom registration code I created to the website (The registration code is 1/2 Html and 1/2 pp). I was wondering if this was possible?I will not be editing any base strings to the website, I will just be adding a seperate registration button that allows connection to my server computer. I was also wondering where to put the code and how I would be doing this.

Heres the Information I have on adding the Registration code.

-------------------------------------------------------------------------------------------------------

User Registration (register.php)
Now we can have a page where the user can register their account. It will be part HTML and part PHP. It can look as follows:

Sample Code

<html></html><form action="register.php" method="post">
Username: <input name="username" type="text" />
Password: <input type="password" name="password" />
Email: <input name="email" type="text" />
<input type="submit" value="Submit" />
</form>

Copyright exforsys.com

The basic HTML structure of the registration form is shown above. We can add some PHP code to handle the actual registration part. The form will send the information through POST, and we can handle it with PHP. We will take the username, make sure it does not exist, then create the account using mysql_query() to place the values within the database.

Sample Code

<?php
include("db.php");
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']))
{
//Prevent SQL injections
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
//Get MD5 hash of password
$password = md5($_POST['password']);
//Check to see if username exists
$sql = mysql_query("SELECT username FROM usersystem WHERE username = 'username'");
If (mysql_num_rows($s?>0))
{
die ("Username taken.");
}
mysql_query("INSERT INTO usersystem (username, password, email) VALUES ( '$username', '$password', '$email')") or die (mysql_error()); echo "Account created."Wink
}
?>
<html></html>
<form action="register.php" method="post">
Username: <input name="username" type="text" />
Password: <input type="password" name="password" />
Email: <input name="email" type="text" />
<input type="submit" value="Submit" />
</form>

Copyright exforsys.com


The login page (login.php)
Final let us create the login page. For login.php, we can have a form for the username and password, then we pass those values to the user_login() function we made earlier in the db.php script.
We can once again have a basic HTML structure for login.php

Sample Code

<html></html>
<form action="login.php" method="post">
Username: <input name="username" type="text" />
Password: <input type="password" name="password" />
<input type="submit" value="Submit" />
</form>

Copyright exforsys.com

Now, we can add the PHP code before the HTML again to process the login, just like with the registration.

We do not really need to add much code, because most of it was done in the db.php page. Here is what you need:

Sample Code

<?php
include("db.php");
if (isset($_POST['username'] && isset($_POST['password']))
{
user_login($_POST['username'], $_POST['password']);
}
?>
<html></html>
<form action="login.php" method="post">
Username: <input name="username" type="text" />
Password: <input type="password" name="password" />
</form>

Copyright exforsys.com

You now have everything you need for your user system. For all of the pages on your website, you must place this line at the very first line for this to work:

Sample Code

<?php include "db.php";?>
You can then show their username like so:
<?php echo "Logged in as: " . $_SESSION['username'];?>

Copyright exforsys.com

That completes the demonstration on how to implement a user login/membership system in your website.


Here's another page from the same subject on the source site. It was to long to paste here.
More Info:

I'm sorry that it was so much to read, I just couldn't find a way to summarize it without leaving important details out. I appreciate any help

-Thank you ^.^


Last edited by matchan2 on August 13th 2010, 12:10 am; edited 1 time in total
avatar
matchan2
New Member

Posts : 9
Reputation : 0
Language : English

Back to top Go down

Solved Re: Adding Html/php so people can register

Post by MrMario August 11th 2010, 8:26 pm

We don't support Php nor database access so whatever your tying to do with this isn't going to work.
MrMario
MrMario
Helper
Helper

Male Posts : 22186
Reputation : 1839
Language : test

Back to top Go down

Solved Re: Adding Html/php so people can register

Post by matchan2 August 11th 2010, 8:30 pm

Awwww. Thank you ^.^
avatar
matchan2
New Member

Posts : 9
Reputation : 0
Language : English

Back to top Go down

Solved Re: Adding Html/php so people can register

Post by matchan2 August 11th 2010, 8:35 pm

What if I was to write a registration html code because I know a string that would allow connection through link to external area ( my computer) without compromising or accessing in any way the database? It would be added to the location Administrator panel>display>templates>General. Even though I can do this the only question is If this is allowed?
avatar
matchan2
New Member

Posts : 9
Reputation : 0
Language : English

Back to top Go down

Solved Re: Adding Html/php so people can register

Post by kirk August 11th 2010, 9:05 pm

if you can add it to your template and it's not in any violations then the answer would be yes.
What do you want them to register too?
i mean you can just add a click-able banner or link somewhere leading to the registration or even a html page with what ever you want on It leading where ever you like?
kirk
kirk
Forumaster

Male Posts : 11037
Reputation : 653
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum