1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Undefined index - PHP (Help please?)

Discussion in 'Help' started by Vortix, Aug 29, 2014.

  1. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    So, I tried this:
    PHP:
    <form name "form1" method "post" action="checklogin.php">
        <
    input type="text" name="email" placeholder="Email">
        <
    input type="password" name="pass" placeholder="Password">
        <
    input type="submit" name="login" class="login login-submit" value="login">
      </
    form>
    Just making a simple login form, then in checklogin.php I try this:
    PHP:
    $email=$_POST['email']; 
    $pass=$_POST['pass'];
    There is no problem with pass, however for email I get the error:
    Notice: Undefined index: mail in C:\wamp\www\mailservice\checklogin.php on line 13
    $email=$_POST['email']; is the piece of code on line 13.
    Any help?
     
  2. trurascalz

    trurascalz C16 Developer Legend

    Undefined index: mail your calling mail as a variable somewhere
     
  3. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Sorry, I tested it by changing it to mail instead of mail at one point, the copy paste was from when I did that.
    Refreshing the page it is now email, same error though.
     
  4. trurascalz

    trurascalz C16 Developer Legend

    well put
    Code:
    print_r($_POST);
    
    to see whats being sent.
     
  5. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Right, that helped, thanks.
    Seems that it isn't being recognised as email, but as user.
     
  6. alexanderk

    alexanderk a Legend

    Validate and sanitize your $_POST input should be a thing to consider.

    $email = (isset($_POST['email']) ? $_POST['email'] : false);

    Then you can successfully do stuff like if($email) {} without it crying out errors everywhere. Sanitization depends on what you use for storage or whatever. htmlspecialchars() is a thing you should use, too.

    Good luck. :)
     
  7. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Thanks for the replies, after a bit it adjusted and it works, no errors.
    Thanks for all your help.
     

Previous Readers (Total: 0)