0

I'm trying to show last entered e-mail characters in input, but I'm getting following error:

Notice: Undefined index: youremail in /home/.../themes/theme_name/lost-password.php on line 42

and these notices are shown in input instead last entered e-mail when I set its value like

value="<?php echo $_SESSION['youremail']; ?>"

This is my session:

if(!isset($_SESSION)) 
    { 
        session_start(); 
    }

This is my input:

<input type="text" size="35" name="youremail" class="input" id="youremail" value="<?php echo $_SESSION['youremail']; ?>" />

my PHP version is 7.0.28

Edit: Whole PHP

<?php 
    if(!isset($_SESSION['youremail'])){
      session_start(); 
}

    require_once dirname( __FILE__ ) . '/form-process.php';  
    $pageURL = 'http';
    //if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    if ( isset( $_SERVER["HTTPS"] ) == "on") {$pageURL .= "s";}
        $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }   

    $action= $pageURL;
?>
<?php get_header(); ?>
<div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
            <h2><?php  _e('Şifrenizi mi Unuttunuz ','qa'); ?> ?</h2>        
        <div class="question-form">
            <form id="get-password" name="get-password" method="post" action="<?php echo $action;?>" enctype="multipart/form-data">
            <input type="hidden" name="action" value="getpassword" />
            <?php wp_nonce_field('get-password'); ?>                
                <div class="err">
                <?php
                if ($error != "") {
                if($error=="null")
                {
                    echo ' <p>'.__('Lütfen yeni şifrenizi almak için gelen maillerinizi kontrol edin!','qa').'</p>'; 
                }
                else
                    echo "<p> HATA: ".$error."</p>";
                }
                ?>
                </div> <!-- /.err -->
                <div class="text-publish2">           
                        <p><?php  _e(' Mail adresiniz','qa'); ?>: </p>                   
                            <input type="text" size="35" name="youremail" class="input" id="youremail" value="<?php echo $_SESSION['youremail']; ?>" />
                </div>   <!-- /.text-publish2 -->
                <div class="btn">               
                <div class="btn_repeat">
                    <input type="submit" name="submit" class="grey" value="<?php  _e(' Şifre Oluştur','qa'); ?>">
                </div>              
                </div>    <!-- /.btn -->                       
            </form>
        </div> <!-- /.question-form -->

        </main><!-- .site-main -->
    </div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
DaF-Student
  • 39
  • 1
  • 7

0 Answers0