Sinisterly
PHP Login - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: PHP (https://sinister.ly/Forum-PHP)
+--- Thread: PHP Login (/Thread-PHP-Login)

Pages: 1 2 3 4 5


RE: PHP Login - Slarek - 11-22-2013

@Geoff
Yeah. You're right. To be honest, i don't even like the way i did it:grin:


RE: PHP Login - Slarek - 11-22-2013

@Geoff
Yeah. You're right. To be honest, i don't even like the way i did it:grin:


RE: PHP Login - hellomen - 11-24-2013

PHP Code:
<?php echo 'Account ID:'; echo '<input type="text" name="user">'; echo 'Password:'; echo '<input type="text" name="pass">'; if(user == 'username' && pass == "password") { echo 'You have successfully logged in' } else { echo 'Incorrect sign in info' } ?>

try:

PHP Code:
<?php echo(' <form method="POST"> Account ID:<br/> <input type="text" name="user"><br/> Password:<br/> <input type="text" name="pass"><br/> <input type="submit" name="submit" id="submit"> </form>'); $user = strip_tags($_POST['user']); $pass = strip_tags($_POST['pass']); $submit = strip_tags($_POST['submit']); if($submit){ if($user == 'username' && $pass == "password") { echo('You have successfully logged in'); } else { echo('Incorrect sign in info'); } } ?>

and to be pro use instead of:
PHP Code:
<input type="text" name="pass"><br/>
this:
PHP Code:
<input type="password" name="pass"><br/>



RE: PHP Login - hellomen - 11-24-2013

PHP Code:
<?php echo 'Account ID:'; echo '<input type="text" name="user">'; echo 'Password:'; echo '<input type="text" name="pass">'; if(user == 'username' && pass == "password") { echo 'You have successfully logged in' } else { echo 'Incorrect sign in info' } ?>

try:

PHP Code:
<?php echo(' <form method="POST"> Account ID:<br/> <input type="text" name="user"><br/> Password:<br/> <input type="text" name="pass"><br/> <input type="submit" name="submit" id="submit"> </form>'); $user = strip_tags($_POST['user']); $pass = strip_tags($_POST['pass']); $submit = strip_tags($_POST['submit']); if($submit){ if($user == 'username' && $pass == "password") { echo('You have successfully logged in'); } else { echo('Incorrect sign in info'); } } ?>

and to be pro use instead of:
PHP Code:
<input type="text" name="pass"><br/>
this:
PHP Code:
<input type="password" name="pass"><br/>



RE: PHP Login - ImMe - 11-26-2013

I thank everyone for the help, but now I realized my flaw. Instead of asking everyone on here for help and wasting there time, I am actually going to learn. Who would've guessed? Any tips are still appreciated of course. :epic:


RE: PHP Login - ImMe - 11-26-2013

I thank everyone for the help, but now I realized my flaw. Instead of asking everyone on here for help and wasting there time, I am actually going to learn. Who would've guessed? Any tips are still appreciated of course. :epic:


RE: PHP Login - hellomen - 11-27-2013

(11-26-2013, 11:47 PM)ImMe Wrote: I thank everyone for the help, but now I realized my flaw. Instead of asking everyone on here for help and wasting there time, I am actually going to learn. Who would've guessed? Any tips are still appreciated of course. :epic:
Well there are 2 different things about time wasting and actually asking

this is asking something you want to know
http://www.hackcommunity.com/Thread-Question-Nexmo-Multi-SMS-sending-script is time wasting


RE: PHP Login - hellomen - 11-27-2013

(11-26-2013, 11:47 PM)ImMe Wrote: I thank everyone for the help, but now I realized my flaw. Instead of asking everyone on here for help and wasting there time, I am actually going to learn. Who would've guessed? Any tips are still appreciated of course. :epic:
Well there are 2 different things about time wasting and actually asking

this is asking something you want to know
http://www.hackcommunity.com/Thread-Question-Nexmo-Multi-SMS-sending-script is time wasting


RE: PHP Login - Crime - 11-30-2013

Maybe I could be of some help.

Firstly, "user" in your case is considered a constant. You *could* do that, but you'd have to define it like this:

Code:
<?php Define('USER', $_POST['user']); // note: the constant doesn't have to be capitalized, but it's good practice. Define('PASS', $_POST['pass']); // same; sessions would be more controlling, and much easier to handle If(IsSet($_POST['submit'])){ If(USER == 'username' && PASS == 'password'){ // Do whatever } ElseIf(!USER == 'username' && PASS == 'password'){ // Incorrect credentials } Else{ // Error / Empty credentials } }

Second, as I mentioned before, sessions are much easier, and safer to work with.

(11-22-2013, 07:22 AM)Geoff Wrote:
(11-22-2013, 05:51 AM)Slarek Wrote:
Code:
if($username == "username" && $password == "password") echo "You have successfully logged in"; else echo "Incorrect sign in info";

Is there a reason you dont use braces? (or formatting?) It should be

Code:
if($username == "username" && $password == "password") { echo "You have successfully logged in"; } else { echo "Incorrect sign in info"; }

Yes, but he'd still need to check for the POST variable, such as in my code. Otherwise, nothing would happen.

(11-21-2013, 04:58 AM)ImMe Wrote:
Code:
<?php echo 'Account ID:'; echo '<input type="text" name="user">'; echo 'Password:'; echo '<input type="text" name="pass">'; if(user == 'username' && pass == "password") { echo 'You have successfully logged in' } else { echo 'Incorrect sign in info' } ?>
------------------------------------------------------------------
I thought this was right but I keep getting an error (specifically on line 9).
If anyone can help please do.
Thanks! :epic:

Just a helpful tip, go to Stack Overflow for a greater understanding of what you're trying to achieve. Don't ask questions unless they're not answered, or don't have the answer you need.

Good luck.


RE: PHP Login - The Real Slim Shady - 11-30-2013

(11-30-2013, 02:14 AM)Crime Wrote: Yes, but he'd still need to check for the POST variable, such as in my code. Otherwise, nothing would happen.

indeed. Had you read the entire thread you would have noticed that I had already pointed this out. The post of mine you decided to quote was specifically directed at @Slarek regarding format/syntax, not functionality.