darkmonk Posted June 1, 2008 Share Posted June 1, 2008 [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 Quote Link to comment Share on other sites More sharing options...
nloding Posted June 1, 2008 Share Posted June 1, 2008 Please post the code that doesn't work, with any errors messages it generates, and describe the problem with details so that we can help you find the problem. I'm not gonna write the code for you However, check out this page. I send everyone to it, it helped me get started: http://www.evolt.org/PHP-Login-System-with-Admin-Features Quote Link to comment Share on other sites More sharing options...
Orio Posted June 1, 2008 Share Posted June 1, 2008 Check out the Competition Board. Competition #2 was building a text-based mmorpg, and all submissions are open source so feel free to download and learn from them. Orio. Quote Link to comment Share on other sites More sharing options...
darkmonk Posted June 1, 2008 Author Share Posted June 1, 2008 thanks guys...two mins and i will post all the scripts i have for the login and sighn up.... Quote Link to comment Share on other sites More sharing options...
darkmonk Posted June 1, 2008 Author Share Posted June 1, 2008 <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..... Quote Link to comment Share on other sites More sharing options...
trq Posted June 1, 2008 Share Posted June 1, 2008 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. Quote Link to comment Share on other sites More sharing options...
darkmonk Posted June 1, 2008 Author Share Posted June 1, 2008 as i said im only new to php and html! i tried teaching myself online...for the past 2-3 days! when i try to sign up to my site to test the scripts it comes up with "Could not connect to MySQL" Quote Link to comment Share on other sites More sharing options...
trq Posted June 1, 2008 Share Posted June 1, 2008 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? Quote Link to comment Share on other sites More sharing options...
darkmonk Posted June 1, 2008 Author Share Posted June 1, 2008 ok changed it ...now the output says "Lost connection to MySQL server during query" Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted June 1, 2008 Share Posted June 1, 2008 do you use godaddy hosting? i've seen that error a lot on their shared hosting. Quote Link to comment Share on other sites More sharing options...
xoligy Posted June 1, 2008 Share Posted June 1, 2008 servername probably should be localhost Quote Link to comment Share on other sites More sharing options...
darkmonk Posted June 1, 2008 Author Share Posted June 1, 2008 i use blackapplehost.com are there any free web hosts you would recommend? Quote Link to comment Share on other sites More sharing options...
darkmonk Posted June 1, 2008 Author Share Posted June 1, 2008 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 Quote Link to comment Share on other sites More sharing options...
nloding Posted June 1, 2008 Share Posted June 1, 2008 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". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.