Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Login Box (http://www.mysidiaadoptables.com/forum/showthread.php?t=3866)

Hedgen 11-03-2012 12:36 AM

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

Hedgen 11-05-2012 12:13 PM

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 -


All times are GMT -5. The time now is 01:09 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.