Jump to content

Problem with else if


chanfuterboy

Recommended Posts

Is easy i know, someone can help me out.

 

When a person is not login in, i want to display >>login<< and when the person is login show >> see it <<

 

Ok the second part i can do, thus see it, but the first of login not.

 

<?

include("classes/core.inc.php");

 

$obj = new core;

session_start();

 

include_once("classes/core.inc.php");

?>

<b><font color="#CC3300"><a href="awa.php">>>Login<<</a></font></b>

<?

 

 

if(session_is_registered('user'))

{

?>

                <a href="http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1">>>see it<<               

                </a>

               

          <?

}

?>

 

 

Link to comment
Share on other sites

First of all especially with links [ code ] and [ /code ] are your best friends. Without it, it is very very hard to see the actualy data.

 

<?
include("classes/core.inc.php");

$obj = new core;
session_start();

include_once("classes/core.inc.php");
  
   if(isset($_SESSION['user'])
   {
      print 'see it code here';
         }else {
   print 'login code here';
   } 
         ?>
         

 

make sure you are using session_start(); and assign the $_SESSION['user'] a value when you get that data.

 

Link to comment
Share on other sites

<?php
include("classes/core.inc.php");
$obj = new core;
session_start();
include_once("classes/core.inc.php");
//why are you including the same thing twice? meh	
if(session_is_registered('user'))
{
       //this will automatically redirect the user, giving them the option to see something could be a security risk
       header(Location:http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1);
      }else{
      ?>
Log in form
<?php
}
?>          

this should work. never mind stick with frosts THAT works. could somone please delete this post? thanks and sorry

 

HoTDaWg

Link to comment
Share on other sites

hi, inserting <?

include_once("classes/core.inc.php");

 

  if(isset($_SESSION['user'])

  {

      print 'see it code here';

        }else {

  print 'login code here';

  }

        ?>

 

it tell me that Parse error: syntax error, unexpected '{' in /home/george/public_html/betav2/new-site/rating/test-koi-pic.php on line 5

Link to comment
Share on other sites

hi, inserting the other code

 

<?php

include("classes/core.inc.php");

$obj = new core;

session_start();

include_once("classes/core.inc.php");

//why are you including the same thing twice? meh

if(session_is_registered('user'))

{

      //this will automatically redirect the user, giving them the option to see something could be a security risk

      header(Location:http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1);

      }else{

      ?>

Log in form

<?php

}

?>

 

 

I got Parse error: syntax error, unexpected ':' in /home/george/public_html/betav2/new-site/rating/test-koi-pic.php on line 10

 

Link to comment
Share on other sites

Seriously if you cannot figure out how to locate simple parse errors you need to read up more on PHP.

 

The problem is in the header(); you need " around the data inside IE: header("Location:etc....");

 

My suggestion learn PHP better before diving head deep into it, or even basic programming syntax structure.

Link to comment
Share on other sites

Seriously, read my above post. you did not set $_SESSION['user'] to anything. Read how to code PHP first before diving head first into it man. You cannot get anywhere without reading. So read, php.net is a great reasource.

Link to comment
Share on other sites

Hi, i have idea but i dont know how to do it small. I try and i comeup whit a long script that work, but how can i make it small as the first post that i send

 

<?

include("classes/core.inc.php");

$obj = new core;
session_start();

include_once("classes/core.inc.php");
?>
<? 
				if($_POST['login'] == 1 && !session_is_registered('user'))
				{					
					$SQL = "select * from user where Email='".$_POST['Email']."' and Password ='".$_POST['auth']."' and active=1"; 

					$obj->execute_query($SQL);
					if($obj->record_count() > 0)
					{ 
						$result = $obj->get_rows();
						$_SESSION['user'] = $result[0]['UserId'];
						$backURL=($_REQUEST['backURL'] <> '') ? $_REQUEST['backURL'] : "page1.php";
						$backURL=str_replace("~","&",$backURL);
						header("location:".$backURL);				
					}
				}
				?>

				<?
				if(!session_is_registered('user'))
				{
				?>
				<a href="jhj.oo">login</a>
				<?
				}
				else
				{
					$SQL = "select UserName AS name,user.UserId,MediaId from user,usermedia where   user.active='1' and  user.UserId =usermedia.UserId and usermedia.MainMedia = '1' and  user.UserId=".$_SESSION['user'];

					$obj->execute_query($SQL);

					if($obj->record_count() > 0)
					{
							$regresult = $obj->get_one_row();
							$name = $regresult[name];
							?>
							<div align="center">
							You are loged in as:<font size="3"><br></font><b><font size="3"><?=$name;?></font></b>
							<br><br>
							 <a href="http://www.domain.com/betav2/new-site/rating/login.php?logout=logout&id="><img border="0" src="http://www.awortinkos.com/betav_backup/betav/new-site/rating/images/logoutb.gif" width="61" height="24"></a>
				</div>
							<?
					}
				}
				?> 

Link to comment
Share on other sites

Hi, i have idea but i dont know how to do it small. I try and i comeup whit a long script that work, but how can i make it small as the first post that i send

 

 
<?

include("classes/core.inc.php");

$obj = new core;
session_start();

include_once("classes/core.inc.php");
?>
<? 
				if($_POST['login'] == 1 && !session_is_registered('user'))
				{					
					$SQL = "select * from user where Email='".$_POST['Email']."' and Password ='".$_POST['auth']."' and active=1"; 

					$obj->execute_query($SQL);
					if($obj->record_count() > 0)
					{ 
						$result = $obj->get_rows();
						$_SESSION['user'] = $result[0]['UserId'];
						$backURL=($_REQUEST['backURL'] <> '') ? $_REQUEST['backURL'] : "page1.php";
						$backURL=str_replace("~","&",$backURL);
						header("location:".$backURL);				
					}
				}
				?>

				<?
				if(!session_is_registered('user'))
				{
				?>
				<a href="jhj.oo">login</a>
				<?
				}
				else
				{
					$SQL = "select UserName AS name,user.UserId,MediaId from user,usermedia where   user.active='1' and  user.UserId =usermedia.UserId and usermedia.MainMedia = '1' and  user.UserId=".$_SESSION['user'];

					$obj->execute_query($SQL);

					if($obj->record_count() > 0)
					{
							$regresult = $obj->get_one_row();
							$name = $regresult[name];
							?>
							<div align="center">
							You are loged in as:<font size="3"><br></font><b><font size="3"><?=$name;?></font></b>
							<br><br>
							 <a href="http://www.domain.com/betav2/new-site/rating/login.php?logout=logout&id="><img border="0" src="http://www.awortinkos.com/betav_backup/betav/new-site/rating/images/logoutb.gif" width="61" height="24"></a>
				</div>
							<?
					}
				}
				?> 

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.