Jump to content

[SOLVED] Unexpected T_CASE


jfarthing

Recommended Posts

I have racked my brain and can't figure why I'm getting a parse error from the following code.

 

  switch($_REQUEST["action"])
  {
    //logout
    case "logout":
    	wp_clearcookie();
      if(get_option("jk_logout_redirect_to"))
        $redirect_to = get_option("jk_logout_redirect_to");
      else
        $redirect_to = "wp-login.php";
    	do_action('wp_logout');
    	nocache_headers();
    
    	if ( isset($_REQUEST['redirect_to']) )
    		$redirect_to = $_REQUEST['redirect_to'];
    	
      wp_redirect($redirect_to);
    	exit();
    break;

    //lost lost password
    case 'lostpassword':
      do_action('lost_password');

	$header_files = get_option("jk_login_header_files");
    	foreach((array)$header_files as $header_file)   	
		include(TEMPLATEPATH . '/' . $header_file);
      
	echo get_option("jk_login_after_head_html");
?>
        <div id="login">
            <h2><?php _e(get_option("jk_login_forgotpw_form_text")); ?></h2>
            <p><?php _e('Please enter your information here. We will send you a new password.'); ?></p>
            <?php if ($error) {echo "<div id='login_error'>$error</div>";} ?>
            
            <form name="lostpass" action="wp-login.php" method="post" id="lostpass">
            <p>
              <input type="hidden" name="action" value="retrievepassword" />
              <label><?php _e('Username:'); ?><br />
              <input type="text" name="user_login" id="user_login" value="" size="20" tabindex="1" /></label>
            </p>
            <p><label><?php _e('E-mail:'); ?><br />
              <input type="text" name="email" id="email" value="" size="25" tabindex="2" /></label><br />
            </p>
            <p class="submit"><input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password'); ?> »" tabindex="3" /></p>
            </form>
            <ul>
            <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?'); ?>">« <?php _e('Home') ?></a></li>
            <?php if (get_settings('users_can_register')) { ?>
            <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register'); ?></a></li>
            <?php } ?>
            <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login'); ?></a></li>
            </ul>
        </div>
<?php
	echo get_option("jk_login_before_foot_html");

	$footer_files = get_option("jk_login_footer_files");
    	foreach((array)$footer_files as $footer_file)   	
		include(TEMPLATEPATH . '/' . $footer_file);

    	die();
break;


    //lost retrieve password
    case 'retrievepassword':
	$header_files = get_option("jk_login_header_files");
    	foreach((array)$header_files as $header_file)   	
		include(TEMPLATEPATH . '/' . $header_file);
      
    	$user_data = get_userdatabylogin($_POST['user_login']);
    	// redefining user_login ensures we return the right case in the email
    	$user_login = $user_data->user_login;
    	$user_email = $user_data->user_email;
    
    	if (!$user_email || $user_email != $_POST['email'])
        {
		echo get_option("jk_login_after_head_html");
        	echo sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.'), 'wp-login.php?action=lostpassword');
    		echo get_option("jk_login_before_foot_html");
    
    		$footer_files = get_option("jk_login_footer_files");
        	foreach((array)$footer_files as $footer_file)   	
    			include(TEMPLATEPATH . '/' . $footer_file);
        		die();
        }
    
      do_action('retreive_password', $user_login);  // Misspelled and deprecated.
      do_action('retrieve_password', $user_login);
    
    	// Generate something random for a password... md5'ing current time with a rand salt
    	$key = substr( md5( uniqid( microtime() ) ), 0, 50);
    	// now insert the new pass md5'd into the db
     	$wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'");
    	$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
    	$message .= get_option('siteurl') . "\r\n\r\n";
    	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    	$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
    	$message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n";
    
    	$m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message);
    
	echo get_option("jk_login_after_head_html");
      echo "          <div id=\"login\">\n";
    	if ($m == false) 
      {
        echo "<h1>There Was a Problem</h1>";
    	  echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
        echo  __('Possible reason: your host may have disabled the mail() function...') . "</p>";
    	} 
      else 
      {
        echo "<h1>Success!</h1>";
    		echo '<p>' .  sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '<br />';
    		echo  "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
    	}
      echo "          </div>\n";
	echo get_option("jk_login_before_foot_html");

	$footer_files = get_option("jk_login_footer_files");
    	foreach((array)$footer_files as $footer_file)   	
		include(TEMPLATEPATH . '/' . $footer_file);

   		die();
    break;

 

It says the error is at the line case 'retrievepassword':

Link to comment
https://forums.phpfreaks.com/topic/89803-solved-unexpected-t_case/
Share on other sites

Quite a few IFs and Loops don't have their {} brackets, which is fine if you just want to run the one line after it.  But go back and make sure you didn't add a } somewhere and the switch is closing.

 

Also, I dont see a } closing the switch at the end.

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.