website hosting.

hey 1337 could u post the part that actually makes it write down the info into the database? i understand all of the stuff u gave me now. looked it over last night. :) thanks in advance.
 
I will when I'll be back home tonight at 18:15. I work from 8h30 to 17h so that doesn't give me alot of time to write all those examples.
 
Ok this is how it should look like, I haven't had the time to test it but the pattern is there.

Code:
<?
session_start(); 
include "config.php";

$Checked = 'checked';
?>

<script language="javascript">
function Validate(){
	var Good        = 1; // Assume everything is ok
	var re = /^[a-zA-Z0-9]*$/; // Alphanumerical characters
	
	var User        = document.getElementById('user').value;
	var Pass        = document.getElementById('pass').value;
	var Passconfirm = document.getElementById('passconfirm').value;
	var Email       = document.getElementById('email').value;
	
	// Trim all the fields (removes spaces before)
	User        = User.replace(/^\s*|\s*$/g,"");
	Pass        = Pass.replace(/^\s*|\s*$/g,"");
	Passconfirm = Passconfirm.replace(/^\s*|\s*$/g,"");
	Email       = Email.replace(/^\s*|\s*$/g,"");
	
	if(User == ''){
		Good = 0;
		alert('The username cannot be blank.');
		document.getElementById('user').focus();
	}else if(!re.test(User)){
		Good = 0;
		alert('The username must contains alphanumerical characters only.');
		document.getElementById('user').focus();
	}else if(Pass == ''){
		Good = 0;
		alert('The password cannot be blank.');
		document.getElementById('pass').focus();
	}else if(!re.test(Pass)){
		Good = 0;
		alert('The password must contains alphanumerical characters only.');
		document.getElementById('pass').focus();
	}else if(Pass != Passconfirm){
		Good = 0;
		alert('The password and the confirmation don\'t match.');
		document.getElementById('passconfirm').value = "";
		document.getElementById('passconfirm').focus();
	}else if(Email == ''){
		Good = 0;
		alert('The email cannot be blank.');
		document.getElementById('email').focus();
	}else if(Email.indexOf(".") <= 0){
		Good = 0;
		alert('The email is not valid.');
		document.getElementById('email').focus();
	}else if(Email.indexOf("@") <= 0){
		Good = 0;
		alert('The email is not valid.');
		document.getElementById('email').focus();
	}
	
	if(Good == 1){
		document.getElementById('Form').submit();
	}
}
</script>

<?php
if(isset($_POST["PostCheck"])){ 
	$Good = 1;
	$User        = trim($_POST["user"]);
	$Pass        = trim($_POST["pass"]);
	$Passconfirm = trim($_POST["passconfirm"]);
	$Email       = trim($_POST["email"]);
	$Maillist    = $_POST["Maillist"];
	
	if($User == ''){
		$Good = 0;
		$Message = 'The username cannot be blank.';
	}elseif(!ctype_alnum($User)){
		$Good = 0;
		$Message = 'The username must contains alphanumerical characters only.';
	}elseif(!ctype_alnum($Pass)){
		$Good = 0;
		$Message = 'The password must contains alphanumerical characters only.';
	}elseif($Pass != $Passconfirm){
		$Good = 0;
		$Message = 'The password and the password confirmation don\'t match.';
	}elseif(!eregi("^[[:alnum:]_'~\-\.]+@[[:alnum:]\-\.] »{2,}\.[[:alnum:]]{2,4}$",$Email)) {
		$Good = 0;
		$Message = 'The email is not valid.';
	}else{
		$Query    = 'SELECT * FROM Members WHERE Username = '.$User;
		$Result   = mysql_query($Query);
		$num_rows = mysql_num_rows($Result);
		if($num_rows > 0){
			$Good = 0;
			$Message = 'The username is already taken by someone else, nanana!';
		}
	}
	
	if($Maillist == ''){
		$Maillist = 0;
	}
}
?>

<?php
	if($_POST["Maillist"] != 1){
		$Checked = '';
	}
	
	if($Good == 1){
		// INSERT
		$query = "INSERT INTO Members (Email, Username, Password, Maillist) VALUES ('".$Email."', '".$Username."', '".$Pass."', ".$Maillist.")";
		mysql_query($query) or die(mysql_error().' - '.$query);
		echo 'Congratulation, you are now a member!';
	}else{
		include "form.php";
	}
}else{ 
	include "form.php";
}
?>

You might have noticed that I put the form into another page :
form.php

Code:
	<?php echo '<span >'.$Message.'</span>'; ?>
	<form name="Form" id="Form" action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
	<input name="PostCheck" id="PostCheck" type="hidden" value="1">
	<table align="left"  cellspacing="0" cellpadding="3" >
	<tr><td align="right">Username :</td><td><input type="text" name="user" id="user" maxlength="20" size="25" value="<?php echo $User; ?>"></td></tr>
	<tr><td align="right">Password :</td><td><input type="password" name="pass" id="pass" maxlength="20" size="25" value="<?php echo $Pass; ?>"></td></tr>
	<tr><td align="right">Confirm password :</td><td><input type="password" name="passconfirm" id="passconfirm" maxlength="20" size="25" value="<?php echo $Passconfirm; ?>"></td></tr>
	<tr><td align="right">Email :</td><td><input type="text" name="email" id="email" maxlength="200" size="35" value="<?php echo $Email; ?>"></td></tr>
	<tr><td align="right"> </td><td></td></tr>
	<tr><td colspan="2">Subscribe to the mailing list <input type="checkbox" name="Maillist" id="Maillist" value="1" <?php echo $Checked; ?>></td></tr>
	<tr><td align="right"> </td><td></td></tr>
	<tr><td colspan="2" align="center"><input type="button" name="Register" id="Register" value="Register" onClick="Validate();"></td></tr>
	</table>
	</form>
 
i see. :) autoincrement will assign numbers and increase them by one for every new member correct? and should i assign everyone an accessnumber (which i can edit later if i want to have them gain access to certain parts of the site)? and can you explain how i will be extracting this information from the Database to my site? would i make my site check to see if you have an id and then check your access level? ur the best 1337. :)
 
Yes, the autoincrement will automaticly increase the Id by one so you never have to put the Id when you insert, this way you let the DB handle the Ids and you are sure that you don't have the same Id in the same table.

If you want to implement the access_level, its very easy (well you decide how you want it to work but..). You can set the default value for the access_level field to 1 in the DB. This way, if you don't specify the access_level when you insert a row, it will (guess what) use the default value wich means that all the new users will be level 1. Now if everyone has an access_level of 1 its not very usefull so you would add a module in your admin pannel that would list all the users and then you could select one user and change its access level to whatever you want. (The admin pannel im talking about is another Web page that only the admin can access.) I'll explain the admin pannel later if you are interested.

Well, with what we did before you can guess how the login system will work. The thing to remember: to retrieve data from the DB you use the "SELECT" SQL query. Your login form will have 2 fields : Username and Password. They will be build the same way you built the other form. The only thing that is different is that when it will post, instead of inserting the data into the DB, you will look if the username and password provided match with those in the DB.

Code:
$query = "SELECT * FROM Members WHERE Username = '".$_POST["Username"]."' AND Password = '".$_POST["Password"]."'";
$result = mysql_query($query);
while($row = mysql_fetch_object($result)){
   $Logged = 1
   $User = $row->Username;
   $Access = $row->access_level;
}
if($Logged == 1){ // If there is a row where the username and pass = those provided by the user, then it means the informations are correct so we can log him in
    $_SESSION["Username"] = $User; // Omg is this the almighty session variable? Yes it is.
    $_SESSION["Level"]       = $Access;
}else{
   $Message = 'Are you trying to sneak into my palace buddy?';
}

When I use the single quotes around the value of the fields it means that this data is a string (varchars, text, dates etc...). You don't have to put quotes when the data type is an integer or float etc...

Ok now the used is logged in (of course there is more things involved when you do a proper site but you get the mechanics (and it actually works).

Now when the user attempts to open a page, you will put this at the top of the page:
Code:
 if($_SESSION["Level"] < 3){ // (suppose you need to be a level 3 to access that page)
   echo 'You can't go there buddy';
   exit();
}

You can google for session variables to understand exactly what they do but it's quite easy to understand, they are variables that keep their values until you close the browser (well the browser manage the session variables so it might timeout after a certain amount of time if you stop browsing the net but otherwise the variables will keep their values even if you go to another page (that's how it works when you log in to that very Forum)).
 
wow, 1337 ur awesome. do u have any other recommendations(besides the access thing) that u think should be in a proper website? i'll have to try and create the login form(shouldnt be too hard). do u happen to know how to create a forums or download a script for forums? i wanted to know how do u make it so when u register for the site it registers u for the forums also? i wouldnt want it to be repetitive for the visitor. i know if i wanted to do this i would most likley have to create my own forums or edit someone elses. any ideas 1337? :)
EDIT:
elseif(!eregi("^[[:alnum:]_'~\-\.]+@[[:alnum:]\-\.] »{2,}\.[[:alnum:]]{2,4}$",$Email))
{
$Good = 0;
$Message = 'The email is not valid.';
}
i know this is supposed to check to see if its (something with letters or numbers here)@(something with letters or numbers here).(something with letters or numbers here) but i think i'm having problems with this. i'm running the code and its always saying the email is not valid. i'll try to fix it but could u explain what all that stuff means?
DOUBLEEDIT: nvm i fixed it after playing around with it. :) but now i get this:
Connected to MySQL

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/aleahn.farvista.net/validate.php on line 94
Congratulation, you are now a member!
i'm usually try to fix these kinds of erros but...i have no clue what this means. i'll play around with it and hopefully i'll fix it. if not i need help. well atleast i got it to work...sort of. :)
TRIPLEEDIT:
else
{
$Query = 'SELECT * FROM Members WHERE Username = '.$User;
$Result = mysql_query($Query);
$num_rows = mysql_num_rows($Result);
if($num_rows > 0)
{
$Good = 0;
$Message = 'The username is already taken by someone else, nanana!';
}
}
i can't find the problem. ugh...
QUADRUPLEEDIT: fixed it. :) u forgot the " and used ' instead in front of SELECT. yay! i fixed it. its running smooth. love u 1337. :)
FIFTHEDIT: now i'm gonna make the login form. i'm really sleepy so i doubt its gonna work. arg...
SIXTHEDIT: awww screw it i'm going to bed. :( its way too late for me.
 
You could download a free forum like phpBB, then use the same table they use for the members of the forums. Coding a forum from scratch would take alot of time if you want to implement all the features of a good forum. So you could start with a good one and learn how it works. They are easy to install. Most of the time you take a folder (phpBB) then upload it to you Website, then go to the install page (www.mysite.com/phpBB/install.php) and everything will install automatically(you might have to enter the username and pass for the BD).

Usually when you get that error : Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource, it means the query is not ok. I usually use the die() function because I can print the error if there is one and display the query. So :
$num_rows = mysql_num_rows($Result) or die(mysql_error()." - ".$Query);
Would probably say something like there is an error in your SQL syntax near Username = - "SELECT * FROM Members WHERE Username = bob". Now this is easier to see that double quotes are missing before and after the username. Should be:
$Query = 'SELECT * FROM Members WHERE Username = "'.$User.'"';
 
lol i did the opposite. i added '.$User.' and put " around the whole SELECT. :) still works :D. i'm gonna download phpBB.
 
Yea you can use single or double it doesn't matter as long as you start with one type and end the string with the same. You you can do things like this too:
$Bob = "Bob ".$Roger.' Yea this is a string';
 
ok i just installed phpbb2. its working smooth. now i need to use the same form that they have to register. not sure if this is gonna be hard or easy(sounds easy :D). i'll see how far i get. oh yeah and would i use the same login form too? since u use the same register form, login form would be logical, but getting this code out of the forums might be annoying.
EDIT: i was thinking of just editing the login system i made right now to post information into the database of the forums. i don't know this would work but what do u suggest 1337? yeah ur probably at work so i'll wait. :)
DOUBLEDIT: ummm holyshit..... there is like a tankload of information when i went into the database to see what the forum stores. it has like last visit, user level, user post, user timezone, user style, userdata format, etc. all this crap. plus the password is like encrypted. it looks like crap under userpassword(like a bunch of random letters and numbers). ack. that was a bad idea. but i dont know how to include the register form from the forums into my site. and i dont want that really really long register form(with like AIM, ICQ, HOTMAIL, occupation, signature, interest, always show my email address, pop up, hide ur online status, OMG THE LIST IS TOO DAMN LONG IT KEEPS GOING AND GOING). i need a simplified one with just username, email, password, and password confirm. hey 1337 i was also wondering how do i set up a security code confirmation thing? like they have a number inside a picture and u have to write it down(to make sure no bots can create like 1293192 accounts). i'll keep messing around with this.
TRIPLEEDIT: i mean i could have an inside frame in my website and when someone clicks register i could make it link to the register page, but that would be rather ugly. i dont know....even if i did do that...they would have a forums account. how do i make it so it says welcome *username* at the top of the page for my website? or like welcome guest. well i couldnt probably make the same script u did but edit it to look for the information in the forums files but this is getting complicated. shit. this shit keeps getting worse and worse.
 
Haha your post made me laugh. I imagine when you looked at the tankload of pages lol. Huh, let's try to break those questions one by one.

The pass in MD5 encrypted. That's why you see "random numbers". But it is alot simpler than it seems. When you were doing the check to see if the user and pass match with those in the DB (when you log in), instead of using
WHERE Password = '".$Pass."'
you would use
WHERE Password = '".md5($Pass)."'

Not that hard huh? :)

For the inscription, well I don't think it's that long because most of the fields are not mandatory, plus everyone is used to those registration forms because phpBB is one of the forums that is used the most (and vBulletin ) but all the registration forms for those forums are very similar. If you want to use yours instead you can take the one you just made and insert blank values for the fields you don't need (In the INSERT query).

For the security code, I really wonder why you want one because I doubt your Web Site will be abused by bots, this method is used when you can take advantage of an account like subscribe to contests, have free emails or web space etc... So.. well tell me if you want it anyway and i'll tell you how you could do it.

Finally, give me the code you have now, for the template of the page and I'll show you how to display feedbacks correctly on the screen (like error messages and welcome when you log in)
 
well the thing is...i dont have the site done. so...there isnt much code at all. and now that i can use the forums .php files i dont know if i'm gonna end up using the ones we made. do u recomment that i have an inside frame of the register page for the forums?
and just to let u know:
<div id="White" >
Images/white.jpg" border=0 >
</div>
[/QUOTE]
this is the way i'm gonna make most of my website(gonna do include with php for the menu and repetitive stuff). i wanted that to be at the top of my page. and another layer with z-index 3 on top of it with the writing(like welcome user or sign in | register). i'm pretty sure i can take care of logging in if i just make an inside frame to the login site for my forums. do u recommend that i do it this way? or do u recommend that i use the one that we made(mostly u). one more thing. yeah i took out the security code idea. lol. :) hopefully u can help me.
 
I'm not sure what you want to do with that frame thing but my guess is that it's not very common, maybe if you show me an example (linky to a Web page) I will understand.

I suggest you to use the left or right login module thing like in every Web pages that require to login.

Example of a Web site i'm working on: http://www.easterntownships.org/atrce/ (The translation is real bad (where someone else has translated :))

Look at the right, Returning Users, this is how it should look like.

Or this one: http://membres.lycos.fr/zepites/
The logins always look the same. They have different styles but they are very similar.

And they are include files, because in programmation, if some lines of code are repeating, then it's not good. Imagine you made a mistake in your login (you put parseword instead of password) you would have to change all the pages... In easterntownships I have over 2k pages, you can imagine the work it would require... You probably already know that but I wanted to insist on that point :)

Now that you know the basics of php I think you are ready to sit down and write all the modules you will need and decide the general layout of the Web site. Make a template in PS and post it here.
 
hmm..instead of the login form being right in the open i was thinking of doing it more like this: http://www.insurgencymod.net you can see that they have a link to a login page(which was what i was thinking about doing). oh and just to be sure...template means like all the pictures and stuff right? what it actually looks like right? i'll try to make my site tomorrow if i have enough time.
 
Ah ok I see what you mean now, this is a good idea, you could do it that way.
Yea this is what I mean by template, an example of what the main page would look like but instead of coding all the stuff you make it in PS.
 
wouldnt that take forever? making it in PS and then changing it into code? i've never made a site that way. :-/ wow. i just imagine what the site will look like in my head and if it doesnt turn out too great i just edit parts and keep editing(after i make the site with code + images). i've never made a template before. might be fun. :)
 
No it will not take forever, it will be faster, easier, nicier, flabergaster. Trust me, this is THE method. Plus, you can cut everything in PS and generate the HTML template automatically, then load the site in DreamWeaver and make modifications. You can't code a nice Web site in Notepad, too much tables to mess with.
 
i dont use tables. i just position them around. like 200 pixels from the left ect. and i was thinking of centering the whole thing by having index.php or html just have :
<iframe="index.html">​
not sure if it will work but this is the method i'm gonna try out. :)
EDIT: hey 1337, it's ok to use stock photos right? they are free right?
 
Nooooo!! Don't do it that way. Tables work on all browsers and relatively the same way on all versions since IE5. Frames suck, iframe are a little better but don't use em for this purpose. It's gonna be a real headache to position all the stuff when you want to enable/disable modules and pictures/text. Please... :(
 
what do u mean enable/disable modules and pictures/text? ok here is an example of how i would make my site: http://aleahn.farvista.net/menu.html i made this is about 5 min of copying the same code over and over and just re-editing the image sizes, etc. i was thinking of having my index.html have an iframe with the WHOLE site in there so it can be centered(centered when user has a larger resolution than 800x600).
EDIT: the site is just something i made fast. don't say anything about it, i know it sucks.
 
I meant, like in http://www.easterntownships.org/atrce/, if there are no last minute deals, the e-coupons will automatically go up to take the place of the last minute deal.

I guess it could be done with relative positionning. Do it the way you are more comfortable with and we'll see how it'll look and behave.

Stock photos?
 
By uploading any images to this site you are automatically assumed to grant license for the use of said images to any and all visitors to this website with the restrictions you specify at each photo.

You may use any of the photos in our system free of charge for any commercial or personal design work if you obey the specified restrictions concerning each photo you download.

Selling and redistribution of these photos (individually, or as a whole) without written permission is prohibited. Using the photos in website templates, on postcards, mugs etc. doesn't count as selling or redistribution, however you are not allowed to build a gallery using the photos you downloaded from here.

Although these images are made available free of charge or obligation, if you use any images here PLEASE remember to contact the artist using the e-mail address found on the artists page. This is a simple courtesy and means a lot to many of our contributors who simply would like to know how their work is used.

These rules differ from web sites to others, read the appropriate section (term of use) and you'll know what you can and can't do.
 
i see. 1337 how do u know when u can use a font to help create images without making it illegal? i've been thinking about it and...i thought maybe the only way is to make my own font. do u know the policies on fonts? oh and if ur experienced with photoshop do u recommend that i make my own font? or do u think it would be too much of a hassle? i want to create a font similiar to the one i used to create the sample image(the font looks pretty complicated).
EDIT: like how do u get ur fonts and stuff? do u just use the default ones that windows comes with?
DOUBLEEDIT: well i've made some changes to the site(redid the top picture). http://aleahn.farvista.net/index.php it looks very plain so i need u to help me out. i usually have an arsenal of pictures at my disposal when i create a site but this time (since i want it to be legal and and(dont want to come across any copyright problems, etc.)) i didnt have much to work with. if u have a site with lots of free pics that would be useful. u might want to suggest what else i add with like brushes and such(blood splatters, etc.)) i actually feel pretty humilated by this work. i think its very low in my opinion. :(
TRIPLEDIT: i seriously need suggestions for my site. need help 1337. i can't come up with anything because i dont have many stock photos that i can actually put to use. :|
 
For the fonts, I don't think that creating one is necessary, it will take alot of time. You can use free fonts (there are alot) or start with one and then modify it in PS.

At this point you should know all the sections you will put into your Web site. This will help you to choose what you will put in the menu. When you know what will be the links in the menu, you have a better idea of how you're gonna display your menu. It seems you already know how you will position everything. (menu on the right).

For the template, I usually start by thinking of a theme, then the colors. I don't know what your MOD is about so you'll have to figure out what you want to tell to the visitors when they see the site. For example, if your MOD is based on violence, the theme could be blood and firearms. For the color, well I think it could be mostly monochrome but to add something interesting I would put red, like everything would be black and white except blood splashes something like that... (This is just to give you an example of finding a theme for the website and the color palette).

Then, having those two things in mind, I google or go on art Websites like devianart to give me more inspiration. I know the direction I want to go but I still need ideas so I click on every pictures/background/interface/designs that looks similar to what I want to to and I save the images on my comp (usually about 20-30). Then I look again at all the images I saved to see exactly what is interesting and what I will do.

Then I fire up PS and draw what would look like the main page. When I'm satisfied with the result, I see if everything is feasible for a Web page. If not, I move or change some parts.

Real pictures are not mandatory. You could use stuff from your MOD (models, screenshots, concept art).
 
umm 1337, i can't seem to figure out what fonts are free or not. i've been to the free font sites and even there(inside the FAQ) they say that if u want to use a font for online or commercial purposes u have to ask the author because the site doesn't have the power to grant permission. i'll try to work on a theme(prolly not gonna happen since the mod really has no theme). my mod is based of zombies, mutants, and survivors. yeah i dont know how i'm gonna display that. :| and uhh the last part u said. none of the mod is done except for unskinned weapon models. :(
 
xC4RN4G3x said:
my mod is based of zombies, mutants, and survivors

That's a good start, the theme might be rotten flesh, rusty stuff (depends if the zombies just arrived or if it's been a while since anybody came in the city), abandoned city (if your levels are in a city like resident evil, I'd see papers everywhere on the road and cars on fire etc...), darkness, if it's more indoor then dark hallways... The theme is just a guideline, when you'll look at pictures on the net you'll get better ideas and you'll imagine how the Web site will look like.

And for the fonts, you could do like you do for 3dsmax... Maybe you bought those fonts, maybe you drew the text from scratch in PS... who knows :)

Oh and for the stuff you made for your MOD, well, if you only have unskinned models and nothing else to show you might want to use temporary pics for your Web site, work on the MOD instead and when you'll have something to show then you do the Web site completely and you make it public. Nothing is more frustrating than a Web site with no content, plus people who are looking at MOD websites want to see screenshots and other medias, if you have none to show they might not come back.
 
yeah i'm not gonna make the site public yet...i'm just trying to get the template down(as well as the forums / login/logout system). i just bought a book on CSS(cascading style sheets i think), and i'll see what i can do. i use only simple css at the moment and i want to expand that. :)
And for the fonts, you could do like you do for 3dsmax... Maybe you bought those fonts, maybe you drew the text from scratch in PS... who knows
but what if like someone knows that its their font? arg i'm getting frustrated over fonts. i'm gonna end up using Times New Roman, i can see it. omg that is the day i'm gonna kill myself. Times New Roman, HELL NO.
 
Back
Top