Basic php question

JakReloaded

New Member
My real question was why does the JSON fire when the page loads? I only want this to go off when the 'submit' button is pressed.\[code\]if (isset($_POST['submit'])) // if page is not submitted to itself echo the form{ if(!$valid_zip){$error_str .= "The zip code you enter must be in the form of '99999' or '99999-9999'\n";}if(!$valid_phone){$error_str .= "Please enter a 10-digit phone number: '999-999-9999'\n";}if(!$valid_mobile){$error_str .= "Please enter a 10-digit phone number: '999-999-9999'\n";}if(!$valid_contrib){$error_str .= "Please enter a valid dollar amount: '0.00'\n";}if(!$valid_email){$error_str .= "Please enter a valid email address: '[email protected]'\n";}if(!$valid_conf) {$error_str .= "Email fields do not match\n";}?> <!-- <p><strong>Error: Please Select At Least One List to Sign Up For</strong></p> --> <script>var error = <?= json_encode($error_str);?>; alert(error); </script> <?}\[/code\]
 
Back
Top