Jump to content

Hiding login form and its div after user logged in


edgarasm

Recommended Posts

Hi there php freaks im looking at hiding a login form at the index page ,so once the user logs in if he decides to click on home/index page ,he wont see login form again untill he logs out 

 

my index page code

<?php include 'header.php'; ?>
<link rel=”apple-touch-icon” href="http://www.tugapay.com/webicon.png"
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="apple-touch-startup-image" href="/startup.png">
<meta name="apple-mobile-web-app-capable" content="yes" />

	<div id="content">
		<div class="container inner">

			<form action="/account/index.php" method="POST" enctype="multipart/form-data">
			<form action="loginprocess.php" method="POST">
			<form action="/account/register.php" method="POST" enctype="multipart/form-data">	
				<div class="one_third">
					<label>Email Address: </label>
					<input type="text" id="login_email" name="login_email" spellcheck="false">	
				</div>
				
				<div class="one_third">
					<label>Password: </label>
					<input type="password" id="login_password" name="login_password" spellcheck="false">	
				</div>
				
				<div class="one_third" style="padding-top: 0px;">
					<td><a href="../account/loginprocess.php"<input type="submit" id="login_submit" name="login_submit" style="background: light_blue;" class="button" value="Login to Account">Login to Accounts</a></td>
				</div>
				
				<div class="one_third" style="padding-top: 0px;">
				<td><a href="/account/register.php" id="login_submit" name="login_submit" input type="submit"   style="background: light_blue;" class="button" value="Register">Register</a></td>
				</div>
								
			</form>
		
		</div>
	</div>

	<div id="slider" class="flexslider">
		<ul class="slides">
			<li>
				<img src="/assets/images/blog/pic.jpg" alt="">
				<div class="inner">
					<h2 class="flex-caption" style="bottom: 60px;">Want to send money Quick & Easy?</h2>
					<h3 class="flex-caption" style="bottom: 20px;">Join Us today to see how its done</h3>
				</div>
			</li>
		</ul>
		<script type="text/javascript">
		/* <![CDATA[ */
			$(window).load(function(){
				$('.flexslider').flexslider({
					//smoothHeight: true,
					controlNav: false,
					animation: "slide",
					start: function(slider){
						$('body').removeClass('loading');
					}	
				});
			});
		/* ]]> */
		</script>
	</div>
	<div id="content">
		<div class="container inner">
			<div class="one_third">
				<i class="icon-time large left"></i>
				<div class="column">
					<h2>Easy & Secure</h2>
					<p>Our Payment System is User friendly and Most Secure to ensure your identity and money is secure .</p>
					<a href="#" class="button large">Read More</a>
					
				</div>
			</div>
			<div class="one_third">
				<i class="icon-magic large left"></i>
				<div class="column">
					<h2>Fast</h2>
					<p>Sending and Receiving money is fast and almost instant and covered almost everywhere around the globe.</p>
					<a href="#" class="button large">Read More</a>
				</div>
			</div>
			<div class="one_third">
				<i class="icon-bar-chart large left"></i>
				<div class="column">
					<h2>Grow Your Business</h2>
					<p>With Our Payment Solution you can make your business income increase rapidly using our tools .</p>
					<a href="#" class="button large">Read More</a>
				</div>
			</div>
		</div>
		<div class="separated">
			<div class="inner">
		
				<div class="container">
					<div class="highlight">
						<h2>Solutions that you need</h2>
						<p>With <strong>TugaPay</strong> Your business will only grow and your profits will only maximize very rapidly and make your business a success . Other payment solutions can be difficult to understand and register for, but our payment solutions are one of the best out there. </p>
						<p>So why not try it Today?</p>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php include 'footer.php'; ?>

And this is my loginprocess code

<?php
$email = $_POST('login_email');
$pass = md5($_POST['password']);

$query = mysql_query("SELECT * FROM users WHERE login_email = '$email' AND login_password = '$pass' AND activation IS NULL");
$data = mysql_fetch_assoc($query);


if mysql_num_rows($query)
?>

Also another problem im getting is when i click to login it redirects me to another login page which is in another folder  which i have and i want it to redirect me to dashboard

 

anyone out there could help  me with this nonsense?

 

 

Link to comment
Share on other sites

Hi edgarasm,

Is your HTML code complete? I am a bit confused as I can see three open form tags each pointing to different php script. One more thing, it is not secure to use user provided inputs directly in your SQL statement. 

Link to comment
Share on other sites

Have you thought about instead of hiding the form replace it with text that says something like logged in(as this may be unclear to the user) or a unordered list with user accounts settings and  logout links ect..
This can be easily achieve by making a global function for the logged in session, something along the lines of this

function logged_in() {
	return (isset($_SESSION['user_id'])) ? true : false;
}

I personally make the login form within a include php file, and then within that file I reference to files, loggedin.php(holds the div that has user settings and logout functionality) and login.php that obviously holds the login form and other php scripts for the login itself. The file that will hold all those included files is normally the same that checks the session. Ill give an example using the logged_in function included..

<div class="login">
<?php
	if (logged_in() == true) {
		include 'includes/loggedin.php';
	} else {
		include 'includes/login_form.php';
	}
?>
</div>

This is a very simple example so excuse me if its very roughly drafted.

Hope this helps

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.