Jump to content

Code help


elmas156

Recommended Posts

I've been looking at this for 3 hours and I just can't seem to figure out what's wrong... any help would be greatly appreciated.

 

I'm getting the following error with this code:

 

Error:

Parse error: syntax error, unexpected T_ELSE in /home/a9893922/public_html/pwordhelp.php on line 93

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

<div align="center">
  <table width="275" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="275">
  <?php
	include("conf.inc.php"); // Includes the db and form info.
	if (!isset($_POST['submit'])) { // If the form has not been submitted.
	echo "<p>Forgot your password?<br>";
        echo "No problem, what is your email address?</p>";
        echo "<p><form action=\"pwordhelp.php\" method=\"POST\"></p>";
	echo "<input name=\"email\" type=\"text\" id=\"email\" size=\"37\" maxlength=\"50\">";
	echo "<input name=\"submit\" type=\"submit\" value=\"Continue\">";

} else { // The form has been submitted.

$email = form($_POST['email']);

	$q = mysql_query("SELECT * FROM `users` WHERE email = '$email'") or die (mysql_error()); // mySQL Query
	$r = mysql_num_rows($q); // Checks to see if anything is in the db.

	if ($r > 0) { // If there are users with the same email.

	$result = mysql_query("SELECT fname,question,pword FROM users WHERE email = '$email'");

	$row = mysql_fetch_row($result);

	if (!isset($_POST['getpword'])) { // If "getpword" has not been submitted.
	echo $row[1];
	echo "<p><form action=\"pwordhelp.php\" method=\"POST\"></p>";
	echo "<input name=\"answer\" type=\"text\" id=\"answer\" size=\"37\" maxlength=\"50\">";
	echo "<input name=\"getpword\" type=\"submit\" value=\"Get my password.\">";

} else { // If "getpword" has been submitted

$answer = form($_POST['answer']);

	$a = mysql_query("SELECT answer FROM `users` WHERE email = '$email'") or die (mysql_error()); // mySQL Query
	$c = mysql_num_rows($q); // gets answer from database

	if ($c == $answer) { // if entered answer matches the one in database.
$fname = "$row[0]";
$pword = "$row[2]";		
$to = "$email";

$subject = "Alleyway Oil & Lube Password.";

$message = "<html>
<body>
<img src=\"http://www.dfwbounce.com/Logo1.gif\">
<br>
Hello $fname,<p>
Your login information is listed below.</p>
Email Address/User ID: $email<br>
Password: $pword<br> <br>
<a href=\"http://www.alleywayoil.com\">Click Here to Login to Alleyway Oil $ Lube</a> 
</body>
</html>";

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers

$headers .= 'From: Alleyway Oil & Lube <[email protected]>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

	echo "Thank you, your password has been emailed to you.";

} else {  //if answer is not right

	echo $row[1];
	echo "<font color=\"#FF0000\">That is not the answer you provided<br>";
	echo "when you signed up. Please try again.</font>";
	echo "<p><form action=\"pwordhelp.php\" method=\"POST\"></p>";
	echo "<input name=\"answer\" type=\"text\" id=\"answer\" size=\"37\" maxlength=\"50\">";
	echo "<input name=\"getpword\" type=\"submit\" value=\"Get my password.\">";

}
}
}
} else { //if email is not in database... THIS IS LINE 93

	echo "<p><font color=\"#FF0000\">That email has not been registered.<br>";
        echo "Please enter another email address or</font>";
	echo "<a href=\"signup.php\">Click Here to Sign Up.</a></p>";
        echo "<p><form action=\"pwordhelp.php\" method=\"POST\"></p>";
	echo "<input name=\"email\" type=\"text\" id=\"email\" size=\"37\" maxlength=\"50\">";
	echo "<input name=\"submit\" type=\"submit\" value=\"Continue\">";
}
	?>
        <p>
  

	</p></td>
    </tr>
  </table>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/121186-code-help/
Share on other sites

The main problem I see for now is the fact that you have too many "else" clauses. You can't do that. You either have:

 

<?php

if(1 == 1){

   echo "True";

} else {

   echo "False";

} ?>

 

In your case, it is not that case, you have:

 

<?php

if(1 == 1){

   echo "True";

} else {

   echo "False";

} else {

   echo "False";

}

?>

 

What you need to do in that case is either use the Switch statement or use the "elseif" clause:

 

<?php

$number = $_POST['value'];

if($number == 1){

   echo "Number is 1";

} elseif($number == 2) {

   echo "Number is 2";

} elseif ($number == 3){

   echo "Number is 3";

} else {

   echo "Number is invalid!";

}

?>

 

Again, that's what I saw at a quick glance, so even if that fixes your problem, you may get other problems.

 

On another note, you should consider organizing your code more. I tried to look at it for you on Dreamweaver, but everything is flying around everywhere. It may be a good to comment where your blocks start and end, as well as using other indenting methods.

Link to comment
https://forums.phpfreaks.com/topic/121186-code-help/#findComment-624719
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.