Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 11-03-2012, 12:36 AM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,803
Hedgen is on a distinguished road
Default Login Box

I am following PTGigi's exploring system tutorial, and I'm making a page that will be shown whenever the person is offline. It's basically a small "cutscene" kind of thing where after a couple of clicks, someone asks you if it's the first time you are there or if you have been there before (if you click first time, brings up registration box, if you click been there before, it bring up a login box)

How do I make the signup or login forms show up?

My code so far:
Code:
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("inc/lang.php");

//***************//
//  START SCRIPT //
//***************//
if($isloggedin == "no"){ //if not logged in
$act = $_GET["act"];
$act = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $act);
$act = secure($act);

$num = $_GET["num"];
$num = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $num);
$num = secure($num);

if ($act == ""){
$article_title = "???";
$article_content = "You find yourself in a strange dark place. You try looking around, and then you see a pair of eyes. Then hundreds more pop up around you. You then see a silhouette of a person.<br><br>
<a href='/beginning.php?act=tosi'>Head towards the silhouette.</a><br>
<a href='/beginning.php?act=awsi'>Back away from the silhouette.</a><br>";
}  

else if ($act == "awsi"){ //If back away/keep trying is pressed
$article_title = "???";
$article_content = "No matter how far you walk, it seems like the silhouette isn't getting further and further away.<br><br>
<a href='/beginning.php?act=awsi'>Keep trying.</a><br>
<a href='/beginning.php?act=tosi'>Give up and go to the silhouette</a><br>";
} 
else if ($act=="tosi") { //If head towards/give up is pressed
$article_title = "???";
$article_content = "As you walk up to the silhouette, you make out a female shape.<br><br>
<a href='/beginning.php?act=ttykri'>Talk to her</a><br>";
}
else if ($act=="ttykri") {
$article_title = "???";
$article_content = "<p style='color:purple'>Yukari: Welcome to the Touhouables Open Beta. Have you been here before? Or are you new?</p><br><br>
<a href='/beginning.php?act=lin'>I've been here before. (Login)</a><br>
<a href='/beginning.php?act=sigup'>I'm new here. (Register)</a><br>";
}
else if ($act=="lin") {
//User is not logged in, so let's attempt to log them in...

$username = $_POST["username"];
$username = secure($username);
$password = $_POST["password"];
$password = secure($password);
$salt = $_POST["salt"];
$salt = secure($salt);

//User is not logged in

$loginform = "<form name='form1' method='post' action='login.php'>
  <p>Username: 
     <input name='username' type='text' id='username'>
</p>
  <p>Password: 
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
  <a href='forgotpass.php'>Forgot your password?  Click Here</a>
</form>";



if($loggedinname == "" and $password == ""){
// User is viewing login form
$article_title = "Member Login:";

$article_content = $loginform;
}
else if(($username != "" and $password == "") or ($username == "" and $password != "") ){

//Something was left blank
$article_title = "Login Error:";
$article_content = "Something was left blank.  Please try logging in again.<br><br>{$loginform}";

}
else if($username != "" and $password != ""){
// Try to log the user in

$user = $adopts->select("users", array(), "username = '{$username}'")->fetchObject();
$password = passencr($username, $password, $user->salt);

if($username == $user->username and $password == $user->password){
  $article_title = "Login Successful!";
  $article_content = "Welcome back {$username}. You are now logged in.  <a href='account.php'>Click Here to view or edit your account.</a>";

  // Set the cookie
  $Month = 2592000 + time();
  // Convert from username to uid to secure data, no need for password since it is already hashed. 
  $uid = usernametouid($username);
  $session = session_id();
  $myssession = md5($uid.$session);
  setcookie("mysuid",$uid,$Month);
  setcookie("myssession",$myssession,$Month);

  // Now update the user login session
  $adopts->update("users", array("session" => $myssession), "username = '{$username}'");

  // Time for forum-integration check
  include("inc/config_forums.php");
  if($mybbenabled == 1){
     include_once("functions/functions_forums.php");
     $forums = new Database($mybbdbname, $mybbhost, $mybbuser, $mybbpass, $mybbprefix) or die("Cannot connect to forum database, please contact an admin immediately.");
     $mybbuser = $forums->select("users", array("uid", "loginkey"), "username = '{$username}'")->fetchObject();
     $cookiesettings = array();
     $cookiesettings['cookiedomain'] = $forums->select("settings", array("value"), "name = 'cookiedomain'")->fetchColumn();
     $cookiesettings['cookiepath'] = $forums->select("settings", array("value"), "name = 'cookiepath'")->fetchColumn();
     $cookiesettings['cookieprefix'] = $forums->select("settings", array("value"), "name = 'cookieprefix'")->fetchColumn();
     mybbsetcookie("mybbuser", $mybbuser->uid."_".$mybbuser->loginkey, NULL, true, $cookiesettings);

     $mybbsid = mybb_random_str(32); 
     mybbsetcookie("sid", $mybbsid, -1, true); 
  }
}
else{
$article_title = "Login Failed!";
$article_content = "Sorry, we could not log you on with the details specified.  You can <a href='login.php'>try again</a> or <a href='forgotpass.php'>request a password reset.</a>";
$fail = 1;
}
}
}
} else { //if logged in
$article_content = "See nothing here? Then logout to be able to see what's here.";
}
//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>
I am using Mysidia Adoptables version 1.3.1
__________________
I have some small tutorials Here that show things such as re-arranging the SIDEFEED and LINKSBAR, and redirecting people after login.
Reply With Quote
  #2  
Old 11-05-2012, 12:13 PM
Hedgen's Avatar
Hedgen Hedgen is offline
Member
 
Join Date: Oct 2012
Posts: 36
Gender: Male
Credits: 4,803
Hedgen is on a distinguished road
Default

I figured it out. I just had to change $loginform to $article_content

So this:
Code:
$loginform = "<form name='form1' method='post' action='login.php'>
  <p>Username: 
     <input name='username' type='text' id='username'>
</p>
  <p>Password: 
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
  <a href='forgotpass.php'>Forgot your password?  Click Here</a>
</form>";
To this:
Code:
$article_content = "<form name='form1' method='post' action='login.php'>
  <p>Username: 
     <input name='username' type='text' id='username'>
</p>
  <p>Password: 
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
  <a href='forgotpass.php'>Forgot your password?  Click Here</a>
</form>";
Edit: How do I make it so it doesn't take you to "login.php" but it still logs you in? I kind of want to create a "visual novel" kind of feeling when the user isn't logged in, so it shows a person, few sentences later you pick login (or register) and I want to make it so if it's not a valid login information, the person says "It seems you either put the wrong username or password in, or we do not have an account for you. Please try again". Or if you put the right information in: "Welcome back." shows up, in the same window.

- Figured out the "Loading screen" thing -
__________________
I have some small tutorials Here that show things such as re-arranging the SIDEFEED and LINKSBAR, and redirecting people after login.

Last edited by Hedgen; 11-05-2012 at 06:42 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't do first login Mortain Questions and Supports 17 11-13-2015 07:56 PM
Login Problems pepofaec Questions and Supports 8 04-16-2014 08:26 PM
Unable to Login. NobodysHero Questions and Supports 42 11-23-2013 03:53 PM
Login Issue Yuki Night Questions and Supports 14 06-02-2013 02:35 PM
login fix 12345 Questions and Supports 0 03-13-2009 02:03 PM


All times are GMT -5. The time now is 11:53 AM.

Currently Active Users: 460 (0 members and 460 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636