Have you noticed that you have
name="PIN" in html and
$_POST['pin']
in php? As I know they must be precisely the same(case sensitive).
Question
I am working in WordPress and I have a form that a user submits a pin and then next page populates with their name and nearest store location. I am trying to use that information to populate a second form so that they can add their email for alerts.
Here is the code for page one:
<h1>Enter PIN</h1><form method="post" action="/form2">
<input name="PIN" type="text" size="5" maxlength="8" class="input-lg"> </p>
<input type="submit" name="btn" class="btn-style" value="submit" /></form> <h5> Please enter PIN EXACTLY as it appears on your letter.`:
Here is the second page:
global $wpdb;
$sql = "SELECT * FROM XXX LEFT JOIN XXX ON XXXX.XXX=XXX.XXX WHERE `PIN` LIKE '" . mysql_escape_string($_POST['pin']) . "';";
$posts = $wpdb->get_results($sql);
foreach ($posts as $post)
{
print('Hello');
print(' ');
print(' <strong>'.$post->First.' '.$post->Last.'! ' );
print('</strong> ');
print('<br>');
print('Thank you for your interest. To complete your application, please confirm your email in the boxes below.');
}
<form method="post" action="form_insert.php" data-parsley-validate>
<input type="hidden" name="PIN" value="<?php echo $_POST['PIN']?>"/>
<input type="hidden" name="First" value="<?php echo $_POST['First'] ?>"/>
<input type="hidden" name="Middle" value="<?php echo $_POST['Middle'] ?>"/>
<input type="hidden" name="Last" value="<?php echo $_POST['Last'] ?>"/>
<input type="hidden" name="Title" value="<?php echo $_POST['Title'] ?>"/>
<input type="hidden" name="Address" value="<?php echo $_POST['Address'] ?>"/>
<input type="hidden" name="Address2" value="<?php echo $_POST['Address2'] ?>"/>
<input type="hidden" name="City" value="<?php echo $_POST['City'] ?>"/>
<input type="hidden" name="State" value="<?php echo $_POST['State'] ?>"/>
<input type="hidden" name="Zip" value="<?php echo $_POST['Zip'] ?>"/>
<input type="hidden" name="Location" value="<?php echo $_POST['Location'] ?>"/>
<p><b>Enter Email: </b> <input name="Email" size="26" maxlength="50" data-parsley-type="email" required >
<br>
<b>Confirm Email: </b> <input name="emailconf" size="24" maxlength="50" required data-type="email" >
<input name="Submit" type="submit" value="Submit" ></p>
</form>
All I am getting is empty arrays upon submission to the insert page... I need to carry over the information from the 2 tables and add the email from the form. The email info is submitting to the database. I just need to figure out how to get the other info to the database. As far as injection protection, I just did not include that here
I know I am doing something wrong or forgetting to do something. I am still learning how to code in Wordpress.. Any help would be appreciated.
Thank you in advance
La solution
Have you noticed that you have
name="PIN" in html and
$_POST['pin']
in php? As I know they must be precisely the same(case sensitive).