0

Code from 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>

I have a form playingcards-quote.php in this i have some dropdown item ,name as input and email .i have entered "Black Centered 305" for dropdown and "name" as xyx for input text, when the user click the email input box a link display below the input email and when i click on the link a new tab open as verifcation.php there i enter email and name and submit it ,the link then goes to my gmail id and when i open my gmail account to open my link the page open but i m not abe to keep the data of "Black Centered 305" and "name" after refresh page .

I have a form playingcards-quote.php in this i have some dropdown item ,name as input and email .i have entered "Black Centered 305" for dropdown and "name" as xyx for input text, when the user click the email input box a link display below the input email and when i click on the link a new tab open as verifcation.php there i enter email and name and submit it ,the link then goes to my gmail id and when i open my gmail account to open my link the page open but i m not abe to keep the data of "Black Centered 305" and "name" after refresh page .

David Dutra
  • 391
  • 7
  • 21
  • 3
    Tip #1: This is redundant: `isset($_POST['name']) && !empty($_POST['name'])` - and can be replaced with simply `if ( ! empty( $_POST[ 'name' ] ) ) {` – random_user_name Aug 22 '17 at 13:20
  • cale_b are you sure ? please read my question carefully and then answer –  Aug 22 '17 at 13:25
  • 1
    Welcome to StackOverflow. This question has too much code, please refer to [how to create a minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) – random_user_name Aug 22 '17 at 13:25
  • 2
    Neetu - yes, I'm sure. And please don't tell me what to do. – random_user_name Aug 22 '17 at 13:25
  • 1
    Store the data in an array session $_SESSION['data][] – Mr Pro Pop Aug 22 '17 at 13:29
  • 2
    Tip#2: This is a horrible code design. Think about separating logic from layout...use a DB wrapper...don't use mysql* functions cause deprecated... – B001ᛦ Aug 22 '17 at 13:29
  • 2
    [SQL Injection vulnerability](https://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) – ctwheels Aug 22 '17 at 13:35
  • @MrProPop in which file i have used $_SESSION['data'][] ? –  Aug 22 '17 at 13:38
  • @NeetuYadav MrProPop is suggesting that you do this, not saying that you already do. And please don't write new code using the `mysql_` API, it was deprecated years ago due to security issues and removed entirely in PHP7. Use mysqli or PDO instead. Then you can also use parameterised queries to protect from SQL Injection attacks which could steal data or corrupt your database based on malicious user input. Not sure who suggested you to use this library but they need to update their information urgently. – ADyson Aug 22 '17 at 13:56

1 Answers1

0

Store your $_POST data into the $_SESSION variable in any key which is you want. Example: $_SESSION['contactusForm'] = $_POST;

And use variable directly where you want to print value like that:

<input type='text' name='name' id='name'  maxlength="50" value="<?php if(isset($_SESSION['contactusForm']['name'])) { echo $_SESSION['contactusForm']['name'];}?>"/><br/>
  • 1
    Welcome to Stack Overflow. Please do not answer questions like this. The question is a bit of a mess, plus this is almost certainly a duplicate of https://stackoverflow.com/questions/7014146/how-to-remember-input-data-in-the-forms-even-after-refresh-page?rq=1 - we want to encourage high quality questions. I'd suggest reading https://stackoverflow.com/help/how-to-answer , especially the section titled "Answer Well Asked Questions" – random_user_name Aug 22 '17 at 14:11