1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
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 Active Member

    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 Active Member

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

    Vortix Active Member

    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 Active Member

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

    Vortix Active Member

    Right, that helped, thanks.
    Seems that it isn't being recognised as email, but as user.
     
  6. 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 Active Member

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

Previous Readers (Total: 0)