Jump to content

Search the Community

Showing results for tags 'submit'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 24 results

  1. I have a file in js structured like this: if ( window.history.replaceState ) { window.history.replaceState( null, null, window.location.href ); } the function blocks the submit request if it has already been executed if you want to reload the page. on desktop devices it works while from my smartphone no. have any idea why? Thanks
  2. Typically when you submit a form, it's in a format like this "collections?type='wheels'&make='acura'&year='2016'&model='mdx' ". Instead of that format, I would like to do something like this " collections/wheels/acura+2016+mdx ". How would I go on about doing that format with jquery submit form? This is my setup so far. <script> // Code goes here $(document).ready(function() { $('#search').on('submit', function() { var type = $('#type').val(); var make = $('#make').val(); var year = $('#year').val(); var model = $('#model').val(); var formAction = $('#search-form').attr('action'); $('#search-form').attr('action', formAction + type + make + year + model); }); </script> <form id="search-form" action="/collections/" method="get"> <select id="type" name="type"> // type list goes here </select> <select id="make" name="make"> // make list goes here </select> <select id="year" name="year"> // year list goes here </select> <select id="model" name="model"> // model list goes here </select> <input type="submit" id="search" value="Search"> </form>
  3. Hi guys. I have a Bootstrap modal that opens on click. Inside is a form with 4 fields. Now i want after the form is submited to show below the submit button a thank yo message, but instead of that the form closes and the page is beeing refreshed. I've manage to do some javascript to stop the form of beeing refreshed but now i want to know how can i make the thank you div to get showed below the submit button. <script> $(function () { var frm = $('#participa-modal'); frm.submit(function (ev) { $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { $(".alert-success").html(data); location.reload(); } }); ev.preventDefault(); }); }); </script>
  4. I need new pair of eyes to look at this and tell me what's wrong with it. All I am trying to do is have a simple form that submits data to database. It works without the "token". With the token code added, it won't let process. I even did var_dump and the session and the $_post code doesn't match. Here's the code. Btw, session_start() and the database connection are in the init.php file. <?php require_once 'init.php'; $token = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM); $_SESSION['token'] = $token; if(isset($_POST['register'], $_POST['token'])) { if($_POST['token'] === $_SESSION['token']) { $email = trim($_POST['email']); $password = trim($_POST['password']); if(empty($email)) { $error = 'Email is required!'; } else if(empty($password)) { $error = 'Password is required!'; } else if(strlen($password) < 6) { $error = 'Password must be at least 6 characters long!'; } else { $findUser = $db->prepare("SELECT email FROM users WHERE email = :email"); $findUser->bindParam(':email', $email); $findUser->execute(); $resultFind = $findUser->fetchAll(PDO::FETCH_ASSOC); if(count($resultFind) > 0) { $error = 'The email already exists! Please try a different email!'; } else { //Hash the password as we do NOT want to store our passwords in plain text. $passwordHash = password_hash($passward, PASSWORD_BCRYPT, array("cost" => 12)); $insertUser = $db->prepare("INSERT INTO users(email, password) VALUES(:email, :password)"); $insertUser->bindParam(':email', $email); $insertUser->bindParam(':password', $passwordHash); $resultInsert = $insertUser->execute(); if($resultInsert == false) { $error = 'There was a problem creating your account. Please try again later!'; } else { $success = 'Your account has been created.'; unset($_SESSION['token']); } } } } else { $error = 'The tokens do not match!'; } } ?> <h1>Sign up</h1> <form action="" method="post"> <fieldset> <input type="email" name="email" value="<?php echo $email; ?>" placeholder="Email" /> </fieldset> <fieldset> <input type="password" name="password" placeholder="Password" /> </fieldset> <fieldset> <input type="hidden" name="token" value="<?php echo $token; ?>" /> <input type="submit" name="register" value="Sign up" /> </fieldset> </form>
  5. i just downloaded this software interspire email marketer to send email campaigns but in the process of sending out email i get to a page where i select the email list i want the email campaign to go to out to. but after i make this selection and click the "Next"button nothig happens. i just click on the button but it doesnt lead to the next page at all. it just remains in the same page. this is very frustrating so i did some research and did a "View Page Source"on mozilla and i found this in the code for that button: <input class="FormButton SubmitButton" type="button" value="Next >>" /> <input class="FormButton CancelButton" type="button" value="Cancel" /> i'm a noob so i looked up the internet and saw that the code here should look more like this below for the button to function like it should: <input class="FormButton SubmitButton" type="submit" value="Next >>" /> <input class="FormButton CancelButton" type="button" value="Cancel" /> my issue however came when i tried to correct this on the webpage code. i downloaded a php editor but it could not locate the page for editing....the page is: http://naudeyfire.atwebpages.com/marketing/admin/index.php?Page=Send but the phpeditor does not locate this page...i do not see it when using ftp ...i only see http://naudeyfire.atwebpages.com/marketing/admin/index.php so my question is two-fold: 1) is it true that changing that code from "button"to "submit" will enable me to proceed to the next page that the button is supposed to link to? 2) how do i find this exact page in order to correct and update it on the server? thank you very much ...
  6. Hi guys I would like to get whole content of html file after I submitted a password. The problem is that the my code doesn't access the value for the file. I tried to create a session but i doesn't work. What other option do I have to get the content of the html file? session_start(); $selected_file = $_POST['radio1']; // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; $password = 'code'; $lines = file("$filename.html"); $_SESSION['selectedfile'] = $selected_file; $_SESSION['file'] = $filename; $_SESSION['Scipt'] = ("$filename.html"); $_SESSION['Scipttext'] = $lines; $_SESSION['file2'] = $fileinfo; if (isset($_POST['submitradio'])) { echo '<div class="imageselected">'; echo '<img src="'.$_SESSION['selectedfile'].'" /></br>'.PHP_EOL; echo '</div>'; // check to see if a html file named the same also exists if(file_exists($_SESSION['Scipt'])) { echo "<form action='test_result.php' method='post'>"; echo '<div class="Password">'; echo 'Type in password to view full Script'; echo "<label><div class=\"Input\"><input type='password' name='passIT' value='passit'/></div>"; echo "<input type='submit' name='submitPasswordIT' value='Submit Password'/></div>"; echo '</div>'; echo "$filename.html shares the same name as $selected_file"; for($x = 1;$x<=15;$x++) { header( "Content-Type: file/html" ); $lines = ($_SESSION['Scipttext']); $new = strip_tags($lines); echo $lines[rand(0, count($lines)-1)]."<br>"; } // end of forloop } // end of check // start Sorrytext else { echo '<div class="NoScript">'; echo "Nothing available at the moment."; echo '</div>'; } // end Sorrytext } // End of submitradio if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ echo "You entered correct password"; readfile($_SESSION['Scipt']); } else{ echo "You entered wrong password"; } } echo '</form>'; I would be grateful for help.
  7. I am trying to create a page for customers to enter their details. I am using a html form. When the submit button is pressed the form posts the inputs to the same page, which then checks if the inputs are empty. If they are not then each post variable is allocated a session variable so this info can be accessed late on in the system. If some of the inputs are empty then the value of the input forms become equal to the session variables that they were just allocated to so that the customer doesn’t have to retype their information. This is where the problem occurs. When I load the page each input box has a slash inside it and when the submit button is pressed a mother slash is added. My code is below: <?php session_start(); if(isset($_POST['NextPage'])){ if (!empty($_POST['CName'])){ $_SESSION["CName"] = $_POST['CName']; if (!empty($_POST['CStreet'])){ $_SESSION["CStreet"] = $_POST['CStreet']; if (!empty($_POST['CTown'])){ $_SESSION["CTown"] = $_POST['CTown']; if ($_POST['Counties'] != "-"){ $_SESSION["CCounty"] = $_POST['Counties']; if (!empty($_POST['CPostcode'])){ $_SESSION["CPostcode"] = $_POST['CPostcode']; if (!empty($_POST['CEmail'])){ $_SESSION["CEmail"] = $_POST['CEmail']; if (!empty($_POST['CNumb'])){ $_SESSION["CNumb"] = $_POST['CNumb']; $NotEmpty = true; }else{ $ErrorMsg = "Number is empty. </br>"; } }else{ $ErrorMsg = "Email is empty. </br>"; } }else{ $ErrorMsg = "Postcode is empty. </br>"; } }else{ $ErrorMsg = "County is empty. </br>"; } }else{ $ErrorMsg = "Town is empty. </br>"; } }else{ $ErrorMsg = "Street is empty. </br>"; } }else{ $ErrorMsg = "Name is empty. </br>"; } } $content = ' <h3 id="CTitle"> Customer Details </h3> <p><i>'.$ErrorMsg.'</i></p> <form action=" " method="POST" name="CDetails" id="CDetails"> Name: * <input type="text" name="CName" size="30" value='.$_SESSION["CName"].'/></br> First line of your address: * <input type="text" name="CStreet" size="40" value='.$_SESSION["CStreet”];.’/></br> Town: * <input type="text" name="CTown" size="25" value='.$_SESSION["CTown"].'/></br> Postcode: * <input type="text" name="CPostcode" size="11" value=‘.$_SESSION["CPostcode"].'/></br> Email address: * <input type="text" name="CEmail" size ="35" value='.$_SESSION["CEmail”];.’/></br> Phone Number: * <input type="text" name="CNumb" value='.$_SESSION["CNumb"].'/></br> <input type="submit" name="NextPage" value="Next" id="Next”/> </form> ?>
  8. Hello all, I am an absolute beginner when it comes to PHP and Javascript but wanted a simple contact form for my website. I used the PHP code from one source and the Javascript validator code from another source and all is working fine except for one very annoying bug: I have to press the Submit button twice in order for the form to send the email. I've found that if the validator is already triggered, however, I only need to press the button once for it to submit. I have scoured the internet for a solution to this problem but am realizing this must be a hangup in the particular code I'm using and I'm just not experienced enough to troubleshoot it. A little help is greatly appreciated. Thank you for your time. Here's the client side code (truncated to only show relevant parts): <html> <head> <script src="js/gen_validatorv4.js" type="text/javascript"></script> </head> <body> <form method="post" action="contact.php" name="contactform"> <div class="row collapse-at-2 half"> <div class="6u"> <input name="name" placeholder="Name" type="text" /> </div> <div class="6u"> <input name="email" placeholder="Email" type="text" /> </div> </div> <div class="row half"> <div class="12u"> <textarea name="message" placeholder="Message"></textarea> </div> </div> <div class="row half"> <div class="12u"> <ul class="actions"> <li><input type="submit" value="Send Message" /></li> <li><input type="reset" value="Clear form" /></li> </ul> </div> </div> </form> <script type="text/javascript"> var myformValidator = new Validator("contactform"); myformValidator.addValidation("name","req", "Please provide your name."); myformValidator.addValidation("email","req", "Please provide your email."); myformValidator.addValidation("message","req", "Please enter your message."); myformValidator.addValidation("email","email", "Please enter a valid email address."); </script> </body> </html> Here's the Javascript validator code: function Validator(frmname) { this.validate_on_killfocus = false; this.formobj = document.forms[frmname]; if (!this.formobj) { alert("Error: couldnot get Form object " + frmname); return; } if (this.formobj.onsubmit) { this.formobj.old_onsubmit = this.formobj.onsubmit; this.formobj.onsubmit = null; } else { this.formobj.old_onsubmit = null; } this.formobj._sfm_form_name = frmname; this.formobj.onsubmit = form_submit_handler; this.addValidation = add_validation; this.formobj.addnlvalidations = new Array(); this.addAddnlValidationFunction = add_addnl_vfunction; this.formobj.runAddnlValidations = run_addnl_validations; this.setAddnlValidationFunction = set_addnl_vfunction;//for backward compatibility this.clearAllValidations = clear_all_validations; this.focus_disable_validations = false; document.error_disp_handler = new sfm_ErrorDisplayHandler(); this.EnableOnPageErrorDisplay = validator_enable_OPED; this.EnableOnPageErrorDisplaySingleBox = validator_enable_OPED_SB; this.show_errors_together = false; this.EnableMsgsTogether = sfm_enable_show_msgs_together; document.set_focus_onerror = true; this.EnableFocusOnError = sfm_validator_enable_focus; this.formobj.error_display_loc = 'right'; this.SetMessageDisplayPos = sfm_validator_message_disp_pos; this.formobj.DisableValidations = sfm_disable_validations; this.formobj.validatorobj = this; } function sfm_validator_enable_focus(enable) { document.set_focus_onerror = enable; } function add_addnl_vfunction() { var proc = { }; proc.func = arguments[0]; proc.arguments = []; for (var i = 1; i < arguments.length; i++) { proc.arguments.push(arguments[i]); } this.formobj.addnlvalidations.push(proc); } function set_addnl_vfunction(functionname) { if(functionname.constructor == String) { alert("Pass the function name like this: validator.setAddnlValidationFunction(DoCustomValidation)\n "+ "rather than passing the function name as string"); return; } this.addAddnlValidationFunction(functionname); } function run_addnl_validations() { var ret = true; for (var f = 0; f < this.addnlvalidations.length; f++) { var proc = this.addnlvalidations[f]; var args = proc.arguments || []; if (!proc.func.apply(null, args)) { ret = false; } } return ret; } function sfm_set_focus(objInput) { if (document.set_focus_onerror) { if (!objInput.disabled && objInput.type != 'hidden') { objInput.focus(); } } } function sfm_disable_validations() { if (this.old_onsubmit) { this.onsubmit = this.old_onsubmit; } else { this.onsubmit = null; } } function sfm_enable_show_msgs_together() { this.show_errors_together = true; this.formobj.show_errors_together = true; } function sfm_validator_message_disp_pos(pos) { this.formobj.error_display_loc = pos; } function clear_all_validations() { for (var itr = 0; itr < this.formobj.elements.length; itr++) { this.formobj.elements[itr].validationset = null; } } function form_submit_handler() { var bRet = true; document.error_disp_handler.clear_msgs(); for (var itr = 0; itr < this.elements.length; itr++) { if (this.elements[itr].validationset && !this.elements[itr].validationset.validate()) { bRet = false; } if (!bRet && !this.show_errors_together) { break; } } if (this.show_errors_together || bRet && !this.show_errors_together) { if (!this.runAddnlValidations()) { bRet = false; } } if (!bRet) { document.error_disp_handler.FinalShowMsg(); return false; } return true; } function add_validation(itemname, descriptor, errstr) { var condition = null; if (arguments.length > 3) { condition = arguments[3]; } if (!this.formobj) { alert("Error: The form object is not set properly"); return; } //if var itemobj = this.formobj[itemname]; if (itemobj.length && isNaN(itemobj.selectedIndex)) //for radio button; don't do for 'select' item { itemobj = itemobj[0]; } if (!itemobj) { alert("Error: Couldnot get the input object named: " + itemname); return; } if (true == this.validate_on_killfocus) { itemobj.onblur = handle_item_on_killfocus; } if (!itemobj.validationset) { itemobj.validationset = new ValidationSet(itemobj, this.show_errors_together); } itemobj.validationset.add(descriptor, errstr, condition); itemobj.validatorobj = this; } function handle_item_on_killfocus() { if (this.validatorobj.focus_disable_validations == true) { /* To avoid repeated looping message boxes */ this.validatorobj.focus_disable_validations = false; return false; } if (null != this.validationset) { document.error_disp_handler.clear_msgs(); if (false == this.validationset.validate()) { document.error_disp_handler.FinalShowMsg(); return false; } } } function validator_enable_OPED() { document.error_disp_handler.EnableOnPageDisplay(false); } function validator_enable_OPED_SB() { document.error_disp_handler.EnableOnPageDisplay(true); } function sfm_ErrorDisplayHandler() { this.msgdisplay = new AlertMsgDisplayer(); this.EnableOnPageDisplay = edh_EnableOnPageDisplay; this.ShowMsg = edh_ShowMsg; this.FinalShowMsg = edh_FinalShowMsg; this.all_msgs = new Array(); this.clear_msgs = edh_clear_msgs; } function edh_clear_msgs() { this.msgdisplay.clearmsg(this.all_msgs); this.all_msgs = new Array(); } function edh_FinalShowMsg() { if (this.all_msgs.length == 0) { return; } this.msgdisplay.showmsg(this.all_msgs); } function edh_EnableOnPageDisplay(single_box) { if (true == single_box) { this.msgdisplay = new SingleBoxErrorDisplay(); } else { this.msgdisplay = new DivMsgDisplayer(); } } function edh_ShowMsg(msg, input_element) { var objmsg = new Array(); objmsg["input_element"] = input_element; objmsg["msg"] = msg; this.all_msgs.push(objmsg); } function AlertMsgDisplayer() { this.showmsg = alert_showmsg; this.clearmsg = alert_clearmsg; } function alert_clearmsg(msgs) { } function alert_showmsg(msgs) { var whole_msg = ""; var first_elmnt = null; for (var m = 0; m < msgs.length; m++) { if (null == first_elmnt) { first_elmnt = msgs[m]["input_element"]; } whole_msg += msgs[m]["msg"] + "\n"; } alert(whole_msg); if (null != first_elmnt) { sfm_set_focus(first_elmnt); } } function sfm_show_error_msg(msg, input_elmt) { document.error_disp_handler.ShowMsg(msg, input_elmt); } function SingleBoxErrorDisplay() { this.showmsg = sb_div_showmsg; this.clearmsg = sb_div_clearmsg; } function sb_div_clearmsg(msgs) { var divname = form_error_div_name(msgs); sfm_show_div_msg(divname, ""); } function sb_div_showmsg(msgs) { var whole_msg = "<ul>\n"; for (var m = 0; m < msgs.length; m++) { whole_msg += "<li>" + msgs[m]["msg"] + "</li>\n"; } whole_msg += "</ul>"; var divname = form_error_div_name(msgs); var anc_name = divname + "_loc"; whole_msg = "<a name='" + anc_name + "' >" + whole_msg; sfm_show_div_msg(divname, whole_msg); window.location.hash = anc_name; } function form_error_div_name(msgs) { var input_element = null; for (var m in msgs) { input_element = msgs[m]["input_element"]; if (input_element) { break; } } var divname = ""; if (input_element) { divname = input_element.form._sfm_form_name + "_errorloc"; } return divname; } function sfm_show_div_msg(divname,msgstring) { if(divname.length<=0) return false; if(document.layers) { divlayer = document.layers[divname]; if(!divlayer){return;} divlayer.document.open(); divlayer.document.write(msgstring); divlayer.document.close(); } else if(document.all) { divlayer = document.all[divname]; if(!divlayer){return;} divlayer.innerHTML=msgstring; } else if(document.getElementById) { divlayer = document.getElementById(divname); if(!divlayer){return;} divlayer.innerHTML =msgstring; } divlayer.style.visibility="visible"; return false; } function DivMsgDisplayer() { this.showmsg = div_showmsg; this.clearmsg = div_clearmsg; } function div_clearmsg(msgs) { for (var m in msgs) { var divname = element_div_name(msgs[m]["input_element"]); show_div_msg(divname, ""); } } function element_div_name(input_element) { var divname = input_element.form._sfm_form_name + "_" + input_element.name + "_errorloc"; divname = divname.replace(/[\[\]]/gi, ""); return divname; } function div_showmsg(msgs) { var whole_msg; var first_elmnt = null; for (var m in msgs) { if (null == first_elmnt) { first_elmnt = msgs[m]["input_element"]; } var divname = element_div_name(msgs[m]["input_element"]); show_div_msg(divname, msgs[m]["msg"]); } if (null != first_elmnt) { sfm_set_focus(first_elmnt); } } function show_div_msg(divname, msgstring) { if (divname.length <= 0) return false; if (document.layers) { divlayer = document.layers[divname]; if (!divlayer) { return; } divlayer.document.open(); divlayer.document.write(msgstring); divlayer.document.close(); } else if (document.all) { divlayer = document.all[divname]; if (!divlayer) { return; } divlayer.innerHTML = msgstring; } else if (document.getElementById) { divlayer = document.getElementById(divname); if (!divlayer) { return; } divlayer.innerHTML = msgstring; } divlayer.style.visibility = "visible"; } function ValidationDesc(inputitem, desc, error, condition) { this.desc = desc; this.error = error; this.itemobj = inputitem; this.condition = condition; this.validate = vdesc_validate; } function vdesc_validate() { if (this.condition != null) { if (!eval(this.condition)) { return true; } } if (!validateInput(this.desc, this.itemobj, this.error)) { this.itemobj.validatorobj.focus_disable_validations = true; sfm_set_focus(this.itemobj); return false; } return true; } function ValidationSet(inputitem, msgs_together) { this.vSet = new Array(); this.add = add_validationdesc; this.validate = vset_validate; this.itemobj = inputitem; this.msgs_together = msgs_together; } function add_validationdesc(desc, error, condition) { this.vSet[this.vSet.length] = new ValidationDesc(this.itemobj, desc, error, condition); } function vset_validate() { var bRet = true; for (var itr = 0; itr < this.vSet.length; itr++) { bRet = bRet && this.vSet[itr].validate(); if (!bRet && !this.msgs_together) { break; } } return bRet; } /* checks the validity of an email address entered * returns true or false */ function validateEmail(email) { var splitted = email.match("^(.+)@(.+)$"); if (splitted == null) return false; if (splitted[1] != null) { var regexp_user = /^\"?[\w-_\.]*\"?$/; if (splitted[1].match(regexp_user) == null) return false; } if (splitted[2] != null) { var regexp_domain = /^[\w-\.]*\.[A-Za-z]{2,4}$/; if (splitted[2].match(regexp_domain) == null) { var regexp_ip = /^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/; if (splitted[2].match(regexp_ip) == null) return false; } // if return true; } return false; } function TestComparison(objValue, strCompareElement, strvalidator, strError) { var bRet = true; var objCompare = null; if (!objValue.form) { sfm_show_error_msg("Error: No Form object!", objValue); return false } objCompare = objValue.form.elements[strCompareElement]; if (!objCompare) { sfm_show_error_msg("Error: Element with name" + strCompareElement + " not found !", objValue); return false; } var objval_value = objValue.value; var objcomp_value = objCompare.value; if (strvalidator != "eqelmnt" && strvalidator != "neelmnt") { objval_value = objval_value.replace(/\,/g, ""); objcomp_value = objcomp_value.replace(/\,/g, ""); if (isNaN(objval_value)) { sfm_show_error_msg(objValue.name + ": Should be a number ", objValue); return false; } //if if (isNaN(objcomp_value)) { sfm_show_error_msg(objCompare.name + ": Should be a number ", objCompare); return false; } //if } //if var cmpstr = ""; switch (strvalidator) { case "eqelmnt": { if (objval_value != objcomp_value) { cmpstr = " should be equal to "; bRet = false; } //if break; } //case case "ltelmnt": { if (eval(objval_value) >= eval(objcomp_value)) { cmpstr = " should be less than "; bRet = false; } break; } //case case "leelmnt": { if (eval(objval_value) > eval(objcomp_value)) { cmpstr = " should be less than or equal to"; bRet = false; } break; } //case case "gtelmnt": { if (eval(objval_value) <= eval(objcomp_value)) { cmpstr = " should be greater than"; bRet = false; } break; } //case case "geelmnt": { if (eval(objval_value) < eval(objcomp_value)) { cmpstr = " should be greater than or equal to"; bRet = false; } break; } //case case "neelmnt": { if (objval_value.length > 0 && objcomp_value.length > 0 && objval_value == objcomp_value) { cmpstr = " should be different from "; bRet = false; } //if break; } } //switch if (bRet == false) { if (!strError || strError.length == 0) { strError = objValue.name + cmpstr + objCompare.name; } //if sfm_show_error_msg(strError, objValue); } //if return bRet; } function TestSelMin(objValue, strMinSel, strError) { var bret = true; var objcheck = objValue.form.elements[objValue.name]; var chkcount = 0; if (objcheck.length) { for (var c = 0; c < objcheck.length; c++) { if (objcheck[c].checked == "1") { chkcount++; } //if } //for } else { chkcount = (objcheck.checked == "1") ? 1 : 0; } var minsel = eval(strMinSel); if (chkcount < minsel) { if (!strError || strError.length == 0) { strError = "Please Select atleast" + minsel + " check boxes for" + objValue.name; } //if sfm_show_error_msg(strError, objValue); bret = false; } return bret; } function TestSelMax(objValue, strMaxSel, strError) { var bret = true; var objcheck = objValue.form.elements[objValue.name]; var chkcount = 0; if (objcheck.length) { for (var c = 0; c < objcheck.length; c++) { if (objcheck[c].checked == "1") { chkcount++; } //if } //for } else { chkcount = (objcheck.checked == "1") ? 1 : 0; } var maxsel = eval(strMaxSel); if (chkcount > maxsel) { if (!strError || strError.length == 0) { strError = "Please Select atmost " + maxsel + " check boxes for" + objValue.name; } //if sfm_show_error_msg(strError, objValue); bret = false; } return bret; } function IsCheckSelected(objValue, chkValue) { var selected = false; var objcheck = objValue.form.elements[objValue.name]; if (objcheck.length) { var idxchk = -1; for (var c = 0; c < objcheck.length; c++) { if (objcheck[c].value == chkValue) { idxchk = c; break; } //if } //for if (idxchk >= 0) { if (objcheck[idxchk].checked == "1") { selected = true; } } //if } else { if (objValue.checked == "1") { selected = true; } //if } //else return selected; } function TestDontSelectChk(objValue, chkValue, strError) { var pass = true; pass = IsCheckSelected(objValue, chkValue) ? false : true; if (pass == false) { if (!strError || strError.length == 0) { strError = "Can't Proceed as you selected " + objValue.name; } //if sfm_show_error_msg(strError, objValue); } return pass; } function TestShouldSelectChk(objValue, chkValue, strError) { var pass = true; pass = IsCheckSelected(objValue, chkValue) ? true : false; if (pass == false) { if (!strError || strError.length == 0) { strError = "You should select" + objValue.name; } //if sfm_show_error_msg(strError, objValue); } return pass; } function TestRequiredInput(objValue, strError) { var ret = true; if (VWZ_IsEmpty(objValue.value)) { ret = false; } //if else if (objValue.getcal && !objValue.getcal()) { ret = false; } if (!ret) { if (!strError || strError.length == 0) { strError = objValue.name + " : Required Field"; } //if sfm_show_error_msg(strError, objValue); } return ret; } function TestFileExtension(objValue, cmdvalue, strError) { var ret = false; var found = false; if (objValue.value.length <= 0) { //The 'required' validation is not done here return true; } var extns = cmdvalue.split(";"); for (var i = 0; i < extns.length; i++) { ext = objValue.value.substr(objValue.value.length - extns[i].length, extns[i].length); ext = ext.toLowerCase(); if (ext == extns[i]) { found = true; break; } } if (!found) { if (!strError || strError.length == 0) { strError = objValue.name + " allowed file extensions are: " + cmdvalue; } //if sfm_show_error_msg(strError, objValue); ret = false; } else { ret = true; } return ret; } function TestMaxLen(objValue, strMaxLen, strError) { var ret = true; if (eval(objValue.value.length) > eval(strMaxLen)) { if (!strError || strError.length == 0) { strError = objValue.name + " : " + strMaxLen + " characters maximum "; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestMinLen(objValue, strMinLen, strError) { var ret = true; if (eval(objValue.value.length) < eval(strMinLen)) { if (!strError || strError.length == 0) { strError = objValue.name + " : " + strMinLen + " characters minimum "; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestInputType(objValue, strRegExp, strError, strDefaultError) { var ret = true; var charpos = objValue.value.search(strRegExp); if (objValue.value.length > 0 && charpos >= 0) { if (!strError || strError.length == 0) { strError = strDefaultError; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestEmail(objValue, strError) { var ret = true; if (objValue.value.length > 0 && !validateEmail(objValue.value)) { if (!strError || strError.length == 0) { strError = objValue.name + ": Enter a valid Email address "; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestLessThan(objValue, strLessThan, strError) { var ret = true; var obj_value = objValue.value.replace(/\,/g, ""); strLessThan = strLessThan.replace(/\,/g, ""); if (isNaN(obj_value)) { sfm_show_error_msg(objValue.name + ": Should be a number ", objValue); ret = false; } //if else if (eval(obj_value) >= eval(strLessThan)) { if (!strError || strError.length == 0) { strError = objValue.name + " : value should be less than " + strLessThan; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestGreaterThan(objValue, strGreaterThan, strError) { var ret = true; var obj_value = objValue.value.replace(/\,/g, ""); strGreaterThan = strGreaterThan.replace(/\,/g, ""); if (isNaN(obj_value)) { sfm_show_error_msg(objValue.name + ": Should be a number ", objValue); ret = false; } //if else if (eval(obj_value) <= eval(strGreaterThan)) { if (!strError || strError.length == 0) { strError = objValue.name + " : value should be greater than " + strGreaterThan; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestRegExp(objValue, strRegExp, strError) { var ret = true; if (objValue.value.length > 0 && !objValue.value.match(strRegExp)) { if (!strError || strError.length == 0) { strError = objValue.name + ": Invalid characters found "; } //if sfm_show_error_msg(strError, objValue); ret = false; } //if return ret; } function TestDontSelect(objValue, dont_sel_value, strError) { var ret = true; if (objValue.value == null) { sfm_show_error_msg("Error: dontselect command for non-select Item", objValue); ret = false; } else if (objValue.value == dont_sel_value) { if (!strError || strError.length == 0) { strError = objValue.name + ": Please Select one option "; } //if sfm_show_error_msg(strError, objValue); ret = false; } return ret; } function TestSelectOneRadio(objValue, strError) { var objradio = objValue.form.elements[objValue.name]; var one_selected = false; for (var r = 0; r < objradio.length; r++) { if (objradio[r].checked == "1") { one_selected = true; break; } } if (false == one_selected) { if (!strError || strError.length == 0) { strError = "Please select one option from " + objValue.name; } sfm_show_error_msg(strError, objValue); } return one_selected; } function TestSelectRadio(objValue, cmdvalue, strError, testselect) { var objradio = objValue.form.elements[objValue.name]; var selected = false; for (var r = 0; r < objradio.length; r++) { if (objradio[r].value == cmdvalue && objradio[r].checked == "1") { selected = true; break; } } if (testselect == true && false == selected || testselect == false && true == selected) { sfm_show_error_msg(strError, objValue); return false; } return true; } //* Checks each field in a form function validateInput(strValidateStr, objValue, strError) { var ret = true; var epos = strValidateStr.search("="); var command = ""; var cmdvalue = ""; if (epos >= 0) { command = strValidateStr.substring(0, epos); cmdvalue = strValidateStr.substr(epos + 1); } else { command = strValidateStr; } switch (command) { case "req": case "required": { ret = TestRequiredInput(objValue, strError) break; } case "maxlength": case "maxlen": { ret = TestMaxLen(objValue, cmdvalue, strError) break; } case "minlength": case "minlen": { ret = TestMinLen(objValue, cmdvalue, strError) break; } case "alnum": case "alphanumeric": { ret = TestInputType(objValue, "[^A-Za-z0-9]", strError, objValue.name + ": Only alpha-numeric characters allowed "); break; } case "alnum_s": case "alphanumeric_space": { ret = TestInputType(objValue, "[^A-Za-z0-9\\s]", strError, objValue.name + ": Only alpha-numeric characters and space allowed "); break; } case "num": case "numeric": case "dec": case "decimal": { if (objValue.value.length > 0 && !objValue.value.match(/^[\-\+]?[\d\,]*\.?[\d]*$/)) { sfm_show_error_msg(strError, objValue); ret = false; } //if break; } case "alphabetic": case "alpha": { ret = TestInputType(objValue, "[^A-Za-z]", strError, objValue.name + ": Only alphabetic characters allowed "); break; } case "alphabetic_space": case "alpha_s": { ret = TestInputType(objValue, "[^A-Za-z\\s]", strError, objValue.name + ": Only alphabetic characters and space allowed "); break; } case "email": { ret = TestEmail(objValue, strError); break; } case "lt": case "lessthan": { ret = TestLessThan(objValue, cmdvalue, strError); break; } case "gt": case "greaterthan": { ret = TestGreaterThan(objValue, cmdvalue, strError); break; } case "regexp": { ret = TestRegExp(objValue, cmdvalue, strError); break; } case "dontselect": { ret = TestDontSelect(objValue, cmdvalue, strError) break; } case "dontselectchk": { ret = TestDontSelectChk(objValue, cmdvalue, strError) break; } case "shouldselchk": { ret = TestShouldSelectChk(objValue, cmdvalue, strError) break; } case "selmin": { ret = TestSelMin(objValue, cmdvalue, strError); break; } case "selmax": { ret = TestSelMax(objValue, cmdvalue, strError); break; } case "selone_radio": case "selone": { ret = TestSelectOneRadio(objValue, strError); break; } case "dontselectradio": { ret = TestSelectRadio(objValue, cmdvalue, strError, false); break; } case "selectradio": { ret = TestSelectRadio(objValue, cmdvalue, strError, true); break; } //Comparisons case "eqelmnt": case "ltelmnt": case "leelmnt": case "gtelmnt": case "geelmnt": case "neelmnt": { return TestComparison(objValue, cmdvalue, command, strError); break; } case "req_file": { ret = TestRequiredInput(objValue, strError); break; } case "file_extn": { ret = TestFileExtension(objValue, cmdvalue, strError); break; } } //switch return ret; } function VWZ_IsListItemSelected(listname, value) { for (var i = 0; i < listname.options.length; i++) { if (listname.options[i].selected == true && listname.options[i].value == value) { return true; } } return false; } function VWZ_IsChecked(objcheck, value) { if (objcheck.length) { for (var c = 0; c < objcheck.length; c++) { if (objcheck[c].checked == "1" && objcheck[c].value == value) { return true; } } } else { if (objcheck.checked == "1") { return true; } } return false; } function sfm_str_trim(strIn) { return strIn.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } function VWZ_IsEmpty(value) { value = sfm_str_trim(value); return (value.length) == 0 ? true : false; } And here's the contact.php code referenced client side: <?php $errors = ''; $name = $_POST['name']; $email_address = $_POST['email']; $message = $_POST['message']; $myemail = 'email address removed for privacy';//<-----Put Your email address here. if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) { $errors .= "\n Error: all fields are required"; return false; } if (!preg_match( "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email_address)) { $errors .= "\n Error: Invalid email address."; return false; } if( empty($errors)) { $to = $myemail; $email_subject = "Contact form submission: $name"; $email_body = "You have received a new message ". " Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message"; $headers = "From: $myemail\n"; $headers .= "Reply-To: $email_address"; mail($to,$email_subject,$email_body,$headers); //redirect to the 'thank you' page header('Location: contact-form-thank-you.html'); } ?> <!DOCTYPE HTML> <html> <head> <title>Contact Form Error</title> <script> function goBack() { window.history.back() } </script> <link rel="stylesheet" href="css/skel.css" /> <link rel="stylesheet" href="css/style.css" /> <!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]--> </head> <body> <!-- This page is displayed only if there is some error --> <p style="text-align: center;"><?php echo nl2br($errors); ?></p> <p style="text-align: center;"><button onclick="goBack()">Go Back</button></p> </body> </html>
  9. I'm developing a form which is essentially a simple set of radio buttons. Conceptually, it is like this: Please select a theme from the list: o Black o Blue o Red [submit] [Reset] I'm actually showing a slideshow of images showing the appearance of each of the themes in a slideshow that only shows one image at a time. I want my users to click on the image that represents the theme they want and, ideally, not have to click on the Submit button at all. Then I will save the name of the theme they chose in a cookie (if cookies are enabled). Many years ago, I dabbled in things like CGI and I have a vague recollection, possibly faulty, that it's not difficult to make a form that has only one set of radio buttons treat the selection of one of the radio buttons as a Submit. I don't remember how to do it though. Can anyone advise me on whether it is indeed possible and, if it is, how I make the selection of the radio button cause the form to be submitted?
  10. Hi all, im having a problem with deleting users from a student database, the database adds new students fine, the problem is deleting a student from the system. Each student has a button beside the student name labeled "Delete Student Number: (student number here)", but for some reason the code is just always deleting the last entry from the database and not the student for which the button beside their name is pressed... Any ideas? Thanks! <?php echo "<h1>Student Database</h1>"; require_once('output_functions.php'); function is_initial_request() { return ! isset($_POST['submit']); } function output_form() { echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">"; output_textfield('username', 'New Student: ', 'username', 30, 30, '', false); output_submit_button('Add Student'); echo "</form>"; } // Try to connect to database $dbconnection = mysqli_connect( "localhost", "bfm3", "eeshaica", "2017_bfm3" ); if ( ! $dbconnection ) { die('Unable to connect to database'); } // Code to allow the user to enter a new Student if ( ! is_initial_request() ) { $username = $_POST['username']; // Insert into the database $insert_sql = "INSERT INTO students ( username ) VALUES ('{$username}');"; $dbinsert_result = mysqli_query( $dbconnection, $insert_sql ); if ( ! $dbinsert_result ) { die(); } } // Code to allow the user to delete a new Student if ( isset($_POST['delete_row']) ) { $id = $_POST['deleteStudent']; $delete_sql = "DELETE FROM students WHERE id = {$id}"; $dbdelete_result = mysqli_query( $dbconnection, $delete_sql ); } $retrieve_sql = "SELECT * FROM students"; $dbretrieve_result = mysqli_query( $dbconnection, $retrieve_sql ); if ( ! $dbretrieve_result ) { die(); } if ( mysqli_num_rows( $dbretrieve_result ) != 0 ) { while ( $row = mysqli_fetch_assoc( $dbretrieve_result ) ) { echo $row['id']; echo "<table>"; echo "<form action=\"{$_SERVER['PHP_SELF']}\" name=\"delete_student\" method=\"POST\">"; echo "<tr><td><p><input type=\"submit\" name=\"delete_row\" value=\"Delete Student Number: {$row['id']}\" /></p></td><td><b>Student ID NO.</b> {$row['id']}</td></tr>"; echo "<input type=\"hidden\" name=\"deleteStudent\" value=\"{$row['id']}\">"; echo "<tr><td></td><td><b>Student Name:</b> {$row['username']}</td></tr>"; echo "</table>"; echo "<br>"; } } output_form(); // Free up memory and close the database connection mysqli_free_result( $dbretrieve_result ); mysqli_close( $dbconnection ); ?>
  11. Hi Prior to a few months ago, when a user hit the final submit button on our site (fitness testing) - the athlete's report (actually an email with a link to view their results) would be automatically be emailed to them and we'd also get an email confirming the test was taken. Now, we still get the confirmation email but the athlete doesn't receive an email. I've located this code and am wondering if there's additional code we need to add to get the process working again: # Email the secret link to the athlete: $i_secret_url = $set_baseurl.'report.php?sid='.$i_sid.'&a='.urlencode($i_passhash); $i_headers = "From: ManOfSteeleSports.com <info@manofsteelesports.com>\nX-Mailer: ManOfSteeleSports.com PHP Mail v1.0\nReply-To: ManOfSteeleSports.com <info@manofsteelesports.com>\nX-Priority: 3 (Normal)"; $i_message = 'Dear '.stripslashes($i_rec1["fname"]).' '.stripslashes($i_rec1["lname"]).', Thanks for the advice in advance!
  12. *Sorry if I posted in the wrong forum, please let me know if I am* I have a piechart with three inputs one submit button. I can input whatever angle into the three inputs and the piechart will draw with a .js I found online. but I found there's a slight problem which is the second time I input a value it just overlaps the previous piechart so if the second time submitting the angles and the angle values are smaller than the original one then you won't be able to see it..I will attach an image to explain it more clearly. <canvas id="piechart1"></canvas> <script type="text/javascript" > $(function() { $("#submitBtn").click(function() { var input1 = $("#angle1").val(); if($("#angle1").val()=='') input1=""; var input2 = $("#angle2").val(); if($("#angle2").val()=='') input2=""; var input3 = $("#angle3").val(); if($("#angle3").val()=='') input3=""; piechart("piechart1", ["cyan", "yellow", "green"], [input1, input2, input3]); }); }); </script> <form action="" method="post"> <label>Angle 1</label> <label>Angle 2</label> <label>Angle 3</label> <br> <input name="" id="angle1" value="" type="number"> <input name="" id="angle2" value="" type="number"> <input name="" id="angle3" value="" type="number"> <input type="button" id="submitBtn" value="submit"> </form> Can someone give me a hand with this? Thanks a lot~!
  13. hey all, i am a bit lost on this one. i have a single php page it has a login form a submit new timesheet form and a display my timesheets table. this is updated as soon as the user submits a new timesheet. my issue is, after a timesheet has been submitted once, the table will add a row from the database and its great. but if i page refresh, it submits another identical timesheet. this happens even if i unset all the post variables. what is the best resolution. is there some kind of cookie i have to use? i'd rather avoid cookies. i'd also rather avoid having a second php file. i dont fully understand the $_POST variable concept. why are they not unset?
  14. Hello, I've been having some troubles in form submitting with HTML and PHP dynamic pages. In this case, the link to register at my site is index.php?p=r Inside this link, I have a form where the user fills and then have a button to submit it: <form class="form-horizontal margin-none" id="registerform" method="_GET" autocomplete="on" action="index.php?p=r"> <!-- Widget --> <div class="widget widget-heading-simple widget-body-gray"> <div class="widget-body"> <h4>Personal Details</h4> <!-- Row --> <div class="row-fluid"> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="firstname">First name</label> <div class="controls"><input class="span12" id="firstname" name="firstname" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="lastname">Last name</label> <div class="controls"><input class="span12" id="lastname" name="lastname" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="email">E-mail</label> <div class="controls"><input class="span12" id="email" name="email" type="email" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="username">Username</label> <div class="controls"><input class="span12" id="username" name="username" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="password">Password</label> <div class="controls"><input class="span12" id="password" name="password" type="password" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="confirm_password">Confirm password</label> <div class="controls"><input class="span12" id="confirm_password" name="confirm_password" type="password" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <h4>Billing Details</h4> <!-- Row --> <!-- Alert --> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">x</button> <strong>Why we need your billing details?</strong> We need your billing details because as a seller/buyer, we need to know where to send the cards. So insert that data carefully, otherwhise can happen shipment mistakes. </div> <!-- // Alert END --> <div class="row-fluid"> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="address">Address</label> <div class="controls"><input class="span12" id="address" name="address" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="zipcode">Zip Code</label> <div class="controls"><input class="span12" id="zipcode" name="zipcode" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="city">City</label> <div class="controls"><input class="span12" id="city" name="city" type="text" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="State">State</label> <div class="controls"><input class="span12" id="state" name="state" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="confirm_password">Country</label> <div class="controls"><input class="span12" id="confirm_password" name="confirm_password" type="text" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <!-- Row --> <div class="row-fluid uniformjs"> <!-- Column --> <div class="span4"> <h4 style="margin-bottom: 10px;">Policy & Newsletter</h4> <label class="checkbox" for="agree"> <input type="checkbox" class="checkbox" id="agree" name="agree" /> I agree with <a href="#TOS" data-toggle="modal">Terms of Services</a> </label> <label class="checkbox" for="newsletter"> <input type="checkbox" class="checkbox" id="newsletter" name="newsletter" checked="true"/> Receive Newsletter </label> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <!-- Form actions --> <div class="form-actions" align="right"> <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Register</button> </div> <!-- // Form actions END --> </div> </div> <!-- // Widget END --> </form> <!-- // Form END --> The problems keeps in this part of code: <!-- Form actions --> <div class="form-actions" align="right"> <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Register</button> </div> <!-- // Form actions END --> When I click the Register Button, it redirects me to index.php?username......password.... Instead of reloading in the same page (index.php?p=r&username=.... ) I would like too the browser link doesn't show that data ( username, password ). Already tried to change the method to POST but it doesn't work. Can anyone help me please?
  15. Hi php Freaks XD I have a small problem. I have a form that i would like to make it so i can add a column to my table on my site. but the form that fills our the stuff, when i press the submit button i don't get a response. Here is a rly simple code that i can't get to work. When i press the button it should say "success", and if the textbox is empty it should say "error". simple right? Well i can't get any response what so ever. here is the code in simpel. if(isset($_POST['addTableBtn'])){ if(empty($_POST['addTableText'])){ echo "Error"; }else{ echo "Success"; } } and the submit button name and textbox name match, i have checket.
  16. Hello peoples. Right, what I'm trying to do is; you fill out a form that generates a HTML page (done with no problems) but you want to preview it before. So essentially, what I'm trying to do it submit a form, but opening another window in doing so, meaning that the entered information on the 1st page stays the same. Here's the code I'm trying: <form action="store_it.php" method="post" id="contact"> <fieldset> <label for="name" >The title of your page:*</label> <input type="text" name="name" value="<?php echo $name; ?>" placeholder="My project" id="name"> <br><label for="body" title="You may use HTML code in this box">The text for your page:*</label> <textarea onfocus="window.lstText=this;" name="body" value="<?php echo $body; ?>" id="body"></textarea><br> <input type="submit" value="Submit" name="submit" class="button" id="submit"><br> <input type="submit" value="Preview" onclick="window.open('store_it.php')"><br> </fieldset> </form> - Thanks, Xanco
  17. Hello, I am having trouble creating a function that allows me to increment on submission. I've attached the html form, which I need assistance with. <div id="backgroundgrid2"> <div id="header"><u> Do they bare any resemblance to each other?</u></div><br /> <center> <img src="gallery/genrochill.jpg" width="177" height="176" /> <img src="gallery/peele.jpg" width="175" height="176" /><br /> </center> Does Genro and Jordon Peele look alike?<br /> <form id="selection" name="selection" method="post"> <input type="radio" name="choice" value="yes">Yes<br> <input type="radio" name="choice" value="no">No<br /> <input type="reset" name="submit" value="Submit" /> </form> Voters who said yes are: <label id="yes">0</label><br /> Voters who said no are: <label id="no">0</label><br /> </div> The goal is to simply adjust the counter located within the label by one per submission. All help would be appreciated.
  18. i searched on google and can't seem to come up with an answer. I keep getting linked to some wiki article about cookies or something. Is there a way to disable the button after submit. or force user to click an "edit" button to enable "update" button? The website is below. Basically you enter the available apartment (select landlord, building, enter price, apt #, # of bedrooms). Hit enter. Added to database. http://responsiblyvodka.com/tester.php if you hit refresh it either reenters it or enters a blank line.
  19. I think I know the answer to this, but am hoping someone can help me. Here is the button code: <form action='writing.php' method='get'><input type='submit' class='sbmt' value='Journalism' name='lnk' /></form> I want the button value to be "Journalism," but I would like it if the text sent in the $_GET request was shortened to four letters, for example 'jour'. I have other links like this one that have spaces in the text and I don't want that in my links. My goal is to have a link that loads a new script and specifies a single four letter variable. I could use $_POST, but thought I would check with the experts and see if anyone had a suggestion that would work given the current set up. Can anyone think of a way to make that happen?
  20. Hi I am working with search form in php. I want my search button to work with autocomplete for three search bars. Kindly guide me with the coding for the search button to get connected with the result displaying. Please find attached my header file. The autocomplete is working, fetching the values from the database but I want - when we click on search button it should display the result. Thanks in advance. Expecting the reply from you soon.header.php
  21. For some reason i need to submit a form to an external website without changing the page. I'm a newbie with AJAX and i don't know how to do it so i would really appreciate if someone could help me. Here's the form i need to submit: Thanks a lot !
  22. Hi! I need to know when the php file has sent the email from the a HTML Form and passsing it to Jquery. i did some research in internet and i found the "submit" option with .serialize() in Jquery, but 'cause i'm new in php i can't get it work. How .serialize() works exactly? Because i'm having my "alert" just by clicing the submit bottom and not when the email has been sent. If someone could help me with a link to begginers to learn that or make a correction in my code, i would be very greatfull. Here's my code : HTML : <html> <form method="post" action="form-to-email.php" id="myform"> <div class="field"> <label for="name">Your Name :</label> <input type="text" name="name" id="name" class="required" /> </div> <div class="field"> <label for="email">Please, give us an email :</label> <input type="text" name="email" id="email" class="required email" /> </div> <div class="field"> <label for="message" id="message-bg">Tell us about your project :</label> <textarea name="message" rows="20" cols="20" id="message" class="required"></textarea> </div> <img id="icon-contact" src="images/icon-contact.png" alt="icon-contact" /> <div class="field"> <input type="submit" name="submit" value="Submit" class="submit-button" /> </div> </form> </html> PHP : <?php if(!isset($_POST['submit'])) { echo "error; you need to submit the form!"; } $name = $_POST['name']; $visitor_email = $_POST['email']; $message = $_POST['message']; //Validate first if(empty($name)||empty($visitor_email)) { echo "Name and email are mandatory!"; exit; } if(IsInjected($visitor_email)) { echo "Bad email value!"; exit; } $email_from = 'website-clientes@blabla.com';//<== update the email address $email_subject = "Mensaje del amigo/a $name"; $email_body = "Hola! Me llamo $name, y quisiera decirles :\n \n$message \n \n \n". $to = "blbla@blabla.com";//<== update the email address $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \n"; //Send the email! mail($to,$email_subject,$email_body,$headers); header('Location: index.html'); ?> JQUERY : $("#myform").submit(function(event) { /* stop form from submitting normally */ event.preventDefault(); $.post( 'form-to-email.php', $("#myform").serialize(), function() { $('#myform').get(0).reset(); alert("Your message has been sent, Thanks!") ; } ); }); Thanks a lot for your help !
  23. I have a form, it's reading the mysql database. I have a while loop to display all of the fields in the table so you can edit it. Yes, it displays the fields, but I'm having problems with the update part, when I specify the ID (which is a hidden field) it takes the last field in the form and uses that to update. For example: UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6';UPDATE mitigations SET `status`='Watch', `notes`='test6' WHERE id='6'; I need id to actually get the ID from the form where it's a hidden field. It works now, but only for the last field. Make sense? Here's the actual code I have on the edit form itself: <?php while ($data = mysql_fetch_array($mitigation_query)) {echo "<form><tr><td width='56' height='20px'><input type=hidden name='mitigation_id' value=". $data['id'] ."><span id='MitigationOnTrack'><input type='text' name='mitigation_status' value=". $data['status'] ."></span></td><td width='758'><input type=text name='mitigation_id' value=". $data['id'] ."><textarea rows=5 cols=100 name='mitigation_notes'>" . $data['notes'] ."</textarea></td></tr></form>"; } ?>
  24. hello everyone, I have a php form, everything works, I do not carry any header() at the end of the form because I have to stay on the same page and because I feel it wipes out the message you sent the form successfully, but for this though if reloading the page shows me the popup asking me to resend the form. how can i solve? I found a function in js with replacestate but I saw that it doesn't work with mobile Safari. if ( window.history.replaceState ) { window.history.replaceState( null, null, window.location.href ); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.