<?php
include 'core/init.php';
include 'includes/overall/indexOver.php';
if (empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) === true || empty($password) === true) {
$errors = 'you need to enter username or password';
} else if(user_exists($username) === false){
$errors= 'We can\'t find the username. Have you registered?';
} else if(user_active($username)=== false) {
$errors = 'please activate your account';
}else{
$login = login($username, $password);
if($login === false){
$errors[] = 'your username or password is incorrect';
}else{
$_SESSION['id'] = $login;
header('Location: main1.php');
exit();
}
}
print_r($errors);
}
?>
alert box in php
Page 1 of 110 Replies - 418 Views - Last Post: 09 October 2012 - 10:23 PM
#1
alert box in php
Posted 09 October 2012 - 06:19 AM
Hello I just want to know how to change this to a alert box
Replies To: alert box in php
#2
Re: alert box in php
Posted 09 October 2012 - 06:38 AM
if you mean something like Javascript’s window.alert() then there is bad news, there is no such thing in PHP.
however you could print out some Javascript code that does exactly that.
however you could print out some Javascript code that does exactly that.
#3
Re: alert box in php
Posted 09 October 2012 - 06:40 AM
You could use the Twitter Bootstrap alert, & feed it server side messages in php. However the act of opening an alert box (styled or not) is going to be handled by the browser, which is a client side execution & not server side. Thus to 2nd what Dormilich said, php isn't the tool for this.
#4
Re: alert box in php
Posted 09 October 2012 - 06:57 AM
@Dormilich- is that so can you help how to do that
#5
Re: alert box in php
Posted 09 October 2012 - 07:13 AM
I can aid in the process, but I’m certainly not writing it for you (which would be a major rewrite anyways).
#6
Re: alert box in php
Posted 09 October 2012 - 07:24 AM
so you mean I need to change all of this just to put the alert box that I wanted
well anyway that's cool for me
well anyway that's cool for me
#7
Re: alert box in php
Posted 09 October 2012 - 07:25 AM
first you need to decide the output format of it all. currently you have text (output) disguised as HTML (default response header) ...
#8
Re: alert box in php
Posted 09 October 2012 - 08:08 AM
Yo I got it
<?php
include 'core/init.php';
include 'includes/overall/indexOver.php';
if (empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) === true || empty($password) === true) {
//$errors = 'you need to enter username or password';
echo "<script>alert(\"you need to enter username or password!\");</script>";
} else if(user_exists($username) === false){
//$errors= 'We can\'t find the username. Have you registered?';
echo "<script>alert(\"We can\'t find the username. Have you registered?\");</script>";
} else if(user_active($username)=== false) {
$errors = 'please activate your account';
}else{
$login = login($username, $password);
if($login === false){
//$errors[] = 'your username or password is incorrect';
echo "<script>alert(\"your username or password is incorrect?\");</script>";
}else{
$_SESSION['id'] = $login;
header('Location: main1.php');
exit();
}
}
//print_r($errors);
}
?>
#9
Re: alert box in php
Posted 09 October 2012 - 10:05 AM
four comments.
- you are aware that this output is nowhere close to a proper HTML document?
- it does not work with Javascript disabled.
- why use header() when you can use include()?
- telling the user that his password resp. login is wrong gives attackers more information than is good for you1). better tell the user that the password-login combination (but not which one) is wrong.
1) if an attacker gains a valid password, finding the appropriate username is only a matter of time.
- you are aware that this output is nowhere close to a proper HTML document?
- it does not work with Javascript disabled.
- why use header() when you can use include()?
- telling the user that his password resp. login is wrong gives attackers more information than is good for you1). better tell the user that the password-login combination (but not which one) is wrong.
1) if an attacker gains a valid password, finding the appropriate username is only a matter of time.
#10
Re: alert box in php
Posted 09 October 2012 - 07:43 PM
We're only needing this for our project this will not go online
#11
Re: alert box in php
Posted 09 October 2012 - 10:23 PM
that doesn’t matter. a project is there to train you for the real thing. and if you only ever made projects where security and efficiency didn’t matter, I can bet that the real life project then has more security holes than you can count.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|