Make WordPress Core


Ignore:
Timestamp:
02/15/2009 12:58:10 PM (17 years ago)
Author:
westi
Message:

Improve the installer when people enter a duff email address. Fixes #5477 props jacobsantos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/install.php

    r9596 r10574  
    4949}//end function display_header();
    5050
     51function display_setup_form( $error = null ) {
     52        if ( ! is_null( $error ) ) {
     53?>
     54<p><strong><?php _e('ERROR'); ?></strong>: <?php echo $error; ?></p>
     55<?php } ?>
     56<form id="setup" method="post" action="install.php?step=2">
     57        <table class="form-table">
     58                <tr>
     59                        <th scope="row"><label for="weblog_title"><?php _e('Blog Title'); ?></label></th>
     60                        <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo ( isset($_POST['weblog_title']) ? $_POST['weblog_title'] : '' ); ?>" /></td>
     61                </tr>
     62                <tr>
     63                        <th scope="row"><label for="admin_email"><?php _e('Your E-mail'); ?></label></th>
     64                        <td><input name="admin_email" type="text" id="admin_email" size="25" value="<?php echo ( isset($_POST['admin_email']) ? $_POST['admin_email'] : '' ); ?>" /><br />
     65                        <?php _e('Double-check your email address before continuing.'); ?>
     66                </tr>
     67                <tr>
     68                        <td colspan="2"><label><input type="checkbox" name="blog_public" value="1"<?php if( isset($_POST) && ! empty($_POST) && isset( $_POST['blog_public'] ) ) : ?> checked="checked"<?php endif; ?> /> <?php _e('Allow my blog to appear in search engines like Google and Technorati.'); ?></label></td>
     69                </tr>
     70        </table>
     71        <p class="step"><input type="submit" name="Submit" value="<?php _e('Install WordPress'); ?>" class="button" /></p>
     72</form>
     73<?php
     74}
     75
    5176// Let's check to make sure WP isn't already installed.
    5277if ( is_blog_installed() ) {display_header(); die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');}
     
    6489<p><?php _e("Please provide the following information.  Don't worry, you can always change these settings later."); ?></p>
    6590
    66 <form id="setup" method="post" action="install.php?step=2">
    67         <table class="form-table">
    68                 <tr>
    69                         <th scope="row"><label for="weblog_title"><?php _e('Blog Title'); ?></label></th>
    70                         <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
    71                 </tr>
    72                 <tr>
    73                         <th scope="row"><label for="admin_email"><?php _e('Your E-mail'); ?></label></th>
    74                         <td><input name="admin_email" type="text" id="admin_email" size="25" /><br />
    75                         <?php _e('Double-check your email address before continuing.'); ?>
    76                 </tr>
    77                 <tr>
    78                         <td colspan="2"><label><input type="checkbox" name="blog_public" value="1" checked="checked" /> <?php _e('Allow my blog to appear in search engines like Google and Technorati.'); ?></label></td>
    79                 </tr>
    80         </table>
    81         <p class="step"><input type="submit" name="Submit" value="<?php _e('Install WordPress'); ?>" class="button" /></p>
    82 </form>
     91
    8392
    8493<?php
     94                display_setup_form();
    8595                break;
    8696        case 2:
     
    94104                $public = isset($_POST['blog_public']) ? (int) $_POST['blog_public'] : 0;
    95105                // check e-mail address
     106                $error = false;
    96107                if (empty($admin_email)) {
    97108                        // TODO: poka-yoke
    98                         die('<p>'.__("<strong>ERROR</strong>: you must provide an e-mail address.").'</p>');
     109                        display_setup_form( __('you must provide an e-mail address.') );
     110                        $error = true;
    99111                } else if (!is_email($admin_email)) {
    100112                        // TODO: poka-yoke
    101                         die('<p>'.__('<strong>ERROR</strong>: that isn&#8217;t a valid e-mail address.  E-mail addresses look like: <code>username@example.com</code>').'</p>');
     113                        display_setup_form( __('that isn&#8217;t a valid e-mail address.  E-mail addresses look like: <code>username@example.com</code>') );
     114                        $error = true;
    102115                }
    103116
    104                 $wpdb->show_errors();
    105                 $result = wp_install($weblog_title, 'admin', $admin_email, $public);
    106                 extract($result, EXTR_SKIP);
     117                if ( $error === false ) {
     118                        $wpdb->show_errors();
     119                        $result = wp_install($weblog_title, 'admin', $admin_email, $public);
     120                        extract($result, EXTR_SKIP);
    107121?>
    108122
     
    126140
    127141<?php
     142                }
    128143                break;
    129144}
Note: See TracChangeset for help on using the changeset viewer.