Jump to content
View in the app

A better way to browse. Learn more.

The Uniform Server Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP login

Featured Replies

can some one tell me what i am doing wrong with this code

 

config.php

<?php 
$username = array('Admin', 'User'); 
$password = array('adminpass', 'userpass'); 
?>

 

index.php

<?php 
require ("config.php"); 
session_start(); 
if ((!$username) || (!$password)) 
{ 
  echo '<form name=login method=post action=""> 
  user:<input type=text name=user><br> 
  pass:<input type=text name=pass><br> 
  <input type=submit value=go> 
  </form>'; 

} 
else 
{ 
  if($user==$username && $pass==$password) 
  { 
  session_register("username"); 
  session_register("password"); 

  echo "Congratulations &username, you have logged in!<br> 
  <a href=\"?logout=1\" >Logout</a>"; 

  } 
  else 
  echo "Incorrect Password please <a href=?index.php?>try again</a>"; 

} 
if($logout==1) 
{ 
  session_unregister("username"); 
  session_unregister("password"); 
} 
?>

IPB Image

 

IPB Image

if you like this Uniform Server User Sing take em i do not mind share

IPB Image

 

IPB Image

There are a few things wrong, the following gives you a clue what you need to do:

<?php
require ("config.php"); // load in array (name and password values)
session_start();

$userin = $_POST['user']; // get from poat
$passin = $_POST['pass']; // get from post

if ( !isset($userin) || !isset($passin)) // chect not set
{
?>
  <form name="login" method="post" action="index.php">
  Name: <input type="text" name="user" ><br>
  Pass: <input type="password" name="pass" ><br>
  <input type="submit" value="go">
  </form>
<?
}
else   //both are set, check for correct values
{
  // scan each array for a match using in_array function  
  if( in_array($userin, $username) && in_array($passin, $password))
  {
  session_register("$userin");
  session_register("$passin");

  echo "Congratulations $userin, you have logged in!<br>
  <a href=\"?logout=1\" >Logout</a>";

  }
  else // failed to match
  echo "Incorrect Name or Password please <a href=?index.php?>try again</a>";

}
if($logout==1)
{
  session_unregister("$userin");
  session_unregister("$passin");
}
?>

All the best

Ric :)

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...

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.