I have just "graduated" from JS (although there's always more to learn/understand) to learning some PHP, and I have a few questions.
I have a log in form in my index.php page that leads to another password validation page (using another page because that's what I'm used to since I used MySQL a lot back in the day, although this might not be the best way to to it). My question is on the security of the thing. How vulnerable is a script like say:
<?php
$username = "myUsername";
$password = "myPassward";
if ($_POST['user'] != $username || $_POST['pass'] != $password) {
echo ('Invalid username or password <a href="http://mywebsite.org/">click here</a> to return to previous page.'); }
else {
header( 'Location: /securepage.php' );
}
?>
And my second question is the one I really want to know about. I want to grab the IP of people attempting login and email it to me. Right now this is what I have, and it doesn't seem to be working. I have this code on the same page as the above script, placed right before it.
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$sendto = "myemail@yahoo.com";
$subject = "Attempted Login";
$message = "IP address is: $ip";
if ($_POST['submit']) {
mail($sendto, $subject, $message);
}
?>
Any suggestions/help appreciated.



