php - HTML form is no longer posting input data -



php - HTML form is no longer posting input data -

i have 'subscribe' form on website uses ajax validate input fields, form processed via php. actual html code resides on wordpress page. reason, form no longer posts. no info posted myql, , no email sent or received.

a status message on page appears , hangs @ "please wait while process information..." message in part of ajax code, thinking wrong php script? have 'contact' page uses identical code 'subscribe' pages uses validate input fields, , works.

i able recover both ajax , php script before time when did work, uploaded server , nothing, form still not process. made sure database credentials right host, , tested connection mysql , able connect. next, made sure able send mail service host using next script:

<?php mail('subscriptions@3elementsreview.com','test mail','the mail service function working!'); echo 'mail sent!'; ?>

i don't know causing form hang, , love solved; help appreciated!

php code:

class="lang-html prettyprint-override"><?php if ($_server['request_method'] == 'post') { define('db_name', '######'); define('db_user', '######'); define('db_password', '######'); define('db_host', '######'); $first = trim(stripslashes($_post['first'])); $last = trim(stripslashes($_post['last'])); $city = trim(stripslashes($_post['city'])); $state = trim(stripslashes($_post['state'])); $country = trim(stripslashes($_post['country'])); $email = trim(stripslashes($_post['email'])); $tempt = $_post['tempt']; $tempt2 = $_post['tempt2']; if ($tempt == 'http://' && empty($tempt2)) { $error_message = ''; $reg_exp = "/^[a-za-z0-9._%+-]+@[a-za-z0-9­-]+\.[a-za-z.]{2,5}$/"; if(!preg_match($reg_exp, $email)) $error_message .= "<p>a valid email address required.</p>"; if (empty($first)) $error_message .= "<p>please provide first name.</p>"; if (empty($last)) $error_message .= "<p>please provide lastly name.</p>"; if (!empty($error_message)) { $return['error'] = true; $return['msg'] = "<p>the request successful, form not filled out correctly.</p>".$error_message; echo json_encode($return); exit(); $dbc = mysql_connect('######', '######', '######'); $check_email_for_duplicates = mysql_query($dbc, "select * 'members' 'email' = '".mysql_real_escape_string($email)."'"); if(mysql_num_rows($check_email_for_duplicates) > 0) //email address unique within scheme , must not more 1 echo 'sorry, <b>'.$email.'</b> has subscribed.'; } else { $return['error'] = false; $return['msg'] = "<p style='top:12px; color:#ff6000; left:15px; text-align:left; font-size:1.50em;'>".$first .", <p style='top:0px; width:100%; left:15px; text-align:left; line-height:1.1em;'>your subscription request has been processed.</p>"; echo json_encode($return); } } else { $return['error'] = true; $return['msg'] = "<p>there problem while sending form. seek again.</p>"; echo json_encode($return); } $to = "######, ######"; $subject = "new email address mailing list"; $headers = "from: $email\n"; $headers .= "content-type: text/html\r\n"; $message = "<span style='color:#252525; font-size:1.2em;'>a visitor 3elements review has entered next info can added mailing list.</span><br>\n <br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$first $last</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$city, $state</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$country</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$email</span>"; mail($to,$subject,$message,$headers); $user = "$email"; $usersubject = "thank subscribing 3elements review"; $userheaders = "from: ######\n"; $userheaders .= "content-type: text/html\r\n"; $usermessage = "<body style='background-color:#dbf7ff; width:100%; height:105%;'> <span style='color:#353535; font-size:2em; font-weight:bold; font-family:pt sans;'>welcome</span> <span style='color:#ff6000; font-size:2em; font-weight:bold; font-family:pt sans;'>$first</span><span style='color:#353535; font-size:2em; font-weight:bold; font-family:pt sans;'>,</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>we're glad you've decided subscribe our email list. adore people of $city!</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>we have lot of great things in works we're excited @ <em>3elements review,</em> , can't wait show <em>you</em> , of other writers, artists, , photographers immersed in $city literary scene, <strong><em>3elements review</em></strong> has in store!</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>stay tuned info regarding our issue release dates, contests, , other news!<br> <br> if find interesting enough, on facebook , follow on twitter!</span><br> <br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>sincerely,</span><br> <br> <span style='color:#ff6000; font-size:1.50em; font-family:pt sans;'>the 3elements team</span><br> <br> <br> <p> <span style='color:#353535; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <span style='color:#353535; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <span style='color:#ff6000; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <img src='http://www.3elementsreview.com/images/logo-2.svg' width='122px' height='95px'> <br> <p> <span style='color:#353535; font-size:.9em; font-family:noto serif;'>you're receiving email because or know subscribed our email list.</p> <span style='color:#353535; font-size:.9em; font-family:noto serif;'>if rather not receive email 3elements review, can unsubscribe clicking <a href='mailto:######?subject=unsubscribe%20request'>here</a>.</p> <br> <p> </body>"; mail($user,$usersubject,$usermessage,$userheaders); $link = mysql_connect('######', '######', '######'); if (!$link) die('could not connect: ' . mysql_error()); $db_selected = mysql_select_db('######', $link); if (!$db_selected) die('can\'t utilize ' . '######' . ': ' . mysql_error()); $value = mysql_real_escape_string($_post['first']); $value2 = mysql_real_escape_string($_post['last']); $value3 = mysql_real_escape_string($_post['city']); $value4 = mysql_real_escape_string($_post['state']); $value5 = mysql_real_escape_string($_post['country']); $value6 = mysql_real_escape_string($_post['email']); $sql = "insert members (first, last, city, state, country, email, date) values('$value','$value2','$value3','$value4','$value5','$value6',now() + interval 2 hour)"; if (!mysql_query($sql)) die('error: ' . mysql_error()); mysql_close(); } else {} ?>

ajax code:

class="lang-js prettyprint-override">//*************************************************************required field script subscribe page*************************************************// $(document).ready(function() { $('form #response2').hide(); $('.button2').click(function(e) { e.preventdefault(); var valid = ''; var required = ' required'; var first = $('form #first').val(); var lastly = $('form #last').val(); var email = $('form #email').val(); var tempt = $('form #tempt').val(); var tempt2 = $('form #tempt2').val(); if (first = '' || first.length <= 1) valid += '<p>your first name' + required + '</p>'; if (last = '' || last.length <= 1) valid += '<p>your lastly name' + required + '</p>'; if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) valid += '<p>your e-mail address' + required + '</p>'; if (tempt != 'http://') valid += '<p>we can\'t allow spam bots.</p>'; if (tempt2 != '') valid += '<p>a human user' + required + '</p>'; if (valid != '') $('form #response2').removeclass().addclass('error2').html('' +valid).fadein('fast'); else { $('form #response2').removeclass().addclass('processing2').html('<p style="top:0px; left:0px; text-align:center; line-height:1.5em;">please wait while process information...</p>').fadein('fast'); var formdata = $('form').serialize(); submitform(formdata); } }); }); function submitform(formdata) { $.ajax({ type: 'post', url: 'http://3elementsreview.com/blog/wp-content/themes/3elements/php-signup/sign-up-complete.php', data: formdata, datatype: 'json', cache: false, timeout: 4000, success: function(data) { $('form #response2').removeclass().addclass((data.error === true) ? 'error2' : 'success2').html(data.msg).fadein('fast'); if ($('form #response2').hasclass('success2')) settimeout("$('form #response2').fadeout('fast')", 6000); }, error: function(xmlhttprequest, textstatus, errorthrown) { $('form #response2').removeclass().addclass('error2') .html('<p>there <strong>' + errorthrown + '</strong> error due <strong>' + textstatus + '</strong> condition.</p>').fadein('fast'); }, complete: function(xmlhttprequest, status) { $('form')[0].reset(); } }); };

i figured out few days ago, using 'functionsubmitform' in 2 different scripts on site. also, reordered link script in footer , form working again.

php ajax

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -