如何在刷新页面后记住表单中的输入数据,页面是以链接的形式

时间:2017-08-22 13:16:39

标签: javascript php

来自playingcards-quote.php的代码:

<?php 
            <div class="main">
               <form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
            <div class="container">
                            <div>&nbsp;</div>
            <?php//echo $_SERVER['PHP_SELF'];?>
            <input type='hidden' name='submitted' id='submitted' value='1'/>
            <input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
            <input type ='hidden' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
            <div>
            <span class='error' style="font-size: 12px;"><?php echo $formproc->GetErrorMessage(); ?></span>
            <span class='error' style="font-size: 12px;"><?php echo $validation_errors; ?></span>
            </div>
            <div style="width:800px;">
            <div style="float:left;width:350px;">
              <div class='container'>
                <label for='email' >Plastic Coated Paper :</label><br/>
                <select name='paper' id='paper' value='<?php echo htmlentities($disp_paper) ?>' maxlength="50" onchange="chgSelect('coatedpaper');">
                                      <option selected value="0">Select Paper</option>
                                      <option>Black Centered 330</option>
                                      <option>Black Centered 320</option>
                                      <option>Black Centered 315</option>
                                      <option>Black Centered 305</option>
                                      <option>Black Centered 300</option>
                                      <option>Black Centered 280</option>
                                      <option>White Centered 330</option>
                                      <option>White Centered 320</option>
                                      <option>White Centered 315</option>
                                      <option>White Centered 305</option>
                                      <option>White Centered 300</option>
                                      <option>White Centered 280</option>
                                    </select>
            </div>
        <div class='container'>
            <label for='name' >First Name*: </label><br/>
            <input type='text' name='name' id='name'  maxlength="50" /><br/>
            <span id='contactus_name_errorloc' class='error' style="font-size: 12px;"></span>

        </div>
        <div class='container'>
            <label for='email' >Email Id*:</label><br/>
            <p id="demo">
            <input type='text' name='email' id='email' maxlength="50" /><br/>
            <div id="hello">

        </div>
        </p>
            <span id='contactus_email_errorloc' class='error' style="font-size: 14px;color:#D32626;background-color: #fff;
        font-weight: 800;"></span>
        <script>
        document.getElementById("demo").addEventListener("click", myFunction);

        function myFunction() 
        {
            document.getElementById("hello").innerHTML = "<a href='http://www.alltypesofplayingcards.com/diwakar/customplayingcards/verification.php' target='_blank'>Please click on this link to verify your email address</a>";
        }
        </script>
        <div class='container'>
            <input type='submit' name='Submit' value='Submit' />
            <br>
        </div>
    verification.php
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Custom Playing Cards > Email Verification</title>
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <link href="css/style.css" type="text/css" rel="stylesheet" />
    </head>

    <body>
    <div id="header">
            <h3>Custom Playing Cards > Email Verification</h3>
        </div>
    <div id="wrap">

    <?php

            mysql_connect("localhost", "playingc_diwakar", "P@ssw0rd12345") or die(mysql_error()); // Connect to database server(localhost) with username and password.
    mysql_select_db("playingc_diwakar") or die(mysql_error()); // Select registrations database.

      if(isset($_POST['name']) && !empty($_POST['name']) AND isset($_POST['email']) && !empty($_POST['email'])){
        $name = mysql_escape_string($_POST['name']); // Turn our post into a local variable
        $email = mysql_escape_string($_POST['email']); // Turn our post into a local variable
        if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
       $msg = 'The email you have entered is invalid, please try again.';
    }else{
        // Return Success - Valid Email
        $msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been send to your email.';
    }
    $hash = md5( rand(0,1000) );
    $password = rand(1000,5000);
    $result = mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
    '". mysql_escape_string($name) ."',
    '". mysql_escape_string(md5($password)) ."',
    '". mysql_escape_string($email) ."',
    '". mysql_escape_string($hash) ."') ") or die(mysql_error());
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    $to      = $email; // Send email to our user
    $subject = 'Signup | Verification'; // Give the email a subject
    $message = '

    Thanks for signing up!
    Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.

    ------------------------
    Username: '.$name.'
    Password: '.$password.'
    ------------------------

    Please click this link to activate your account:
    http://www.alltypesofplayingcards.com/diwakar/customplayingcards/playingcards-quote.php?email='.$email.'&hash='.$hash.'

    '; // Our message above including the link

    $headers = 'From:noreply@yourwebsite.com' . "\r\n"; // Set from headers
    mail($to, $subject, $message, $headers); // Send our email
    }

    ?>



            <!-- stop php code -->

            <!-- title and description -->
            <h3>Email Verfication</h3>
            <p>Please enter your name and email addres </p>
            <?php
        if(isset($msg)){  // Check if $msg is not empty
            echo '<div class="statusmsg">'.$msg.'</div>'; // Display our message and wrap it with a div with the class "statusmsg".
        }
    ?>

            <!-- start sign up form -->
            <form action="" method="post">
                <label for="name">Name:</label>
                <input type="text" name="name" value="" />
                <label for="email">Email:</label>
                <input type="text" name="email" value="" />

                <input type="submit" class="submit_button" value="Sign up" />
            </form>
            <!-- end sign up form -->

        </div>
        <!-- end wrap div -->
    </body>
    </html>

我有一个表格playcards-quote.php在这里我有一些下拉项目,名称作为输入和电子邮件.i已进入&#34;黑色中心305&#34;用于下拉和&#34;名称&#34;作为输入文本的xyx,当用户单击电子邮件输入框时,输入电子邮件下方的链接显示,当我点击链接时,新的选项卡打开为verifcation.php,我输入电子邮件和名称并提交,链接然后去到我的Gmail帐号,当我打开我的Gmail帐户打开我的链接页面打开但我不能保持&#34;黑色中心305&#34;和&#34;名称&#34;刷新页面后。

我有一个表格playcards-quote.php在这里我有一些下拉项目,名称作为输入和电子邮件.i已进入&#34;黑色中心305&#34;用于下拉和&#34;名称&#34;作为输入文本的xyx,当用户单击电子邮件输入框时,输入电子邮件下方的链接显示,当我点击链接时,新的选项卡打开为verifcation.php,我输入电子邮件和名称并提交,链接然后去到我的Gmail帐号,当我打开我的Gmail帐户打开我的链接页面打开但我不能保持&#34;黑色中心305&#34;和&#34;名称&#34;刷新页面后。

1 个答案:

答案 0 :(得分:0)

将$ _POST数据存储到您想要的任何键中的$ _SESSION变量中。 示例:$ _SESSION ['contactusForm'] = $ _POST;

并在您想要打印值的地方直接使用变量:

<input type='text' name='name' id='name'  maxlength="50" value="<?php if(isset($_SESSION['contactusForm']['name'])) { echo $_SESSION['contactusForm']['name'];}?>"/><br/>
相关问题