You are viewing our Forum Archives. To view or take place in current topics click here.
Anyone here decent at PHP?
Posted:
Anyone here decent at PHP?Posted:
Status: Offline
Joined: Jan 25, 20168Year Member
Posts: 119
Reputation Power: 12
So I have an issue with this think I downloaded and it uses php. So basically you have to sign in using a login but theres no login provided, so I was wondering if there was a way to make it check if the username is like admin and password is password?
If that makes any sense.
Thanks
If that makes any sense.
Thanks
#2. Posted:
Status: Offline
Joined: Oct 09, 201014Year Member
Posts: 2,358
Reputation Power: 106
Status: Offline
Joined: Oct 09, 201014Year Member
Posts: 2,358
Reputation Power: 106
If youre trying to use something like phpmyadmin it would be "root" for username and blank for pass until you change it/add your account.
Let us know what thing you are using and we can help
Let us know what thing you are using and we can help
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Jan 25, 20168Year Member
Posts: 119
Reputation Power: 12
Its not like that its a control panel for this thing and it uses a mysql data based which I have access to and the php file that runs the code.
So i was wondering if I can edit that code so it doesn't go to the database it just looks for it in the file e.g
if $username = "admin"
then bla bla
I can also provide the code via pm
So i was wondering if I can edit that code so it doesn't go to the database it just looks for it in the file e.g
if $username = "admin"
then bla bla
I can also provide the code via pm
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: May 16, 20177Year Member
Posts: 232
Reputation Power: 72
Status: Offline
Joined: May 16, 20177Year Member
Posts: 232
Reputation Power: 72
Yeah, here's an example..
<?php
// Start a session
session_start();
// Correct details to login
$usernameCorrect = "admin";
$passwordCorrect = "admin123";
// Check on submission
if(isset($_POST['submit'])) {
// Make it simpler on us for later use
// It'd be smart to clean the input, but since I don't know
// if you're using MySQL or PDO, or MySQLi I'll let you do that
$usernameInput = $_POST['username'];
$passwordInput = $_POST['password'];
// Check if matches what we want
if($usernameInput != $usernameCorrect) {
// It matches so do whatever with it
} else {
// It does not match so maybe show them an error
}
}
?>
<form method="post">
<input name="username" type="text" placeholder="Username..">
<input name="password" type="text" placeholder="Password..">
<input name="submit" type="button" value="Submit">
</form>
- 2useful
- 0not useful
#5. Posted:
Status: Offline
Joined: May 16, 20177Year Member
Posts: 232
Reputation Power: 72
Status: Offline
Joined: May 16, 20177Year Member
Posts: 232
Reputation Power: 72
Noticed I goofed up on my last post..
Forgot to check if the password was right.. Oops!
<?php
// Start a session
session_start();
// Correct details to login
$usernameCorrect = "admin";
$passwordCorrect = "admin123";
// Check on submission
if(isset($_POST['submit'])) {
// Make it simpler on us for later use
// It'd be smart to clean the input, but since I don't know
// if you're using MySQL or PDO, or MySQLi I'll let you do that
$usernameInput = $_POST['username'];
$passwordInput = $_POST['password'];
// Check if matches what we want
if($usernameInput != $usernameCorrect || $passwordInput != $passwordCorrect) {
// It matches so do whatever with it
} else {
// It does not match so maybe show them an error
}
}
?>
<form method="post">
<input name="username" type="text" placeholder="Username..">
<input name="password" type="text" placeholder="Password..">
<input name="submit" type="button" value="Submit">
</form>
Forgot to check if the password was right.. Oops!
- 0useful
- 0not useful
#6. Posted:
Status: Offline
Joined: Dec 30, 201211Year Member
Posts: 3,778
Reputation Power: 3016
#7. Posted:
Status: Offline
Joined: Aug 19, 201014Year Member
Posts: 5,243
Reputation Power: 532
Status: Offline
Joined: Aug 19, 201014Year Member
Posts: 5,243
Reputation Power: 532
Ryzen wrote Noticed I goofed up on my last post..
<?php
// Start a session
session_start();
// Correct details to login
$usernameCorrect = "admin";
$passwordCorrect = "admin123";
// Check on submission
if(isset($_POST['submit'])) {
// Make it simpler on us for later use
// It'd be smart to clean the input, but since I don't know
// if you're using MySQL or PDO, or MySQLi I'll let you do that
$usernameInput = $_POST['username'];
$passwordInput = $_POST['password'];
// Check if matches what we want
if($usernameInput != $usernameCorrect || $passwordInput != $passwordCorrect) {
// It matches so do whatever with it
} else {
// It does not match so maybe show them an error
}
}
?>
<form method="post">
<input name="username" type="text" placeholder="Username..">
<input name="password" type="text" placeholder="Password..">
<input name="submit" type="button" value="Submit">
</form>
Forgot to check if the password was right.. Oops!
You dun goofed again.
Should be like this
if($usernameInput == $usernameCorrect && $passwordInput == $passwordCorrect) {
You need to have == instead of != for your logic. Also, using " || " is a boolean OR, you need to use &&.
(Or you would just need to swap round your 'Correct' code block with the 'Incorrect' code block.
You aren't actually using the session variable so there's no need to update your session.
- 1useful
- 0not useful
#8. Posted:
Status: Offline
Joined: May 16, 20177Year Member
Posts: 232
Reputation Power: 72
Status: Offline
Joined: May 16, 20177Year Member
Posts: 232
Reputation Power: 72
Eh, my bad again. It works fine I just had my comments in the wrong spot. The first bit should return the error to the user and the second should do whatever with it lol.
<?php
// Start a session
session_start();
// Correct details to login
$usernameCorrect = "admin";
$passwordCorrect = "admin123";
// Check on submission
if(isset($_POST['submit'])) {
// Make it simpler on us for later use
// It'd be smart to clean the input, but since I don't know
// if you're using MySQL or PDO, or MySQLi I'll let you do that
$usernameInput = $_POST['username'];
$passwordInput = $_POST['password'];
// Check if matches what we want
if($usernameInput != $usernameCorrect || $passwordInput != $passwordCorrect) {
// It does not match
} else {
// It does match
}
}
?>
<form method="post">
<input name="username" type="text" placeholder="Username..">
<input name="password" type="text" placeholder="Password..">
<input name="submit" type="button" value="Submit">
</form>
- 0useful
- 0not useful
#9. Posted:
Status: Offline
Joined: Jan 25, 20168Year Member
Posts: 119
Reputation Power: 12
Forgot to post this but i found a way around it, thanks for the help tho guys!
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.