Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
What do I change here??
Old 06-12-2006, 04:01 PM What do I change here??
Novice Talker

Posts: 5
Trades: 0
Someone on here gave me this code for a login but I want to add a actual login name and password but don't know what to change in the code for it to work. Here is the code.....

require('application/application_top.php');

if ( isset($_POST['login']) && isset($_POST['userid']) && isset($_POST['password']) && !$_SESSION['logged_in'] ) {



$_POST('login') == "admin" && $_POST('password') == "password";

$members_user_id = clc_db_input($_POST['userid']);
$members_password = clc_db_input($_POST['password']);

$getLogin = $db->


<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right">
<fieldset>
<form action="page2.html" target="_blank">
<form name="loginform" action="<?php echo PHP_SELF; ?>" method="post">
<nobr align="right">
<strong>USERID:</strong>
<input name="userid" accesskey="u" type="text" max="16" style="width: 150px;" />
</nobr><br />
<nobr>
<strong>PASSWORD:</strong>
<input name="password" accesskey="p" type="password" max="16" style="width: 150px;" />
</nobr><br />
<input name="login" type="submit" value="Login" /><br />
<div align="left">
<input type="checkbox" accesskey="r" name="setcookie" id="setcookie" />
<label for="setcookie">remember me</label>
</div>
<?php

if (isset($_GET['requested_page'])) {
joeywebber is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-12-2006, 05:03 PM Re: What do I change here??
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Hey Joey - I gave you that code as a basic example flow to follow to help give you ideas. Its a form that reploads itself and checks the user input with a database login info to validate and confirm.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-13-2006, 08:13 AM Re: What do I change here??
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
Lets give you something basic to work with, login pages really require some complexity to them, but if you're just starting out, how about just simple string comparisons. Everyone has to start somewhere, but simple checking whether one string is the same as the other is a basic login type system so here's some code:

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    <title>Simple Login</title>
  </head>
  <body>
    <form id="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <div>
        <label for="username">Username:</label> <input id="username" name="username" type="text" <?php if(isset($_POST['username']) && !empty($_POST['username'])) echo 'value="'.$_POST['username'].'" '?>/><br />
        <label for="passwd">Password:</label> <input id="passwd" name="passwd" type="password" /><br />
        <input id="submit" name="submit" type="submit" value="Login" />
      </div>
    </form>
    <?php 
if(isset($_POST['submit']) && strcmp($_POST['submit'],'Login') == 0)
{
  if(isset(
$_POST['username'],$_POST['passwd']) && !empty($_POST['username']) && !empty($_POST['passwd']))
  {
    if(
strcmp($_POST['username'], 'user1') == && strcmp($_POST['passwd'], 'pass1') == 0)
    {
      echo 
'<p>Thank you for logging in ' $_POST['username'] . '</p>';
    }
    else
    {
      echo 
'<p>Sorry your login was incorrect, please try again.</p>';
    }
  }
  else
  {
    echo 
'<p>You can not leave any fields blank.</p>';
  }
}
?>

  </body>
</html>
As long as this file is named with a .php extension, e.g. some_name.php and on your web server, it will work all from the same page.

There is no state remembering used in this, it's basically just asked you to insert your username which in this test is "user1" exact without quotes and case sensitive and the password is "pass1", which on successful login will display a confirmation, unsuccessful we ask you to try again, no input will tell you that you can't leave fields empty.

Since this is just a tiny example, it can still be used to move on to more complex things, only changes needed is in the code.

If you require any explanation in regards to this script, then please feel free to ask.

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.

Last edited by mastercomputers; 06-13-2006 at 08:14 AM..
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Reply     « Reply to What do I change here??
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12694 seconds with 12 queries