Jump to content

creating a text-based MMORPG....needing help with sign up and login scripts


darkmonk

Recommended Posts

[move]HELP!![/move]

im new to php and html...and im having trouble creating a sign up and login script... iv created and a database and some login and sign up scripts but it just doesnt seem to work!

if someone could help me or walk me through is step by step that would be awesome!

 

thanks all

Link to comment
Share on other sites

<move>scripts  scripts    scripts    scripts      scripts      scripts</move>

 

<b>database:</b>

 

$sql = 'CREATE TABLE `blah1` ('

        . ' `user ID` VARCHAR(10) NOT NULL, '

        . ' `password` VARCHAR(10) NOT NULL, '

        . ' `e-mail` VARCHAR(50) NOT NULL, '

        . ' `name` VARCHAR(50) NOT NULL, '

        . ' `sex` VARCHAR(6) NOT NULL,'

        . ' PRIMARY KEY (`user ID`)'

        . ' )'

        . ' ENGINE = myisam;';

 

 

<b>login:</b>

 

<!doctype html public "-//w3c//dtd html 3.2//en">

 

<html>

 

<head>

<title><-underground-></title>

 

<center>

<img src='http://cdn.myfonts.com/111/textimage/e1/e1535af9cae1968c4e1842f4a470fc90.gif'

size width='600' height='150'></center>

 

<p><h1>

welcome to <-underground->...life is hard!!

<h1></p>

 

<meta name="GENERATOR" content="Arachnophilia 4.0">

<meta name="FORMATTER" content="Arachnophilia 4.0">

</head>

 

<body bgcolor="black" text="red" link="pink" vlink="#800080" alink="#ff0000">

 

<form action='loginck.php' method=post>

<table border='0' cellspacing='0' cellpadding='0' align=center>

  <tr id='cat'>

  <tr> <td bgcolor='#f1f1f1' ><font face='verdana, arial, helvetica' size='2' align='center'>   Login ID     

</font></td> <td bgcolor='#f1f1f1' align='center'><font face='verdana, arial, helvetica' size='2' >

<input type ='text' class='bginput' name='userid' ></font></td></tr>

 

<tr> <td bgcolor='#ffffff' ><font face='verdana, arial, helvetica' size='2' align='center'>   Password 

</font></td> <td bgcolor='#ffffff' align='center'><font face='verdana, arial, helvetica' size='2' >

<input type ='text' class='bginput' name='password' ></font></td></tr>

 

<tr> <td bgcolor='#f1f1f1' colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'> 

<input type='submit' value='Submit'> <input type='reset' value='Reset'>

</font></td> </tr>

 

 

<tr> <td bgcolor='#ffffff' ><font face='verdana, arial, helvetica' size='2' align='center'>  <a href='signup.php'>New Member Sign UP</a></font></td> <td bgcolor='#ffffff' align='center'><font face='verdana, arial, helvetica' size='2' >

Forgot Password ?</font></td></tr>

 

<tr> <td bgcolor='#f1f1f1' colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'> 

 </font></td> </tr>

 

 

</table></center></form>

 

<center>

<br><br><p><h2>Welcome to <b><-Underground-></b>...Here you can do just about anything. You can rob a bank, have a rap battle, train at the gym and even go to college to enjoy a nice shoot up.<br>

The only aim here is to become the best,<br> challenge rival gangs and bands...Beat them down and spit in there wounds!</h2></a></center>

 

</body>

 

</html>

 

 

<b>loginck:</b>

 

 

<?

include "include/session.php";

 

$dbservertype='mysql';

$servername='blackapplehost.com';

// username and password to log onto db server

$dbusername='darkmonk_data';

$dbpassword='screwyou';

// name of database

$dbname='blah1';

 

////////////////////////////////////////

////// DONOT EDIT BELOW  /////////

///////////////////////////////////////

connecttodb($servername,$dbname,$dbusername,$dbpassword);

function connecttodb($servername,$dbname,$dbuser,$dbpassword)

{

global $link;

$link=mysql_connect ("$servername","$dbuser","$dbpassword");

if(!$link){die("Could not connect to MySQL");}

mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());

}

//////////////////////////////

?>

<!doctype html public "-//w3c//dtd html 3.2//en">

 

<html>

 

<head>

<title><-underground-></title>

<meta name="GENERATOR" content="Arachnophilia 4.0">

<meta name="FORMATTER" content="Arachnophilia 4.0">

</head>

 

<body bgcolor="black" text="red" link="pink" vlink="#800080" alink="#ff0000">

 

<center>

<img src='http://cdn.myfonts.com/111/textimage/e1/e1535af9cae1968c4e1842f4a470fc90.gif'

size width='600' height='150'></center>

 

<?

$userid=mysql_real_escape_string($userid);

$password=mysql_real_escape_string($password);

 

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM plus_signup WHERE userid='$userid' AND password = '$password'"))){

if(($rec['userid']==$userid)&&($rec['password']==$password)){

include "include/newsession.php";

            echo "<p class=data> <center>Successfully,Logged in...welcome back<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";

    print "<script>";

      print " self.location='welcome.php';"; // Comment this line if you don't want to redirect

          print "</script>";

 

}

}

else {

 

session_unset();

echo "<font face='Verdana' size='2' color=red>Wrong!! stupid tit! get it right this time <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";

 

}

?>

 

</body>

 

</html>

 

 

<b>logout:</b>

 

<?

 

include "include/session.php";

session_unset();

session_destroy();

 

?>

<!doctype html public "-//w3c//dtd html 3.2//en">

 

<html>

 

<head>

<title><-underground-></title>

 

<center>

<img src='http://cdn.myfonts.com/111/textimage/e1/e1535af9cae1968c4e1842f4a470fc90.gif'

size width='600' height='150'></center>

 

<p><h1>

welcome to <-underground->...life is hard!!

<h1></p>

 

<meta name="GENERATOR" content="Arachnophilia 4.0">

<meta name="FORMATTER" content="Arachnophilia 4.0">

</head>

 

<body bgcolor="black" text="red" link="blue" vlink="#800080" alink="#ff0000">

<?

 

echo "<center><font face='Verdana' size='2' >fine then, leave!! worthless quitter. <br><br> <a href=login.php>Login</a></font></center>";

 

?>

 

 

</body>

 

</html>

 

 

<b>signup</b>

 

<!doctype html public "-//w3c//dtd html 3.2//en">

 

<html>

 

<head>

<title><-underground-></title>

<script type="text/javascript">

function validate(form) {

if (!document.form1.agree.checked) { alert("Please Read the guidlines and check the box below  .");

return false; }

return true;

}

</script>

 

<meta name="GENERATOR" content="Arachnophilia 4.0">

<meta name="FORMATTER" content="Arachnophilia 4.0">

</head>

 

<body bgcolor="black" text="red" link="blue" vlink="#800080" alink="#ff0000">

 

<center>

<img src='http://cdn.myfonts.com/111/textimage/e1/e1535af9cae1968c4e1842f4a470fc90.gif'

size width='600' height='150'></center>

 

 

<table border='0' width='50%' cellspacing='0' cellpadding='0' align=center><form name=form1 method=post action=signupck.php onsubmit='return validate(this)'><input type=hidden name=todo value=post>

 

<tr bgcolor='#f1f1f1'><td align=center colspan=2><font face='Verdana' size='2' ><b>Signup</b></td></tr>

<tr ><td > <font face='Verdana' size='2' >User ID</td><td ><font face='Verdana' size='2'><input type=text name=userid></td></tr>

 

<tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Password</td><td ><font face='Verdana' size='2'><input type=text name=password></td></tr>

<tr ><td > <font face='Verdana' size='2' >Re-enter Password</td><td ><font face='Verdana' size='2'><input type=text name=password2></td></tr>

 

 

<tr bgcolor='#f1f1f1'><td ><font face='Verdana' size='2' > Email</td><td  ><input type=text name=email></td></tr>

<tr ><td > <font face='Verdana' size='2' >Name</td><td ><font face='Verdana' size='2'><input type=text name=name></td></tr>

 

<tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Sex</td><td ><font face='Verdana' size='2'>  <input type='radio' value=male checked name='sex'>Male <input type='radio' value=female  name='sex'>Female</td></tr>

 

<tr ><td > <font face='Verdana' size='2' >I agree to terms and conditions</td><td ><font face='Verdana' size='2'><input type=checkbox name=agree value='yes'></td></tr>

 

<tr bgcolor='#f1f1f1'><td align=center colspan=2><input type=submit value=Signup></td></tr>

</table>

 

<center>

<br><br><font face='Verdana' size='2' ><a href='login.php'>Already a member ? Please Login</a></font></center>

 

 

 

 

</body>

 

</html>

 

 

<b>signupck:</b>

 

<?

 

 

$dbservertype='mysql';

$servername='blackapplehost.com';

// username and password to log onto db server

$dbusername='darkmonk_data';

$dbpassword='screwyou';

// name of database

$dbname='blah1';

 

////////////////////////////////////////

////// DONOT EDIT BELOW  /////////

///////////////////////////////////////

connecttodb($servername,$dbname,$dbusername,$dbpassword);

function connecttodb($servername,$dbname,$dbuser,$dbpassword)

{

global $link;

$link=mysql_connect ("$servername","$dbuser","$dbpassword");

if(!$link){die("Could not connect to MySQL");}

mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());

}

//////////////////////////////

?>

<!doctype html public "-//w3c//dtd html 3.2//en">

 

<html>

 

<head>

<title><-underground-></title>

 

<center>

<img src='http://cdn.myfonts.com/111/textimage/e1/e1535af9cae1968c4e1842f4a470fc90.gif'

size width='600' height='150'></center>

 

<p><h1>

welcome to <-underground->...life is hard!!

<h1></p>

 

<meta name="GENERATOR" content="Arachnophilia 4.0">

<meta name="FORMATTER" content="Arachnophilia 4.0">

</head>

 

<body bgcolor="black" text="red" link="blue" vlink="#800080" alink="#ff0000">

<?

if(isset($todo) and $todo=="post"){

 

$status = "OK";

$msg="";

 

// if userid is less than 3 char then status is not ok

if(!isset($userid) or strlen($userid) <5){

$msg=$msg."User id should be =3 or more than 5 char length<BR>";

$status= "NOTOK";}

 

if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){

$msg=$msg."Userid already exists. Please try another one<BR>";

$status= "NOTOK";}

 

 

if ( strlen($password) < 3 ){

$msg=$msg."Password must be more than 3 char legth<BR>";

$status= "NOTOK";}

 

if ( $password <> $password2 ){

$msg=$msg."Both passwords are not matching<BR>";

$status= "NOTOK";}

 

 

if ($agree<>"yes") {

$msg=$msg."You must agree to terms and conditions<BR>";

$status= "NOTOK";}

 

if($status<>"OK"){

echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";

}else{ // if all validations are passed.

$query=mysql_query("insert into plus_signup(userid,password,email,name,sex) values('$userid','$password','$email','$name','$sex')");

echo "<font face='Verdana' size='2' color=green>Welcome, You have successfully signed up<br><br><a href=login.php>Click here to login</a><br></font>";

}

}

?>

 

 

</body>

 

</html>

 

 

<b>welcome</b>

 

<?

 

include "include/session.php";

?>

<!doctype html public "-//w3c//dtd html 3.2//en">

 

<html>

 

<head>

<title><-underground-></title>

 

<center>

<img src='http://cdn.myfonts.com/111/textimage/e1/e1535af9cae1968c4e1842f4a470fc90.gif'

size width='600' height='150'></center>

 

<p><h1>

welcome to <-underground->...life is hard!!

<h1></p>

 

<meta name="GENERATOR" content="Arachnophilia 4.0">

<meta name="FORMATTER" content="Arachnophilia 4.0">

</head>

 

<body bgcolor="black" text="red" link="blue" vlink="#800080" alink="#ff0000">

<?

 

echo "<center><font face='Verdana' size='2' >Welcome userid=$session[userid]<br><br>You must see your userid here (above) <br><br><br>Click <a href=logout.php>here to logout</a><br></center></font>";

 

?>

 

 

</body>

 

</html>

 

 

<u>INCLUDE:</u>

 

 

<b>newsession:</b>

 

<?php

//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);

$session['id']=session_id();

$session['userid']=$userid;

//echo $session['userid'];

?>

 

 

<b>session:</b>

 

<?php

session_start();

session_register("session");

?>

 

 

 

thats all the ones for the sign up etc.....

 

Link to comment
Share on other sites

Posting all your code like that without any description of what the problem isn't going to get us anywhere. Narrow your problems down and post the relevent code only, asking one question at a time.

Link to comment
Share on other sites

as i said im only new to php and html! i tried teaching myself online...for the past 2-3 days!

 

But surely your not new to asking questions. From our point of view that is just a mass of code (same as Im sure it is to you).

 

The first thing you might try is debugging your connection.

 

Change this line (I can't even tell what file its in sorry)...

 

if(!$link){die("Could not connect to MySQL");}

 

to

 

if(!$link){die(mysql_error());}

 

Now what output do you get?

Link to comment
Share on other sites

ok iv edited it again but now the output is "could not open dbAccess denied for user 'darkmonk_data'@'localhost' to database 'test1'"

 

can anyone help me wioth this....this comes up when i submit the sign up form

Link to comment
Share on other sites

That probably means the MySQL user darkmonk_data doesn't have privileges to the database "test1".  You'll need to make sure that darkmonk_data has the correct privileges.  I'm not familiar with that webhost -- do you have phpMyAdmin?  If so, go in there, then click "Privileges".

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.