Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    405
    Thanks
    17
    Thanked 2 Times in 2 Posts

    login form that loads content into page

    Sorry if this is an obscure, dumb question. I should know this, but I'm not thinking yet this morning, or I just haven't learned it yet? I've been asked to use a bit of code from one site, on another site. It's a login form, that then goes to a new page. But I want it to just load content into the existing page. Maybe somebody can point me in the right direction? Is there just a different way of doing the form submit?

    Basically, I have index.php, which includes login.php. When they successfully login, I want the login.php to replace itself within index.php with the new page, admin.php (or whatever page it would be)

    Right now, I have:

    Code:
    <!-- header, some code, some content -->
    <div id="client_details">
    	<div class="client_article" style="padding:50px;">
    		<?php include("inc/login.php"); ?>
    	</div>
    </div>
    <!--  some code, some content, footer -->
    The login.php looks like this:

    Code:
    <script tyle="text/javascript">
    	$(document).ready(function(){
    		$(".useDefault").addDefaultText();
    	});
    </script>
    
    <form name="login" action="clientAccess.php" method="post">
    	<h3 id="client_headers">CLIENT ACCESS</h3>
    		<p style="margin-bottom:30px;">				
    			<label class="client_labels" for="username">User Name</label><br />
    			<input class="client_formfields" type="text" name="login" id="login" maxlength="50" size="30" tabIndex="1">
    			<br /><br />
    			<label class="client_labels" for="password">Password</label><br />
    			<input class="client_formfields" type="password" name="password" id="password" maxlength="50" size="30" tabIndex="2">
    			<br /><br />
    			<input id="login_submit" type="image" src="images/submit.png" border="0" alt="Login" tabIndex="3"  value="Submit" onClick="return SubmitForm(this)"> 
    		</p>
    		<div class="form-item"><?php if(isset($_GET['error'])){ echo("<span style=\"color:#ff0000\">There was an error with the username or password.</span>"); }?></div>			
    </form>
    
    <script language="javascript">
    			
    			function SubmitForm(formData){
    				var frm=document.CreateItemForm;
    				if(document.getElementById("login").value == ""){
    					alert("Please enter your username.");
    					document.getElementById("login").focus(); return false;
    				}
    				if(document.getElementById("password").value == ""){
    					alert("Please enter your password.");
    					document.getElementById("password").focus(); return false;
    				}
    				formData.submit();
    			}
    </script>
    The clientAccess.php would be just a div full of content available to the logged in user.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,186
    Thanks
    10
    Thanked 569 Times in 550 Posts
    Code:
    <form name="login" action="index.php" method="post">
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •