minneapolis Posted April 16, 2006 Share Posted April 16, 2006 i am trying to add a change password function to a project and i am getting an error. Could somebody take a look at the following code:[code]<?php //this page lets the a user change their password//check if the form has been submittedif (isset($_POST['submitted'])) { //connect to the DB $dbcn = new mysqli ("localhost","ics325sp0604", "13855", "ics325sp0604" ); if(mysqli_connect_errno()) { echo "<p>Error creating database connection: </p>"; exit; } //create a function for escaping the data function escape_data($data) { global $dbcn; if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } return mysqli_real_escape_string(trim($data), $dbcn); } $errors = array();//check for an email addressif (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email address';} else { $e = escape_data($_POST['email']);}//check for an existing passwordif (empty($_POST['password'])) { $errors[] = 'You forgot to enter your existing password';} else { $p = escape_data($_POST['password']);}if (empty($errors)) { //check that they have entered the right email password $query = "SELECT username FROM user_info WHERE (email = '$e' AND password=SHA('$p'))"; $result = $dbcn->query($query); if (mysqli_num_rows($result) == 1) { //get the username $row = mysqli_fetch_array($result, MYSQLI_NUM); $query = "UPDATE user_info SET password=SHA('$np') WHERE username=$row[0]"; $result = $dbcn->query($query); if (mysqli_affected_rows() == 1) { echo 'Thank You! Your password has been updated'; } else { echo 'Your password has not been changed'; }}}?><html><head><title> Password form</title></head><body><h2>change your password</h2> <form action="password.php" method = "post"> <p>Email address: <input type ="text" name="email" size="20" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST ['email']; ?> /> </p> <p>Current Password: <input type ="password" name="password" size="10" maxlength="20" /> </p> <p>New Password: <input type ="password" name="password" size="10" maxlength="20" /> </p> <p>Confirm New Password: <input type ="password" name="password" size="10" maxlength="20" /> </p> <p><input type="submit" name="submit" value="Change My Password" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form></body><html> [/code]The error is the following:Parse error: parse error, unexpected $ in /home/students/ics325sp06/ics325sp0604/public_html/project4/password.php on line 123 Quote Link to comment https://forums.phpfreaks.com/topic/7532-change-paswword-function/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.