Highlighted

Code problems in Dreamweaver

New Here ,
Jan 01, 2018

Copy link to clipboard

Copied

Hi There,

I've got a problem with my code, I am trying to create a login system so I can give clients logins to log on and access everything they need. I have some code and it keeps coming up with " {"code":"MethodNotAllowedError","message":"POST is not allowed"} " and I've looked all around and cannot fix it. Here is the code, any idea's ???

<?php

$host="localhost";

$user="root";

$password="";

$db="loginsystem";

mysql_connect($host,$user,$password);

$mysql_select_db($db);

if(isset($_POST['username'])){

$uname=$_POST['username'];

$password=$_POST['password'];

$sql="select * from loginform where user='".$uname."'AND pass='".$password."'limit 1";

$result=mysql_query($sql);

if(mysql_num_rows($result)==1){

echo " You Have Successfully Logged in";

exit();

}

else{

echo "You Have Gone Wrong Somewhere?!"

}

}

?>

<!DOCTYPE html>

<html>

<head>

  <title>Login | LHWD</title>

  <link rel="stylesheet" type="text/css" href="style.css">

</head>

<style>

@import url('https://fonts.googleapis.com/css?family=Courgette');

</style>

<body>

  <img src="Screen Shot 2017-12-26 at 12.53.03.png">

  <form method="POST" action="#s" >

  <input class="input-group usrpwd" type="text" name="uid" placeholder="Username/Email">

  <br>

  <input class="input-group usrpwd" type="password" name="pwd" placeholder="Password">

  <button class="btn" type="submit" name="submit">Login</button>

  </form>

</body>

</html>

Nachricht geändert durch Axel Matthies: Title changed.

Yes, start by making sure that you have 2 columns in your 'loginform' table named username and password NOT user and pass as you currently have. (I personally hate abbreviated variable names and then other obscure variable names being used to match those. It just make everything so much more difficult, so lets keep it real and you'll  get along much better in my opinion.)

Copy the code below and insert it in a new Dreamweaver document and save it as login.php

<?php

session_start();

$host="localhost";

$user="root";

$password="";

$db="loginsystem";

mysql_connect($host, $user, $password);

mysql_select_db($db);

if(isset($_POST['username'])){

$username=$_POST['username'];

$password=$_POST['password'];

$sql="select * from loginform where username='".$username."'AND password='".$password."'limit 1";

$result=mysql_query($sql);

if(mysql_num_rows($result)==1){

// SET 2 SESSION VARIABLES FOR SECURITY

$_SESSION['username'] = true;

$_SESSION['password'] = true;

echo "<h2>You Have Successfully Logged in</h2>";

echo "<h3><a href='secure_page.php'>Enter Here</a></h3>";

}

else{

echo "<h2>You Have Gone Wrong Somewhere?!</h2>";

}

}

?>

<!DOCTYPE html>

<html>

<head>

<meta  charset="UTF-8" />

<title>Login</title>

</head>

<body>

<form method="post" action="login.php" >

<input class="input-group usrpwd" type="text" name="username" placeholder="Username/Email">

<br>

<input class="input-group usrpwd" type="password" name="password" placeholder="Password">

<button class="btn" type="submit" name="submit">Login</button>

</form>

</body>

</html>

Thats just about it. If you follow the instructions above you'll have a simple working login page.

Next create a page named secure_page.php in your project folder as that is where the link in the login script above is pointed if someone successfully logs in:

echo "<h3><a href='secure_page.php'>Enter Here</a></h3>";

Now what you dont want to happen is if someone happens upon secure_page.php is for the information to be shown unless someone is logged in.

At the very start of the sercure_page.php document insert the below code OR on any other page with sensitive information on it. If you browse to any page which has this information it will instantly take you back to the login.php page

<?php

session_start();

if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) {

header('Location: login.php');

}

?>

The above is a simple login approach and you can style it how you like. Please be aware you are using the old deprecated method mysql to perform this task which will still work on any servers which have php version less than 7 installed. Ideally you would want to use the new improved mysqli method and encrypt your passwords but for now I don't want to confuse you.

TOPICS
Dreamweaver | Mac OS issues

Views

744

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Code problems in Dreamweaver

New Here ,
Jan 01, 2018

Copy link to clipboard

Copied

Hi There,

I've got a problem with my code, I am trying to create a login system so I can give clients logins to log on and access everything they need. I have some code and it keeps coming up with " {"code":"MethodNotAllowedError","message":"POST is not allowed"} " and I've looked all around and cannot fix it. Here is the code, any idea's ???

<?php

$host="localhost";

$user="root";

$password="";

$db="loginsystem";

mysql_connect($host,$user,$password);

$mysql_select_db($db);

if(isset($_POST['username'])){

$uname=$_POST['username'];

$password=$_POST['password'];

$sql="select * from loginform where user='".$uname."'AND pass='".$password."'limit 1";

$result=mysql_query($sql);

if(mysql_num_rows($result)==1){

echo " You Have Successfully Logged in";

exit();

}

else{

echo "You Have Gone Wrong Somewhere?!"

}

}

?>

<!DOCTYPE html>

<html>

<head>

  <title>Login | LHWD</title>

  <link rel="stylesheet" type="text/css" href="style.css">

</head>

<style>

@import url('https://fonts.googleapis.com/css?family=Courgette');

</style>

<body>

  <img src="Screen Shot 2017-12-26 at 12.53.03.png">

  <form method="POST" action="#s" >

  <input class="input-group usrpwd" type="text" name="uid" placeholder="Username/Email">

  <br>

  <input class="input-group usrpwd" type="password" name="pwd" placeholder="Password">

  <button class="btn" type="submit" name="submit">Login</button>

  </form>

</body>

</html>

Nachricht geändert durch Axel Matthies: Title changed.

Yes, start by making sure that you have 2 columns in your 'loginform' table named username and password NOT user and pass as you currently have. (I personally hate abbreviated variable names and then other obscure variable names being used to match those. It just make everything so much more difficult, so lets keep it real and you'll  get along much better in my opinion.)

Copy the code below and insert it in a new Dreamweaver document and save it as login.php

<?php

session_start();

$host="localhost";

$user="root";

$password="";

$db="loginsystem";

mysql_connect($host, $user, $password);

mysql_select_db($db);

if(isset($_POST['username'])){

$username=$_POST['username'];

$password=$_POST['password'];

$sql="select * from loginform where username='".$username."'AND password='".$password."'limit 1";

$result=mysql_query($sql);

if(mysql_num_rows($result)==1){

// SET 2 SESSION VARIABLES FOR SECURITY

$_SESSION['username'] = true;

$_SESSION['password'] = true;

echo "<h2>You Have Successfully Logged in</h2>";

echo "<h3><a href='secure_page.php'>Enter Here</a></h3>";

}

else{

echo "<h2>You Have Gone Wrong Somewhere?!</h2>";

}

}

?>

<!DOCTYPE html>

<html>

<head>

<meta  charset="UTF-8" />

<title>Login</title>

</head>

<body>

<form method="post" action="login.php" >

<input class="input-group usrpwd" type="text" name="username" placeholder="Username/Email">

<br>

<input class="input-group usrpwd" type="password" name="password" placeholder="Password">

<button class="btn" type="submit" name="submit">Login</button>

</form>

</body>

</html>

Thats just about it. If you follow the instructions above you'll have a simple working login page.

Next create a page named secure_page.php in your project folder as that is where the link in the login script above is pointed if someone successfully logs in:

echo "<h3><a href='secure_page.php'>Enter Here</a></h3>";

Now what you dont want to happen is if someone happens upon secure_page.php is for the information to be shown unless someone is logged in.

At the very start of the sercure_page.php document insert the below code OR on any other page with sensitive information on it. If you browse to any page which has this information it will instantly take you back to the login.php page

<?php

session_start();

if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) {

header('Location: login.php');

}

?>

The above is a simple login approach and you can style it how you like. Please be aware you are using the old deprecated method mysql to perform this task which will still work on any servers which have php version less than 7 installed. Ideally you would want to use the new improved mysqli method and encrypt your passwords but for now I don't want to confuse you.

TOPICS
Dreamweaver | Mac OS issues

Views

745

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 01, 2018 0
LEGEND ,
Jan 01, 2018

Copy link to clipboard

Copied

Not sure if youre the same poster that posted about a similar issue a couple of days ago?

Looking at your code you have no form input with the name - username - so you have zero chance of the php script running as it needs a form input field with the name - username - to be set to excute the script That might not be the issue but it wont help if the php code is incorrect.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 01, 2018 0
New Here ,
Jan 02, 2018

Copy link to clipboard

Copied

Hi there,

I don't quite understand what you mean? It's probably just me I've never done a form before. Could you possibly help me by telling me what to do?

Many Thanks,

Louie

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 02, 2018 0
LEGEND ,
Jan 03, 2018

Copy link to clipboard

Copied

Yes, start by making sure that you have 2 columns in your 'loginform' table named username and password NOT user and pass as you currently have. (I personally hate abbreviated variable names and then other obscure variable names being used to match those. It just make everything so much more difficult, so lets keep it real and you'll  get along much better in my opinion.)

Copy the code below and insert it in a new Dreamweaver document and save it as login.php

<?php

session_start();

$host="localhost";

$user="root";

$password="";

$db="loginsystem";

mysql_connect($host, $user, $password);

mysql_select_db($db);

if(isset($_POST['username'])){

$username=$_POST['username'];

$password=$_POST['password'];

$sql="select * from loginform where username='".$username."'AND password='".$password."'limit 1";

$result=mysql_query($sql);

if(mysql_num_rows($result)==1){

// SET 2 SESSION VARIABLES FOR SECURITY

$_SESSION['username'] = true;

$_SESSION['password'] = true;

echo "<h2>You Have Successfully Logged in</h2>";

echo "<h3><a href='secure_page.php'>Enter Here</a></h3>";

}

else{

echo "<h2>You Have Gone Wrong Somewhere?!</h2>";

}

}

?>

<!DOCTYPE html>

<html>

<head>

<meta  charset="UTF-8" />

<title>Login</title>

</head>

<body>

<form method="post" action="login.php" >

<input class="input-group usrpwd" type="text" name="username" placeholder="Username/Email">

<br>

<input class="input-group usrpwd" type="password" name="password" placeholder="Password">

<button class="btn" type="submit" name="submit">Login</button>

</form>

</body>

</html>

Thats just about it. If you follow the instructions above you'll have a simple working login page.

Next create a page named secure_page.php in your project folder as that is where the link in the login script above is pointed if someone successfully logs in:

echo "<h3><a href='secure_page.php'>Enter Here</a></h3>";

Now what you dont want to happen is if someone happens upon secure_page.php is for the information to be shown unless someone is logged in.

At the very start of the sercure_page.php document insert the below code OR on any other page with sensitive information on it. If you browse to any page which has this information it will instantly take you back to the login.php page

<?php

session_start();

if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) {

header('Location: login.php');

}

?>

The above is a simple login approach and you can style it how you like. Please be aware you are using the old deprecated method mysql to perform this task which will still work on any servers which have php version less than 7 installed. Ideally you would want to use the new improved mysqli method and encrypt your passwords but for now I don't want to confuse you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 03, 2018 0
New Here ,
Jan 07, 2018

Copy link to clipboard

Copied

Hi There,

Sorry to bother again but I pasted the code into dream weaver and this is what I'm getting when I try to view it:

Screen Shot 2018-01-07 at 09.43.46.png

and then if I enter login details it comes back with this;

Screen Shot 2018-01-07 at 09.44.00.png

Sorry, any idea??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2018 0
Adobe Community Professional ,
Jan 07, 2018

Copy link to clipboard

Copied

You will need to give the document containing PHP code an extension of .php

index.html -> index.php


Ben

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2018 1
Adobe Community Professional ,
Jan 07, 2018

Copy link to clipboard

Copied

you have to name the page login.php nor index.html nor index.php

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2018 1
osgood_ LATEST
LEGEND ,
Jan 07, 2018

Copy link to clipboard

Copied

Thanks team Ben/Birnou for stepping in.

OP should read the reply a bit more carefully but l guess it can be confusing if you're struggling along with this stuff.

Os

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2018 0
Adobe Community Professional ,
Jan 01, 2018

Copy link to clipboard

Copied

<I am trying to create a login system so I can give clients logins to log on and access everything they need.>

Have you considered password protecting the client's directory with .htaccess?  Or if your server has a C-Panel you can do it that way.

Nancy

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 01, 2018 0