html - PHP Script won't recognise email -
i'm getting pretty far registration script now. has been such amazing learning curve me. of i've finished bugs user recognition , registration email send outs. i'm having issues recovering password though. @ moment trying email recognised, here html , php:
html
<?php session_start(); ?> <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php include "header.php" ?> <div id="wrapper"> <form method="post" action=""> <h2>recover password</h2> <div id="underline"></div> <ul> <li> <label for="usn">email : </label> <input type="text" maxlength="30" required autofocus name="reset" /> </li> <li class="buttons"> <input type="submit" name="reset" value="reset pass" class="xbutton" /> </li> </ul> </form> </div> </body> </html> <?php include "prec.php" ?> php
<?php if($_post) { if(empty($_post['reset'])) { echo 'please enter fields'; } else { $email = $_post['reset']; $password = $_post['password']; $db_name = $db_user = $db_pass = $conn = new pdo('mysql:host=localhost;dbname=tweezy_php', 'tweezy_php', 'xxxxxx', array( pdo::attr_persistent => true )); $stmt = $conn->prepare("select email users email = ? "); $stmt->execute(array($email)); if($stmt->rowcount() === 1 ) { echo "that email exists"; } else { echo "sorry, email doesn't exsist."; } } } ?> for reason, no matter enter supplied email never recognised. looking through code don't quite see why though. i've tried couple of variations, seems give me same result. i'm thinking has sql query, can't seem quite put finger on it.
any insights wonderful!
your input field is:
<input type="text" maxlength="30" required autofocus name="reset" /> change to:
<input type="text" maxlength="30" required autofocus name="email" /> and, in php, you'd retrieve email user:
$email = $_post['email']; a simple example demonstrate why it's failing:
test.php
<?php if(isset($_post['fieldname'])){ echo $_post['fieldname']; //outputs "submit" instead of user input } ?> <form action="" method="post"> <input type="text" name="fieldname"/> <input type="submit" name="fieldname"> </form> both input field , submit button has same name. when input , click on submit, find instead of echoing user input, echoes text submit. because first input being overridden name attribute in submit button. can resolved changing email input's name attribute different, email makes more sense.
hope helps!
Comments
Post a Comment