Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

I need some help, for some reason only the SELECT form type has a problem when I process the form twice. All the other variables continue to appear no matter how many times I process the form except for the SELECT types. I can process the form once and it stays, but twice and it's gone.

 

Please check out the code and let me know what you think:

 

*The variable is month1

 

if (!isset($_POST['month1'])) $_POST['month1'] = '';

// function to output form and hold previously entered values.
function user_form() {

// now to output the form HTML.
echo ('
<form method="post" action="'.htmlspecialchars($_SERVER['PHP_SELF']).'">');
if (!$_POST['month1']){
echo ('
 <select name="month1"><option value="">[Select One]<option value="January">January<option value="February">February<option value="March">March<option value="April">April<option value="May">May<option value="June">June<option value="July">July<option value="August">August<option value="September">September<option value="October">October<option value="November">November<option value="December">December</select> 
');}else{
echo htmlspecialchars($month1);
} 
');
}

// has the form been submitted?
if (isset($_POST['submit'])) {
   // the form has been submitted
   // perform data checks.
//POST Contract Variables
$month1 = $_POST['month1'];

//Strip Slashes from Contract Variables
$month1 = stripslashes(month1);

}
               //Error checking here
                              // Show the form again!
 user_form();
 exit(); // if the error checking has failed, we'll exit the script!
}
}else {
   // the form has not been submitted, let's show it
   user_form();
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...